mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-24 07:40:52 +00:00
Add an option to suppress the creation of the .snap directory in
the new filesystem. This is intended for memory and vnode filesystems that will never be fsck'ed or dumped. Obtained from: St. Bernard Software RAPID MFC after: 2 weeks
This commit is contained in:
parent
73e31afa1a
commit
34b59b6bf2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=140603
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
.Nd construct a new UFS1/UFS2 file system
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl NUl
|
||||
.Op Fl NUln
|
||||
.Op Fl L Ar volname
|
||||
.Op Fl O Ar filesystem-type
|
||||
.Op Fl S Ar sector-size
|
||||
@ -159,6 +159,20 @@ currently 8%.
|
||||
See
|
||||
.Xr tunefs 8
|
||||
for more details on how to set this option.
|
||||
.It Fl n
|
||||
Do not create a .snap directory on the new filesystem.
|
||||
The resulting filesystem will not support snapshot generation, so
|
||||
.Xr dump 8
|
||||
in live mode and background
|
||||
.Xr fsck 8
|
||||
will not function properly.
|
||||
The traditional
|
||||
.Xr fsck 8
|
||||
and offline
|
||||
.Xr dump 8
|
||||
will work on the filesystem.
|
||||
This option is intended primarily for memory or vnode filesystems that
|
||||
do not require dump or fsck support.
|
||||
.It Fl o Ar optimization
|
||||
.Cm ( space
|
||||
or
|
||||
@ -219,6 +233,7 @@ on file systems that contain many small files.
|
||||
.Xr fs 5 ,
|
||||
.Xr bsdlabel 8 ,
|
||||
.Xr camcontrol 8 ,
|
||||
.Xr dump 8 ,
|
||||
.Xr dumpfs 8 ,
|
||||
.Xr fsck 8 ,
|
||||
.Xr mount 8 ,
|
||||
|
@ -118,6 +118,7 @@ int Rflag; /* regression test */
|
||||
int Uflag; /* enable soft updates for file system */
|
||||
int Eflag = 0; /* exit in middle of newfs for testing */
|
||||
int lflag; /* enable multilabel for file system */
|
||||
int nflag; /* do not create .snap directory */
|
||||
quad_t fssize; /* file system size */
|
||||
int sectorsize; /* bytes/sector */
|
||||
int realsectorsize; /* bytes/sector in hardware */
|
||||
@ -155,7 +156,7 @@ main(int argc, char *argv[])
|
||||
off_t mediasize;
|
||||
|
||||
while ((ch = getopt(argc, argv,
|
||||
"EL:NO:RS:T:Ua:b:c:d:e:f:g:h:i:lm:o:s:")) != -1)
|
||||
"EL:NO:RS:T:Ua:b:c:d:e:f:g:h:i:lm:no:s:")) != -1)
|
||||
switch (ch) {
|
||||
case 'E':
|
||||
Eflag++;
|
||||
@ -244,6 +245,9 @@ main(int argc, char *argv[])
|
||||
if ((minfree = atoi(optarg)) < 0 || minfree > 99)
|
||||
errx(1, "%s: bad free space %%", optarg);
|
||||
break;
|
||||
case 'n':
|
||||
nflag = 1;
|
||||
break;
|
||||
case 'o':
|
||||
if (strcmp(optarg, "space") == 0)
|
||||
opt = FS_OPTSPACE;
|
||||
|
@ -50,6 +50,7 @@ extern int Rflag; /* regression test */
|
||||
extern int Uflag; /* enable soft updates for file system */
|
||||
extern int Eflag; /* exit as if error, for testing */
|
||||
extern int lflag; /* enable multilabel MAC for file system */
|
||||
extern int nflag; /* do not create .snap directory */
|
||||
extern quad_t fssize; /* file system size */
|
||||
extern int sectorsize; /* bytes/sector */
|
||||
extern int realsectorsize; /* bytes/sector in hardware*/
|
||||
|
Loading…
Reference in New Issue
Block a user