aboutsummaryrefslogtreecommitdiff
path: root/sbin/newfs/mkfs.c
diff options
context:
space:
mode:
authorWes Peters <wes@FreeBSD.org>2005-01-21 22:20:25 +0000
committerWes Peters <wes@FreeBSD.org>2005-01-21 22:20:25 +0000
commit34b59b6bf2398cfcac5a70930e0272efbc8c1624 (patch)
tree7fbfbe0303677bc55d5c8f4300d1d0ac2c58879f /sbin/newfs/mkfs.c
parent73e31afa1acf7eab45ee701d8ef1b3667d58e287 (diff)
downloadsrc-34b59b6bf2398cfcac5a70930e0272efbc8c1624.tar.gz
src-34b59b6bf2398cfcac5a70930e0272efbc8c1624.zip
Notes
Diffstat (limited to 'sbin/newfs/mkfs.c')
-rw-r--r--sbin/newfs/mkfs.c68
1 files changed, 38 insertions, 30 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index 66074c7850c9..b796aefa36fb 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -738,10 +738,12 @@ fsinit(time_t utime)
{
union dinode node;
struct group *grp;
+ int entries;
memset(&node, 0, sizeof node);
if ((grp = getgrnam("operator")) == NULL)
errx(35, "Cannot retrieve operator gid");
+ entries = (nflag) ? ROOTLINKCNT - 1: ROOTLINKCNT;
if (sblock.fs_magic == FS_UFS1_MAGIC) {
/*
* initialize the node
@@ -753,27 +755,30 @@ fsinit(time_t utime)
* create the root directory
*/
node.dp1.di_mode = IFDIR | UMASK;
- node.dp1.di_nlink = ROOTLINKCNT;
- node.dp1.di_size = makedir(root_dir, ROOTLINKCNT);
+ node.dp1.di_nlink = entries;
+ node.dp1.di_size = makedir(root_dir, entries);
node.dp1.di_db[0] = alloc(sblock.fs_fsize, node.dp1.di_mode);
node.dp1.di_blocks =
btodb(fragroundup(&sblock, node.dp1.di_size));
wtfs(fsbtodb(&sblock, node.dp1.di_db[0]), sblock.fs_fsize,
iobuf);
iput(&node, ROOTINO);
- /*
- * create the .snap directory
- */
- node.dp1.di_mode |= 020;
- node.dp1.di_gid = grp->gr_gid;
- node.dp1.di_nlink = SNAPLINKCNT;
- node.dp1.di_size = makedir(snap_dir, SNAPLINKCNT);
- node.dp1.di_db[0] = alloc(sblock.fs_fsize, node.dp1.di_mode);
- node.dp1.di_blocks =
- btodb(fragroundup(&sblock, node.dp1.di_size));
- wtfs(fsbtodb(&sblock, node.dp1.di_db[0]), sblock.fs_fsize,
- iobuf);
- iput(&node, ROOTINO + 1);
+ if (!nflag) {
+ /*
+ * create the .snap directory
+ */
+ node.dp1.di_mode |= 020;
+ node.dp1.di_gid = grp->gr_gid;
+ node.dp1.di_nlink = SNAPLINKCNT;
+ node.dp1.di_size = makedir(snap_dir, SNAPLINKCNT);
+ node.dp1.di_db[0] =
+ alloc(sblock.fs_fsize, node.dp1.di_mode);
+ node.dp1.di_blocks =
+ btodb(fragroundup(&sblock, node.dp1.di_size));
+ wtfs(fsbtodb(&sblock, node.dp1.di_db[0]),
+ sblock.fs_fsize, iobuf);
+ iput(&node, ROOTINO + 1);
+ }
} else {
/*
* initialize the node
@@ -786,27 +791,30 @@ fsinit(time_t utime)
* create the root directory
*/
node.dp2.di_mode = IFDIR | UMASK;
- node.dp2.di_nlink = ROOTLINKCNT;
- node.dp2.di_size = makedir(root_dir, ROOTLINKCNT);
+ node.dp2.di_nlink = entries;
+ node.dp2.di_size = makedir(root_dir, entries);
node.dp2.di_db[0] = alloc(sblock.fs_fsize, node.dp2.di_mode);
node.dp2.di_blocks =
btodb(fragroundup(&sblock, node.dp2.di_size));
wtfs(fsbtodb(&sblock, node.dp2.di_db[0]), sblock.fs_fsize,
iobuf);
iput(&node, ROOTINO);
- /*
- * create the .snap directory
- */
- node.dp2.di_mode |= 020;
- node.dp2.di_gid = grp->gr_gid;
- node.dp2.di_nlink = SNAPLINKCNT;
- node.dp2.di_size = makedir(snap_dir, SNAPLINKCNT);
- node.dp2.di_db[0] = alloc(sblock.fs_fsize, node.dp2.di_mode);
- node.dp2.di_blocks =
- btodb(fragroundup(&sblock, node.dp2.di_size));
- wtfs(fsbtodb(&sblock, node.dp2.di_db[0]), sblock.fs_fsize,
- iobuf);
- iput(&node, ROOTINO + 1);
+ if (!nflag) {
+ /*
+ * create the .snap directory
+ */
+ node.dp2.di_mode |= 020;
+ node.dp2.di_gid = grp->gr_gid;
+ node.dp2.di_nlink = SNAPLINKCNT;
+ node.dp2.di_size = makedir(snap_dir, SNAPLINKCNT);
+ node.dp2.di_db[0] =
+ alloc(sblock.fs_fsize, node.dp2.di_mode);
+ node.dp2.di_blocks =
+ btodb(fragroundup(&sblock, node.dp2.di_size));
+ wtfs(fsbtodb(&sblock, node.dp2.di_db[0]),
+ sblock.fs_fsize, iobuf);
+ iput(&node, ROOTINO + 1);
+ }
}
}