summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgordon <gordon@FreeBSD.org>2003-02-01 04:17:10 +0000
committergordon <gordon@FreeBSD.org>2003-02-01 04:17:10 +0000
commitf340c1ac9e703e24d41cc4afe89b152b2cf7ebfa (patch)
tree2d33c52f2fec2a53d09438d913937daf82c605e6
parenta7fd524f8e3d3856a304114d97f9450fc2645b58 (diff)
downloadFreeBSD-src-f340c1ac9e703e24d41cc4afe89b152b2cf7ebfa.zip
FreeBSD-src-f340c1ac9e703e24d41cc4afe89b152b2cf7ebfa.tar.gz
Bring in support for volume labels to the filesystem utilities.
Reviewed by: mckusick
-rw-r--r--sbin/dumpfs/dumpfs.c3
-rw-r--r--sbin/newfs/mkfs.c2
-rw-r--r--sbin/newfs/newfs.83
-rw-r--r--sbin/newfs/newfs.c20
-rw-r--r--sbin/newfs/newfs.h2
-rw-r--r--sbin/tunefs/tunefs.83
-rw-r--r--sbin/tunefs/tunefs.c40
7 files changed, 63 insertions, 10 deletions
diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c
index 71b05e9..19f8795 100644
--- a/sbin/dumpfs/dumpfs.c
+++ b/sbin/dumpfs/dumpfs.c
@@ -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)
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index 4b78f9b..de8140f 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -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.
diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8
index da0ff2a..7f10c72 100644
--- a/sbin/newfs/newfs.8
+++ b/sbin/newfs/newfs.8
@@ -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.
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index 50034a2..75832b3 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -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");
diff --git a/sbin/newfs/newfs.h b/sbin/newfs/newfs.h
index fb32a62..60347f3 100644
--- a/sbin/newfs/newfs.h
+++ b/sbin/newfs/newfs.h
@@ -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 *);
diff --git a/sbin/tunefs/tunefs.8 b/sbin/tunefs/tunefs.8
index b8c8a1d..1a4ab8c 100644
--- a/sbin/tunefs/tunefs.8
+++ b/sbin/tunefs/tunefs.8
@@ -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
diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c
index ec1589e..a861248 100644
--- a/sbin/tunefs/tunefs.c
+++ b/sbin/tunefs/tunefs.c
@@ -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 @@ err:
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);
}
OpenPOWER on IntegriCloud