mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-24 11:29:10 +00:00
Bring in support for volume labels to the filesystem utilities.
Reviewed by: mckusick
This commit is contained in:
parent
03b6e02551
commit
c715b047bc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=110174
@ -237,6 +237,9 @@ dumpfs(const char *name)
|
||||
if (fsflags != 0)
|
||||
printf("unknown flags (%#x)", fsflags);
|
||||
putchar('\n');
|
||||
printf("fsmnt\t%s\n", afs.fs_fsmnt);
|
||||
printf("volname\t%s\tswuid\t%qu\n",
|
||||
afs.fs_volname, afs.fs_swuid);
|
||||
printf("\ncs[].cs_(nbfree,ndir,nifree,nffree):\n\t");
|
||||
afs.fs_csp = calloc(1, afs.fs_cssize);
|
||||
if (bread(&disk, fsbtodb(&afs, afs.fs_csaddr), afs.fs_csp, afs.fs_cssize) == -1)
|
||||
|
@ -140,6 +140,8 @@ mkfs(struct partition *pp, char *fsys)
|
||||
sblock.fs_flags = 0;
|
||||
if (Uflag)
|
||||
sblock.fs_flags |= FS_DOSOFTDEP;
|
||||
if (Lflag)
|
||||
strlcpy(sblock.fs_volname, volumelabel, MAXVOLLEN);
|
||||
/*
|
||||
* Validate the given file system size.
|
||||
* Verify that its last block can actually be accessed.
|
||||
|
@ -40,6 +40,7 @@
|
||||
.Nd construct a new file system
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl L Ar volname
|
||||
.Op Fl NU
|
||||
.Op Fl O Ar filesystem-type
|
||||
.Op Fl S Ar sector-size
|
||||
@ -82,6 +83,8 @@ The following options define the general layout policies:
|
||||
.Bl -tag -width indent
|
||||
.It Fl T Ar disktype
|
||||
For backward compatibility.
|
||||
.It Fl L Ar volname
|
||||
Add a volume label to the new file system.
|
||||
.It Fl N
|
||||
Cause the file system parameters to be printed out
|
||||
without really creating the file system.
|
||||
|
@ -117,6 +117,7 @@ static const char rcsid[] =
|
||||
*/
|
||||
#define NFPI 4
|
||||
|
||||
int Lflag; /* add a volume label */
|
||||
int Nflag; /* run without writing file system */
|
||||
int Oflag = 1; /* file system format (1 => UFS1, 2 => UFS2) */
|
||||
int Rflag; /* regression test */
|
||||
@ -136,6 +137,7 @@ int maxbpg; /* maximum blocks per file in a cyl group */
|
||||
int avgfilesize = AVFILESIZ;/* expected average file size */
|
||||
int avgfilesperdir = AFPDIR;/* expected number of files per directory */
|
||||
int fso; /* filedescriptor to device */
|
||||
u_char *volumelabel = NULL; /* volume label for filesystem */
|
||||
|
||||
static char device[MAXPATHLEN];
|
||||
static char *disktype;
|
||||
@ -153,12 +155,25 @@ main(int argc, char *argv[])
|
||||
struct partition oldpartition;
|
||||
struct stat st;
|
||||
char *cp, *special;
|
||||
int ch;
|
||||
int ch, i;
|
||||
off_t mediasize;
|
||||
|
||||
while ((ch = getopt(argc, argv,
|
||||
"NO:RS:T:Ua:b:c:d:e:f:g:h:i:m:o:s:")) != -1)
|
||||
"L:NO:RS:T:Ua:b:c:d:e:f:g:h:i:m:o:s:")) != -1)
|
||||
switch (ch) {
|
||||
case 'L':
|
||||
volumelabel = optarg;
|
||||
i = -1;
|
||||
while (isalnum(volumelabel[++i]));
|
||||
if (volumelabel[i] != '\0') {
|
||||
errx(1, "bad volume label. Valid characters are alphanumerics.");
|
||||
}
|
||||
if (strlen(volumelabel) >= MAXVOLLEN) {
|
||||
errx(1, "bad volume label. Length is longer than %d.",
|
||||
MAXVOLLEN);
|
||||
}
|
||||
Lflag = 1;
|
||||
break;
|
||||
case 'N':
|
||||
Nflag = 1;
|
||||
break;
|
||||
@ -390,6 +405,7 @@ usage()
|
||||
getprogname(),
|
||||
" [device-type]");
|
||||
fprintf(stderr, "where fsoptions are:\n");
|
||||
fprintf(stderr, "\t-L volume label to add to superblock\n");
|
||||
fprintf(stderr,
|
||||
"\t-N do not create file system, just print out parameters\n");
|
||||
fprintf(stderr, "\t-O file system format: 1 => UFS1, 2 => UFS2\n");
|
||||
|
@ -49,6 +49,7 @@
|
||||
/*
|
||||
* variables set up by front end.
|
||||
*/
|
||||
extern int Lflag; /* add a volume label */
|
||||
extern int Nflag; /* run mkfs without writing file system */
|
||||
extern int Oflag; /* build UFS1 format file system */
|
||||
extern int Rflag; /* regression test */
|
||||
@ -68,5 +69,6 @@ extern int maxbpg; /* maximum blocks per file in a cyl group */
|
||||
extern int avgfilesize; /* expected average file size */
|
||||
extern int avgfilesperdir; /* expected number of files per directory */
|
||||
extern int fso; /* filedescriptor to device */
|
||||
extern u_char *volumelabel; /* volume label for filesystem */
|
||||
|
||||
void mkfs (struct partition *, char *);
|
||||
|
@ -41,6 +41,7 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl A
|
||||
.Op Fl L Ar volname
|
||||
.Op Fl a Cm enable | disable
|
||||
.Op Fl e Ar maxbpg
|
||||
.Op Fl f Ar avgfilesize
|
||||
@ -71,6 +72,8 @@ Specifying
|
||||
this option will cause all backups to be modified as well as the
|
||||
primary super-block.
|
||||
This is potentially dangerous - use with caution.
|
||||
.It Fl L Ar volname
|
||||
Add/modify an optional file system volume label.
|
||||
.It Fl a Cm enable | disable
|
||||
Turn on/off the administrative ACL enable flag.
|
||||
.It Fl e Ar maxbpg
|
||||
|
@ -57,6 +57,7 @@ static const char rcsid[] =
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstab.h>
|
||||
@ -81,26 +82,42 @@ main(int argc, char *argv[])
|
||||
{
|
||||
const char *special, *on;
|
||||
const char *name;
|
||||
int Aflag = 0, active = 0, aflag = 0;
|
||||
int Aflag = 0, Lflag = 0, active = 0, aflag = 0;
|
||||
int eflag = 0, fflag = 0, lflag = 0, mflag = 0;
|
||||
int nflag = 0, oflag = 0, pflag = 0, sflag = 0;
|
||||
int evalue = 0, fvalue = 0;
|
||||
int mvalue = 0, ovalue = 0, svalue = 0;
|
||||
char *avalue = NULL, *lvalue = NULL, *nvalue = NULL;
|
||||
char *Lvalue = NULL, *avalue = NULL, *lvalue = NULL, *nvalue = NULL;
|
||||
const char *chg[2];
|
||||
struct ufs_args args;
|
||||
struct statfs stfs;
|
||||
int found_arg, ch;
|
||||
int found_arg, ch, i;
|
||||
|
||||
if (argc < 3)
|
||||
usage();
|
||||
found_arg = 0; /* at least one arg is required */
|
||||
while ((ch = getopt(argc, argv, "Aa:e:f:l:m:n:o:ps:")) != -1)
|
||||
while ((ch = getopt(argc, argv, "AL:a:e:f:l:m:n:o:ps:")) != -1)
|
||||
switch (ch) {
|
||||
case 'A':
|
||||
found_arg = 1;
|
||||
Aflag++;
|
||||
break;
|
||||
case 'L':
|
||||
found_arg = 1;
|
||||
name = "volume label";
|
||||
Lvalue = optarg;
|
||||
i = -1;
|
||||
while (isalnum(Lvalue[++i]));
|
||||
if (Lvalue[i] != '\0') {
|
||||
errx(10, "bad %s. Valid characters are alphanumerics.",
|
||||
name);
|
||||
}
|
||||
if (strlen(Lvalue) >= MAXVOLLEN) {
|
||||
errx(10, "bad %s. Length is longer than %d.",
|
||||
name, MAXVOLLEN - 1);
|
||||
}
|
||||
Lflag = 1;
|
||||
break;
|
||||
case 'a':
|
||||
found_arg = 1;
|
||||
name = "ACLs";
|
||||
@ -204,6 +221,10 @@ main(int argc, char *argv[])
|
||||
printfs();
|
||||
exit(0);
|
||||
}
|
||||
if (Lflag) {
|
||||
name = "volume label";
|
||||
strlcpy(sblock.fs_volname, Lvalue, MAXVOLLEN);
|
||||
}
|
||||
if (aflag) {
|
||||
name = "ACLs";
|
||||
if (strcmp(avalue, "enable") == 0) {
|
||||
@ -354,10 +375,11 @@ main(int argc, char *argv[])
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "%s\n%s\n%s\n",
|
||||
"usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]",
|
||||
" [-l enable | disable] [-m minfree] [-n enable | disable]",
|
||||
" [-o space | time] [-p] [-s avgfpdir] special | filesystem");
|
||||
fprintf(stderr, "%s\n%s\n%s\n%s\n",
|
||||
"usage: tunefs [-A] [-L volname] [-a enable | disable] [-e maxbpg]",
|
||||
" [-f avgfilesize] [-l enable | disable] [-m minfree]",
|
||||
" [-n enable | disable] [-o space | time] [-p]",
|
||||
" [-s avgfpdir] special | filesystem");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@ -386,4 +408,6 @@ printfs(void)
|
||||
if (sblock.fs_minfree < MINFREE &&
|
||||
sblock.fs_optim == FS_OPTTIME)
|
||||
warnx(OPTWARN, "space", "<", MINFREE);
|
||||
warnx("volume label: (-L) %s",
|
||||
sblock.fs_volname);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user