aboutsummaryrefslogtreecommitdiff
path: root/sbin/tunefs
diff options
context:
space:
mode:
authorGordon Tetlow <gordon@FreeBSD.org>2003-02-01 04:17:10 +0000
committerGordon Tetlow <gordon@FreeBSD.org>2003-02-01 04:17:10 +0000
commitc715b047bc0c670704a8a7f0369dcd4d38ab50ff (patch)
tree2d33c52f2fec2a53d09438d913937daf82c605e6 /sbin/tunefs
parent03b6e025513b9f1cbf8ceac4c32cbda45ed63caf (diff)
downloadsrc-c715b047bc0c670704a8a7f0369dcd4d38ab50ff.tar.gz
src-c715b047bc0c670704a8a7f0369dcd4d38ab50ff.zip
Bring in support for volume labels to the filesystem utilities.
Reviewed by: mckusick
Notes
Notes: svn path=/head/; revision=110174
Diffstat (limited to 'sbin/tunefs')
-rw-r--r--sbin/tunefs/tunefs.83
-rw-r--r--sbin/tunefs/tunefs.c40
2 files changed, 35 insertions, 8 deletions
diff --git a/sbin/tunefs/tunefs.8 b/sbin/tunefs/tunefs.8
index b8c8a1dd1583..1a4ab8ca6f3a 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 ec1589e1b7fe..a861248929a0 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);
}