diff -rudpN src/sbin/tunefs.orig/tunefs.8 src/sbin/tunefs/tunefs.8 --- src/sbin/tunefs.orig/tunefs.8 2015-08-31 16:12:07.264970000 +0300 +++ src/sbin/tunefs/tunefs.8 2016-05-27 14:15:54.658161000 +0300 @@ -40,6 +40,7 @@ .Op Fl a Cm enable | disable .Op Fl e Ar maxbpg .Op Fl f Ar avgfilesize +.Op Fl G .Op Fl j Cm enable | disable .Op Fl J Cm enable | disable .Op Fl k Ar held-for-metadata-blocks @@ -93,6 +94,8 @@ For file systems with exclusively large this parameter should be set higher. .It Fl f Ar avgfilesize Specify the expected average file size. +.It Fl G +Generating a new unique filesystem id (/dev/ufsid/...). .It Fl j Cm enable | disable Turn on/off soft updates journaling. .It Fl J Cm enable | disable diff -rudpN src/sbin/tunefs.orig/tunefs.c src/sbin/tunefs/tunefs.c --- src/sbin/tunefs.orig/tunefs.c 2015-08-31 16:12:07.263782000 +0300 +++ src/sbin/tunefs/tunefs.c 2016-05-27 14:15:54.658163000 +0300 @@ -91,21 +91,24 @@ main(int argc, char *argv[]) int active; int Aflag, aflag, eflag, evalue, fflag, fvalue, jflag, Jflag, kflag; int kvalue, Lflag, lflag, mflag, mvalue, Nflag, nflag, oflag, ovalue; - int pflag, sflag, svalue, Svalue, tflag; + int pflag, sflag, svalue, Svalue, tflag, Gflag; int ch, found_arg, i; const char *chg[2]; struct ufs_args args; struct statfs stfs; + int32_t old_fs_id[2]; + time_t utime; if (argc < 3) usage(); Aflag = aflag = eflag = fflag = jflag = Jflag = kflag = Lflag = 0; lflag = mflag = Nflag = nflag = oflag = pflag = sflag = tflag = 0; + Gflag = 0; avalue = jvalue = Jvalue = Lvalue = lvalue = Nvalue = nvalue = NULL; evalue = fvalue = mvalue = ovalue = svalue = Svalue = 0; active = 0; found_arg = 0; /* At least one arg is required. */ - while ((ch = getopt(argc, argv, "Aa:e:f:j:J:k:L:l:m:N:n:o:ps:S:t:")) + while ((ch = getopt(argc, argv, "Aa:e:f:j:J:k:L:l:m:N:n:o:ps:S:t:G")) != -1) switch (ch) { @@ -292,6 +295,11 @@ main(int argc, char *argv[]) tflag = 1; break; + case 'G': + found_arg = 1; + Gflag++; + break; + default: usage(); } @@ -551,6 +559,15 @@ main(int argc, char *argv[]) } } } + if (Gflag) { + name = "ufsid"; + time(&utime); + old_fs_id[0] = sblock.fs_id[0]; + old_fs_id[1] = sblock.fs_id[1]; + sblock.fs_id[0] = (long)utime; + sblock.fs_id[1] = arc4random(); + warnx("%s changed from %08x%08x to new value %08x%08x", name, old_fs_id[0], old_fs_id[1], sblock.fs_id[0], sblock.fs_id[1]); + } if (sbwrite(&disk, Aflag) == -1) goto err; @@ -1086,7 +1103,7 @@ static void usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n", -"usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]", +"usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize] [-G]", " [-J enable | disable] [-j enable | disable] [-k metaspace]", " [-L volname] [-l enable | disable] [-m minfree]", " [-N enable | disable] [-n enable | disable]", @@ -1132,4 +1149,6 @@ printfs(void) warnx(OPTWARN, "space", "<", MINFREE); warnx("volume label: (-L) %s", sblock.fs_volname); + warnx("unique filesystem id: (-G) %08x%08x", + sblock.fs_id[0],sblock.fs_id[1]); }