summaryrefslogtreecommitdiffstats
path: root/sbin/newlfs
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/newlfs')
-rw-r--r--sbin/newlfs/Makefile6
-rw-r--r--sbin/newlfs/config.h18
-rw-r--r--sbin/newlfs/lfs.c134
-rw-r--r--sbin/newlfs/newfs.c29
-rw-r--r--sbin/newlfs/newlfs.86
5 files changed, 99 insertions, 94 deletions
diff --git a/sbin/newlfs/Makefile b/sbin/newlfs/Makefile
index c79c83e..2f6c03f 100644
--- a/sbin/newlfs/Makefile
+++ b/sbin/newlfs/Makefile
@@ -1,9 +1,9 @@
# @(#)Makefile 8.1 (Berkeley) 6/18/93
PROG= newlfs
-CFLAGS+=-I/sys/ufs/lfs
+CFLAGS+=-I${.CURDIR}/../../sys/ufs/lfs
SRCS= dkcksum.c lfs.c lfs_cksum.c misc.c newfs.c
-MAN8= newlfs.0
-.PATH: /sys/ufs/lfs ${.CURDIR}/../disklabel
+MAN8= newlfs.8
+.PATH: ${.CURDIR}/../../sys/ufs/lfs ${.CURDIR}/../disklabel
.include <bsd.prog.mk>
diff --git a/sbin/newlfs/config.h b/sbin/newlfs/config.h
index 2747f61..55fed69 100644
--- a/sbin/newlfs/config.h
+++ b/sbin/newlfs/config.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)config.h 8.3 (Berkeley) 5/24/95
+ * @(#)config.h 8.2 (Berkeley) 4/22/94
*/
/*
@@ -84,7 +84,7 @@
* determining the rotationally optimal layout for disk blocks
* within a file; the default of fs_rotdelay is 4ms.
*/
-#define ROTDELAY 4
+#define ROTDELAY 0
/*
* MAXCONTIG sets the default for the maximum number of blocks
@@ -115,7 +115,7 @@
* rotational positions that we distinguish. With NRPOS of 8 the resolution
* of our summary information is 2ms for a typical 3600 rpm drive.
*/
-#define NRPOS 8 /* number distinct rotational positions */
+#define NRPOS 1 /* number distinct rotational positions */
/*
* The following constants set the default block and segment size for a log
@@ -129,12 +129,6 @@
#define DFL_LFSSEG_MASK 0xFFFFF
#define LFS_MINBLOCKSIZE 1024
-#define DFL_LFSBLOCK 4096
-#define DFL_LFSBLOCK_SHIFT 12
-#define DFL_LFSBLOCK_MASK 0xFFF
-
-#define DFL_LFSFRAG 4096
-#define DFL_LFS_FFMASK DFL_LFSBLOCK_MASK
-#define DFL_LFS_FFSHIFT DFL_LFSBLOCK_SHIFT
-#define DFL_LFS_FBMASK 0
-#define DFL_LFS_FBSHIFT 0
+#define DFL_LFSBLOCK 8192
+#define DFL_LFSBLOCK_SHIFT 13
+#define DFL_LFSBLOCK_MASK 0x1FFF
diff --git a/sbin/newlfs/lfs.c b/sbin/newlfs/lfs.c
index dc271c4..c22f19f 100644
--- a/sbin/newlfs/lfs.c
+++ b/sbin/newlfs/lfs.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95";
+static char sccsid[] = "@(#)lfs.c 8.1 (Berkeley) 6/5/93";
#endif /* not lint */
#include <sys/param.h>
@@ -91,7 +91,7 @@ static struct lfs lfs_default = {
/* lfs_ssize */ DFL_LFSSEG/DFL_LFSBLOCK,
/* lfs_dsize */ 0,
/* lfs_bsize */ DFL_LFSBLOCK,
- /* lfs_fsize */ DFL_LFSFRAG,
+ /* lfs_fsize */ DFL_LFSBLOCK,
/* lfs_frag */ 1,
/* lfs_free */ LFS_FIRST_INUM,
/* lfs_bfree */ 0,
@@ -106,6 +106,7 @@ static struct lfs lfs_default = {
/* lfs_offset */ 0,
/* lfs_lastpseg */ 0,
/* lfs_tstamp */ 0,
+ /* lfs_maxsymlinklen */ MAXSYMLINKLEN,
/* lfs_minfree */ MINFREE,
/* lfs_maxfilesize */ 0,
/* lfs_dbpseg */ DFL_LFSSEG/DEV_BSIZE,
@@ -121,10 +122,10 @@ static struct lfs lfs_default = {
/* lfs_segshift */ DFL_LFSSEG_SHIFT,
/* lfs_bmask */ DFL_LFSBLOCK_MASK,
/* lfs_bshift */ DFL_LFSBLOCK_SHIFT,
- /* lfs_ffmask */ DFL_LFS_FFMASK,
- /* lfs_ffshift */ DFL_LFS_FFSHIFT,
- /* lfs_fbmask */ DFL_LFS_FBMASK,
- /* lfs_fbshift */ DFL_LFS_FBSHIFT,
+ /* lfs_ffmask */ 0,
+ /* lfs_ffshift */ 0,
+ /* lfs_fbmask */ 0,
+ /* lfs_fbshift */ 0,
/* lfs_fsbtodb */ 0,
/* lfs_sushift */ 0,
/* lfs_sboffs */ { 0 },
@@ -143,8 +144,8 @@ static struct lfs lfs_default = {
/* lfs_flags */ 0,
/* lfs_fsmnt */ { 0 },
/* lfs_pad */ { 0 },
- /* lfs_cksum */ 0,
- /* lfs_maxsymlinklen */ MAXSYMLINKLEN
+ /* lfs_pad2 */ { 0 },
+ /* lfs_cksum */ 0
};
@@ -160,19 +161,18 @@ struct direct lfs_lf_dir[] = {
{ ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." },
};
-static daddr_t make_dinode
+static daddr_t make_dinode
__P((ino_t, struct dinode *, int, daddr_t, struct lfs *));
static void make_dir __P(( void *, struct direct *, int));
static void put __P((int, off_t, void *, size_t));
int
-make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
+make_lfs(fd, lp, partp, minfree, bsize, seg_size)
int fd;
struct disklabel *lp;
struct partition *partp;
int minfree;
- int block_size;
- int frag_size;
+ int bsize;
int seg_size;
{
struct dinode *dip; /* Pointer to a disk inode */
@@ -197,8 +197,6 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
u_long *dp; /* Used to computed checksum on data */
u_long *datasump; /* Used to computed checksum on data */
int block_array_size; /* How many entries in block array */
- int bsize; /* Block size */
- int fsize; /* Fragment size */
int db_per_fb; /* Disk blocks per file block */
int i, j;
int off; /* Offset at which to write */
@@ -209,29 +207,19 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
lfsp = &lfs_default;
- if (!(bsize = block_size))
- bsize = DFL_LFSBLOCK;
- if (!(fsize = frag_size))
- fsize = DFL_LFSFRAG;
if (!(ssize = seg_size))
ssize = DFL_LFSSEG;
/* Modify parts of superblock overridden by command line arguments */
- if (bsize != DFL_LFSBLOCK || fsize != DFL_LFSFRAG) {
+ if (bsize != DFL_LFSBLOCK) {
lfsp->lfs_bshift = log2(bsize);
if (1 << lfsp->lfs_bshift != bsize)
fatal("%d: block size not a power of 2", bsize);
lfsp->lfs_bsize = bsize;
- lfsp->lfs_fsize = fsize;
+ lfsp->lfs_fsize = bsize;
lfsp->lfs_bmask = bsize - 1;
lfsp->lfs_inopb = bsize / sizeof(struct dinode);
- lfsp->lfs_ffmask = fsize - 1;
- lfsp->lfs_ffshift = log2(fsize);
- if (1 << lfsp->lfs_ffshift != fsize)
- fatal("%d: frag size not a power of 2", fsize);
- lfsp->lfs_frag = numfrags(lfsp, bsize);
- lfsp->lfs_fbmask = lfsp->lfs_frag - 1;
- lfsp->lfs_fbshift = log2(lfsp->lfs_frag);
+
/* MIS -- should I round to power of 2 */
lfsp->lfs_ifpb = bsize / sizeof(IFILE);
lfsp->lfs_sepb = bsize / sizeof(SEGUSE);
@@ -263,7 +251,7 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
lfsp->lfs_nseg = lfsp->lfs_dsize / lfsp->lfs_ssize;
lfsp->lfs_maxfilesize = maxtable[lfsp->lfs_bshift] << lfsp->lfs_bshift;
- /*
+ /*
* The number of free blocks is set from the number of segments times
* the segment size - 2 (that we never write because we need to make
* sure the cleaner can run). Then we'll subtract off the room for the
@@ -290,7 +278,7 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
/* Figure out where the superblocks are going to live */
lfsp->lfs_sboffs[0] = LFS_LABELPAD/lp->d_secsize;
for (i = 1; i < LFS_MAXNUMSB; i++) {
- sb_addr = ((i * sb_interval) <<
+ sb_addr = ((i * sb_interval) <<
(lfsp->lfs_segshift - lfsp->lfs_bshift + lfsp->lfs_fsbtodb))
+ lfsp->lfs_sboffs[0];
if (sb_addr > partp->p_size)
@@ -299,15 +287,15 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
}
last_sb_addr = lfsp->lfs_sboffs[i - 1];
lfsp->lfs_lastseg = lfsp->lfs_sboffs[0];
- lfsp->lfs_nextseg =
+ lfsp->lfs_nextseg =
lfsp->lfs_sboffs[1] ? lfsp->lfs_sboffs[1] : lfsp->lfs_sboffs[0];
lfsp->lfs_curseg = lfsp->lfs_lastseg;
/*
* Initialize the segment usage table. The first segment will
- * contain the superblock, the cleanerinfo (cleansz), the segusage
- * table * (segtabsz), 1 block's worth of IFILE entries, the root
- * directory, the lost+found directory and one block's worth of
+ * contain the superblock, the cleanerinfo (cleansz), the segusage
+ * table * (segtabsz), 1 block's worth of IFILE entries, the root
+ * directory, the lost+found directory and one block's worth of
* inodes (containing the ifile, root, and l+f inodes).
*/
if (!(cleaninfo = malloc(lfsp->lfs_cleansz << lfsp->lfs_bshift)))
@@ -329,7 +317,7 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
lfsp->lfs_bfree -=
fsbtodb(lfsp, lfsp->lfs_cleansz + lfsp->lfs_segtabsz + 4);
- /*
+ /*
* Now figure out the address of the ifile inode. The inode block
* appears immediately after the segment summary.
*/
@@ -348,47 +336,47 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
segp->su_nsums = 0;
}
- /*
+ /*
* Initialize dynamic accounting. The blocks available for
* writing are the bfree blocks minus 1 segment summary for
* each segment since you can't write any new data without
* creating a segment summary - 2 segments that the cleaner
* needs.
*/
- lfsp->lfs_avail = lfsp->lfs_bfree - lfsp->lfs_nseg -
+ lfsp->lfs_avail = lfsp->lfs_bfree - lfsp->lfs_nseg -
fsbtodb(lfsp, 2 * lfsp->lfs_ssize);
lfsp->lfs_uinodes = 0;
/*
* Ready to start writing segments. The first segment is different
* because it contains the segment usage table and the ifile inode
- * as well as a superblock. For the rest of the segments, set the
+ * as well as a superblock. For the rest of the segments, set the
* time stamp to be 0 so that the first segment is the most recent.
* For each segment that is supposed to contain a copy of the super
- * block, initialize its first few blocks and its segment summary
+ * block, initialize its first few blocks and its segment summary
* to indicate this.
*/
lfsp->lfs_nfiles = LFS_FIRST_INUM - 1;
- lfsp->lfs_cksum =
+ lfsp->lfs_cksum =
cksum(lfsp, sizeof(struct lfs) - sizeof(lfsp->lfs_cksum));
/* Now create a block of disk inodes */
if (!(dpagep = malloc(lfsp->lfs_bsize)))
fatal("%s", strerror(errno));
dip = (struct dinode *)dpagep;
- memset(dip, 0, lfsp->lfs_bsize);
+ bzero(dip, lfsp->lfs_bsize);
/* Create a block of IFILE structures. */
if (!(ipagep = malloc(lfsp->lfs_bsize)))
fatal("%s", strerror(errno));
ifile = (IFILE *)ipagep;
- /*
+ /*
* Initialize IFILE. It is the next block following the
* block of inodes (whose address has been calculated in
* lfsp->lfs_idaddr;
*/
sb_addr = lfsp->lfs_idaddr + lfsp->lfs_bsize / lp->d_secsize;
- sb_addr = make_dinode(LFS_IFILE_INUM, dip,
+ sb_addr = make_dinode(LFS_IFILE_INUM, dip,
lfsp->lfs_cleansz + lfsp->lfs_segtabsz+1, sb_addr, lfsp);
dip->di_mode = IFREG|IREAD|IWRITE;
ip = &ifile[LFS_IFILE_INUM];
@@ -416,10 +404,10 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
/* Make all the other dinodes invalid */
for (i = INOPB(lfsp)-3, dip++; i; i--, dip++)
dip->di_inumber = LFS_UNUSED_INUM;
-
+
/* Link remaining IFILE entries in free list */
- for (ip = &ifile[LFS_FIRST_INUM], i = LFS_FIRST_INUM;
+ for (ip = &ifile[LFS_FIRST_INUM], i = LFS_FIRST_INUM;
i < lfsp->lfs_ifpb; ++ip) {
ip->if_version = 1;
ip->if_daddr = LFS_UNUSED_DADDR;
@@ -433,10 +421,10 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
dp = datasump = malloc (blocks_used * sizeof(u_long));
*dp++ = ((u_long *)dpagep)[0]; /* inode block */
for (i = 0; i < lfsp->lfs_cleansz; i++)
- *dp++ = ((u_long *)cleaninfo)[(i << lfsp->lfs_bshift) /
+ *dp++ = ((u_long *)cleaninfo)[(i << lfsp->lfs_bshift) /
sizeof(u_long)]; /* Cleaner info */
for (i = 0; i < lfsp->lfs_segtabsz; i++)
- *dp++ = ((u_long *)segtable)[(i << lfsp->lfs_bshift) /
+ *dp++ = ((u_long *)segtable)[(i << lfsp->lfs_bshift) /
sizeof(u_long)]; /* Segusage table */
*dp++ = ((u_long *)ifile)[0]; /* Ifile */
@@ -462,20 +450,20 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
off += lfsp->lfs_bsize;
/*
- * use ipagep for space for writing out other stuff. It used to
+ * use ipagep for space for writing out other stuff. It used to
* contain the ifile, but we're done with it.
*/
/* Write out the root and lost and found directories */
- memset(ipagep, 0, lfsp->lfs_bsize);
- make_dir(ipagep, lfs_root_dir,
+ bzero(ipagep, lfsp->lfs_bsize);
+ make_dir(ipagep, lfs_root_dir,
sizeof(lfs_root_dir) / sizeof(struct direct));
*dp++ = ((u_long *)ipagep)[0];
put(fd, off, ipagep, lfsp->lfs_bsize);
off += lfsp->lfs_bsize;
- memset(ipagep, 0, lfsp->lfs_bsize);
- make_dir(ipagep, lfs_lf_dir,
+ bzero(ipagep, lfsp->lfs_bsize);
+ make_dir(ipagep, lfs_lf_dir,
sizeof(lfs_lf_dir) / sizeof(struct direct));
*dp++ = ((u_long *)ipagep)[0];
put(fd, off, ipagep, lfsp->lfs_bsize);
@@ -484,7 +472,7 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
lfsp->lfs_offset = (off + lfsp->lfs_bsize) / lp->d_secsize;
put(fd, LFS_LABELPAD, lfsp, sizeof(struct lfs));
- /*
+ /*
* Finally, calculate all the fields for the summary structure
* and write it.
*/
@@ -493,7 +481,6 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
summary.ss_create = lfsp->lfs_tstamp;
summary.ss_nfinfo = 3;
summary.ss_ninos = 3;
- summary.ss_magic = SS_MAGIC;
summary.ss_datasum = cksum(datasump, sizeof(u_long) * blocks_used);
/*
@@ -524,36 +511,34 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
/* copy into segment */
sump = ipagep;
- memmove(sump, &summary, sizeof(SEGSUM));
+ bcopy(&summary, sump, sizeof(SEGSUM));
sump += sizeof(SEGSUM);
/* Now, add the ifile */
file_info.fi_nblocks = block_array_size;
file_info.fi_version = 1;
- file_info.fi_lastlength = lfsp->lfs_bsize;
file_info.fi_ino = LFS_IFILE_INUM;
- memmove(sump, &file_info, sizeof(FINFO) - sizeof(u_long));
+ bcopy(&file_info, sump, sizeof(FINFO) - sizeof(u_long));
sump += sizeof(FINFO) - sizeof(u_long);
- memmove(sump, block_array, sizeof(u_long) * file_info.fi_nblocks);
+ bcopy(block_array, sump, sizeof(u_long) * file_info.fi_nblocks);
sump += sizeof(u_long) * file_info.fi_nblocks;
/* Now, add the root directory */
file_info.fi_nblocks = 1;
file_info.fi_version = 1;
- file_info.fi_lastlength = lfsp->lfs_bsize;
file_info.fi_ino = ROOTINO;
file_info.fi_blocks[0] = 0;
- memmove(sump, &file_info, sizeof(FINFO));
+ bcopy(&file_info, sump, sizeof(FINFO));
sump += sizeof(FINFO);
/* Now, add the lost and found */
file_info.fi_ino = LOSTFOUNDINO;
- memmove(sump, &file_info, sizeof(FINFO));
+ bcopy(&file_info, sump, sizeof(FINFO));
- ((daddr_t *)ipagep)[LFS_SUMMARY_SIZE / sizeof(daddr_t) - 1] =
+ ((daddr_t *)ipagep)[LFS_SUMMARY_SIZE / sizeof(daddr_t) - 1] =
lfsp->lfs_idaddr;
- ((SEGSUM *)ipagep)->ss_sumsum = cksum(ipagep+sizeof(summary.ss_sumsum),
+ ((SEGSUM *)ipagep)->ss_sumsum = cksum(ipagep+sizeof(summary.ss_sumsum),
LFS_SUMMARY_SIZE - sizeof(summary.ss_sumsum));
put(fd, LFS_LABELPAD + LFS_SBPAD, ipagep, LFS_SUMMARY_SIZE);
@@ -562,7 +547,6 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
sp->ss_nfinfo = 0;
sp->ss_ninos = 0;
sp->ss_datasum = 0;
- sp->ss_magic = SS_MAGIC;
/* Now write the summary block for the next partial so it's invalid */
lfsp->lfs_tstamp = 0;
@@ -572,9 +556,9 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
put(fd, off, sp, LFS_SUMMARY_SIZE);
/* Now, write rest of segments containing superblocks */
- lfsp->lfs_cksum =
+ lfsp->lfs_cksum =
cksum(lfsp, sizeof(struct lfs) - sizeof(lfsp->lfs_cksum));
- for (seg_addr = last_addr = lfsp->lfs_sboffs[0], j = 1, i = 1;
+ for (seg_addr = last_addr = lfsp->lfs_sboffs[0], j = 1, i = 1;
i < lfsp->lfs_nseg; i++) {
seg_addr += lfsp->lfs_ssize << lfsp->lfs_fsbtodb;
@@ -587,10 +571,10 @@ make_lfs(fd, lp, partp, minfree, block_size, frag_size, seg_size)
j++;
put(fd, seg_seek, lfsp, sizeof(struct lfs));
seg_seek += LFS_SBPAD;
- }
+ }
/* Summary */
- sp->ss_sumsum = cksum(&sp->ss_datasum,
+ sp->ss_sumsum = cksum(&sp->ss_datasum,
LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum));
put(fd, seg_seek, sp, LFS_SUMMARY_SIZE);
}
@@ -621,6 +605,10 @@ put(fd, off, p, len)
* directory.
*/
+ u_long d_ino; /* inode number of entry */
+ u_short d_reclen; /* length of this record */
+ u_short d_namlen; /* length of string in d_name */
+ char d_name[MAXNAMLEN + 1]; /* name with length <= MAXNAMLEN */
void
lfsinit()
{}
@@ -639,8 +627,10 @@ make_dinode(ino, dip, nblocks, saddr, lfsp)
dip->di_blocks = nblocks << lfsp->lfs_fsbtodb;
dip->di_size = (nblocks << lfsp->lfs_bshift);
- dip->di_atime = dip->di_mtime = dip->di_ctime = lfsp->lfs_tstamp;
- dip->di_atimensec = dip->di_mtimensec = dip->di_ctimensec = 0;
+ dip->di_atime.tv_sec = dip->di_mtime.tv_sec =
+ dip->di_ctime.tv_sec = lfsp->lfs_tstamp;
+ dip->di_atime.tv_nsec = dip->di_mtime.tv_nsec =
+ dip->di_ctime.tv_nsec = 0;
dip->di_inumber = ino;
#define SEGERR \
@@ -659,7 +649,7 @@ make_dinode(ino, dip, nblocks, saddr, lfsp)
/*
* Construct a set of directory entries in "bufp". We assume that all the
- * entries in protodir fir in the first DIRBLKSIZ.
+ * entries in protodir fir in the first DIRBLKSIZ.
*/
static void
make_dir(bufp, protodir, entries)
@@ -673,11 +663,11 @@ make_dir(bufp, protodir, entries)
spcleft = DIRBLKSIZ;
for (cp = bufp, i = 0; i < entries - 1; i++) {
protodir[i].d_reclen = DIRSIZ(NEWDIRFMT, &protodir[i]);
- memmove(cp, &protodir[i], protodir[i].d_reclen);
+ bcopy(&protodir[i], cp, protodir[i].d_reclen);
cp += protodir[i].d_reclen;
if ((spcleft -= protodir[i].d_reclen) < 0)
fatal("%s: %s", special, "directory too big");
}
protodir[i].d_reclen = spcleft;
- memmove(cp, &protodir[i], DIRSIZ(NEWDIRFMT, &protodir[i]));
+ bcopy(&protodir[i], cp, DIRSIZ(NEWDIRFMT, &protodir[i]));
}
diff --git a/sbin/newlfs/newfs.c b/sbin/newlfs/newfs.c
index 88ca638..4f8e72d 100644
--- a/sbin/newlfs/newfs.c
+++ b/sbin/newlfs/newfs.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)newfs.c 8.5 (Berkeley) 5/24/95";
+static char sccsid[] = "@(#)newfs.c 8.3 (Berkeley) 4/22/94";
#endif /* not lint */
/*
@@ -127,7 +127,7 @@ main(argc, argv)
int debug, lfs, fsi, fso, segsize;
char *cp, *opstring;
- if (progname = strrchr(*argv, '/'))
+ if (progname = rindex(*argv, '/'))
++progname;
else
progname = *argv;
@@ -269,7 +269,7 @@ main(argc, argv)
* prefix, try /dev/r%s and then /dev/%s.
*/
special = argv[0];
- if (strchr(special, '/') == NULL) {
+ if (index(special, '/') == NULL) {
(void)sprintf(device, "%sr%s", _PATH_DEV, special);
if (stat(device, &st) == -1)
(void)sprintf(device, "%s%s", _PATH_DEV, special);
@@ -293,7 +293,7 @@ main(argc, argv)
if (!debug && !mfs && !S_ISCHR(st.st_mode))
(void)printf("%s: %s: not a character-special device\n",
progname, special);
- cp = strchr(argv[0], '\0') - 1;
+ cp = index(argv[0], '\0') - 1;
if (!debug && (cp == 0 || (*cp < 'a' || *cp > 'h') && !isdigit(*cp)))
fatal("%s: can't figure out file system partition", argv[0]);
@@ -312,9 +312,26 @@ main(argc, argv)
pp = &lp->d_partitions[*cp - 'a'];
if (pp->p_size == 0)
fatal("%s: `%c' partition is unavailable", argv[0], *cp);
+ if (fsize == 0) {
+ fsize = pp->p_fsize;
+ if (fsize <= 0)
+ fsize = MAX(DFL_FRAGSIZE, lp->d_secsize);
+ }
+
+ if (bsize == 0) {
+ bsize = pp->p_frag * fsize;
+ if (bsize <= 0)
+ bsize = MIN(DFL_LFSBLOCK, 8 * fsize);
+ }
+
+ if (segsize == 0) {
+ segsize = pp->p_cpg * bsize;
+ if (segsize <= 0)
+ segsize = DFL_LFSSEG;
+ }
/* If we're making a LFS, we break out here */
- exit(make_lfs(fso, lp, pp, minfree, bsize, fsize, segsize));
+ exit(make_lfs(fso, lp, pp, minfree, bsize, segsize));
}
#ifdef COMPAT
@@ -401,7 +418,7 @@ rewritelabel(s, fd, lp)
cfd = open(specname, O_WRONLY);
if (cfd < 0)
fatal("%s: %s", specname, strerror(errno));
- memset(blk, 0, sizeof(blk));
+ bzero(blk, sizeof(blk));
*(struct disklabel *)(blk + LABELOFFSET) = *lp;
alt = lp->d_ncylinders * lp->d_secpercyl - lp->d_nsectors;
for (i = 1; i < 11 && i < lp->d_nsectors; i += 2) {
diff --git a/sbin/newlfs/newlfs.8 b/sbin/newlfs/newlfs.8
index 92474e5..63abcbe 100644
--- a/sbin/newlfs/newlfs.8
+++ b/sbin/newlfs/newlfs.8
@@ -30,6 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)newlfs.8 8.1 (Berkeley) 6/19/93
+.\" $Id$
.\"
.Dd June 19, 1993
.Dt NEWLFS 8
@@ -72,9 +73,9 @@ The size of the file system in sectors.
.Sh SEE ALSO
.Xr disktab 5 ,
.Xr fs 5 ,
-.Xr dumplfs 8 ,
.Xr disklabel 8 ,
.Xr diskpart 8 ,
+.Xr dumplfs 8 ,
.Xr tunefs 8
.Rs
.%A M. McKusick
@@ -88,6 +89,9 @@ The size of the file system in sectors.
.%D August 1984
.%O (reprinted in the BSD System Manager's Manual)
.Re
+.Sh BUGS
+LFS does not currently work in any variant of FreeBSD and should therefore
+not be used.
.Sh HISTORY
The
.Nm
OpenPOWER on IntegriCloud