[Midnightbsd-cvs] src [11214] trunk/sbin/growfs: sync growfs with freebsd
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Jul 1 16:48:40 EDT 2018
Revision: 11214
http://svnweb.midnightbsd.org/src/?rev=11214
Author: laffer1
Date: 2018-07-01 16:48:40 -0400 (Sun, 01 Jul 2018)
Log Message:
-----------
sync growfs with freebsd
Modified Paths:
--------------
trunk/sbin/growfs/Makefile
trunk/sbin/growfs/debug.c
trunk/sbin/growfs/debug.h
trunk/sbin/growfs/growfs.8
trunk/sbin/growfs/growfs.c
Added Paths:
-----------
trunk/sbin/growfs/tests/
trunk/sbin/growfs/tests/Makefile
trunk/sbin/growfs/tests/legacy_test.pl
Property Changed:
----------------
trunk/sbin/growfs/growfs.8
Modified: trunk/sbin/growfs/Makefile
===================================================================
--- trunk/sbin/growfs/Makefile 2018-07-01 20:47:52 UTC (rev 11213)
+++ trunk/sbin/growfs/Makefile 2018-07-01 20:48:40 UTC (rev 11214)
@@ -1,10 +1,11 @@
+# $MidnightBSD$
# @(#)Makefile 8.8 (Berkeley) 6/21/2000
#
# $TSHeader: src/sbin/growfs/Makefile,v 1.4 2000/12/05 19:45:24 tomsoft Exp $
-# $MidnightBSD$
+# $FreeBSD: stable/10/sbin/growfs/Makefile 284669 2015-06-21 06:49:44Z trasz $
#
-#GFSDBG=
+.include <bsd.own.mk>
.PATH: ${.CURDIR}/../mount
@@ -14,10 +15,16 @@
CFLAGS+=-I${.CURDIR}/../mount
.if defined(GFSDBG)
-SRCS+= debug.c
+SRCS+= debug.c
+CFLAGS+= -DFS_DEBUG
+NO_WCAST_ALIGN= yes
.endif
DPADD= ${LIBUTIL}
LDADD= -lutil
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.prog.mk>
Modified: trunk/sbin/growfs/debug.c
===================================================================
--- trunk/sbin/growfs/debug.c 2018-07-01 20:47:52 UTC (rev 11213)
+++ trunk/sbin/growfs/debug.c 2018-07-01 20:48:40 UTC (rev 11214)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz
* Copyright (c) 1980, 1989, 1993 The Regents of the University of California.
@@ -41,7 +42,7 @@
#ifndef lint
static const char rcsid[] =
- "$MidnightBSD$";
+ "$FreeBSD: stable/10/sbin/growfs/debug.c 259223 2013-12-11 19:25:17Z pfg $";
#endif /* not lint */
#include <sys/param.h>
@@ -765,7 +766,7 @@
fprintf(dbg_log, "gen int32_t 0x%08x\n", ino->di_gen);
fprintf(dbg_log, "kernflags u_int32_t 0x%08x\n", ino->di_kernflags);
fprintf(dbg_log, "flags u_int32_t 0x%08x\n", ino->di_flags);
- fprintf(dbg_log, "extsize int32_t 0x%08x\n", ino->di_extsize);
+ fprintf(dbg_log, "extsize u_int32_t 0x%08x\n", ino->di_extsize);
/* XXX: What do we do with di_extb[NXADDR]? */
Modified: trunk/sbin/growfs/debug.h
===================================================================
--- trunk/sbin/growfs/debug.h 2018-07-01 20:47:52 UTC (rev 11213)
+++ trunk/sbin/growfs/debug.h 2018-07-01 20:48:40 UTC (rev 11214)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz
* Copyright (c) 1980, 1989, 1993 The Regents of the University of California.
@@ -36,7 +37,7 @@
* SUCH DAMAGE.
*
* $TSHeader: src/sbin/growfs/debug.h,v 1.2 2000/11/16 18:43:50 tom Exp $
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sbin/growfs/debug.h 131720 2004-07-06 17:48:34Z stefanf $
*
*/
Modified: trunk/sbin/growfs/growfs.8
===================================================================
--- trunk/sbin/growfs/growfs.8 2018-07-01 20:47:52 UTC (rev 11213)
+++ trunk/sbin/growfs/growfs.8 2018-07-01 20:48:40 UTC (rev 11214)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz
.\" Copyright (c) 1980, 1989, 1993 The Regents of the University of California.
.\" All rights reserved.
@@ -35,9 +36,9 @@
.\" SUCH DAMAGE.
.\"
.\" $TSHeader: src/sbin/growfs/growfs.8,v 1.3 2000/12/12 19:31:00 tomsoft Exp $
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/growfs/growfs.8 307403 2016-10-16 22:02:50Z sevan $
.\"
-.Dd April 30, 2012
+.Dd November 20, 2014
.Dt GROWFS 8
.Os
.Sh NAME
@@ -96,12 +97,14 @@
will enlarge the file system to the size of the entire partition).
.El
.Sh EXAMPLES
-.Dl growfs -s 2G /dev/ada0p1
+Expand root file system to fill up available space:
+.Dl growfs /
.Pp
-will enlarge
+Resize
.Pa /dev/ada0p1
-up to 2GB if there is enough space in
-.Pa /dev/ada0p1 .
+partition to 2GB and expand the file system:
+.Dl gpart resize -i 1 -s 2G ada0
+.Dl growfs -s 2G /dev/ada0p1
.Sh SEE ALSO
.Xr dumpfs 8 ,
.Xr ffsinfo 8 ,
@@ -115,19 +118,17 @@
.Nm
utility first appeared in
.Fx 4.4 .
-The ability to resize mounted filesystems was added in
+The ability to resize mounted file systems was added in
.Fx 10.0 .
.Sh AUTHORS
-.An Christoph Herrmann Aq chm at FreeBSD.org
-.An Thomas-Henning von Kamptz Aq tomsoft at FreeBSD.org
-.An The GROWFS team Aq growfs at Tomsoft.COM
-.An Edward Tomasz Napierala Aq trasz at FreeBSD.org
+.An Christoph Herrmann Aq Mt chm at FreeBSD.org
+.An Thomas-Henning von Kamptz Aq Mt tomsoft at FreeBSD.org
+.An The GROWFS team Aq Mt growfs at Tomsoft.COM
+.An Edward Tomasz Napierala Aq Mt trasz at FreeBSD.org
.Sh CAVEATS
-.Pp
When expanding a file system mounted read-write, any writes to that file system
will be temporarily suspended until the expansion is finished.
.Sh BUGS
-.Pp
Normally
.Nm
writes cylinder group summary to disk and reads it again later for doing more
Property changes on: trunk/sbin/growfs/growfs.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/growfs/growfs.c
===================================================================
--- trunk/sbin/growfs/growfs.c 2018-07-01 20:47:52 UTC (rev 11213)
+++ trunk/sbin/growfs/growfs.c 2018-07-01 20:48:40 UTC (rev 11214)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1980, 1989, 1993 The Regents of the University of California.
* Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz
@@ -51,7 +52,7 @@
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/growfs/growfs.c 284669 2015-06-21 06:49:44Z trasz $");
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -141,14 +142,9 @@
uint cylno;
int i, j, width;
char tmpbuf[100];
- static int randinit = 0;
DBG_ENTER;
- if (!randinit) {
- randinit = 1;
- srandomdev();
- }
time(&modtime);
/*
@@ -166,7 +162,7 @@
#ifdef FS_DEBUG
{
struct csum *dbg_csp;
- int dbg_csc;
+ u_int32_t dbg_csc;
char dbg_line[80];
dbg_csp = fscs;
@@ -206,7 +202,7 @@
* Now build the cylinders group blocks and
* then print out indices of cylinder groups.
*/
- printf("super-block backups (for fsck -b #) at:\n");
+ printf("super-block backups (for fsck_ffs -b #) at:\n");
i = 0;
width = charsperline();
@@ -247,7 +243,7 @@
#ifdef FS_DEBUG
{
struct csum *dbg_csp;
- int dbg_csc;
+ u_int32_t dbg_csc;
char dbg_line[80];
dbg_csp = fscs;
@@ -325,6 +321,7 @@
DBG_FUNC("initcg")
static caddr_t iobuf;
long blkno, start;
+ ino_t ino;
ufs2_daddr_t i, cbase, dmax;
struct ufs1_dinode *dp1;
struct csum *cs;
@@ -393,8 +390,8 @@
}
acg.cg_cs.cs_nifree += sblock.fs_ipg;
if (cylno == 0)
- for (i = 0; i < ROOTINO; i++) {
- setbit(cg_inosused(&acg), i);
+ for (ino = 0; ino < ROOTINO; ino++) {
+ setbit(cg_inosused(&acg), ino);
acg.cg_cs.cs_nifree--;
}
/*
@@ -406,7 +403,7 @@
i += sblock.fs_frag) {
dp1 = (struct ufs1_dinode *)(void *)iobuf;
for (j = 0; j < INOPB(&sblock); j++) {
- dp1->di_gen = random();
+ dp1->di_gen = arc4random();
dp1++;
}
wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
@@ -1548,7 +1545,7 @@
printf(" from %s to %s? [Yes/No] ", oldsizebuf, newsizebuf);
fflush(stdout);
fgets(reply, (int)sizeof(reply), stdin);
- if (strcmp(reply, "Yes\n")){
+ if (strcasecmp(reply, "Yes\n")){
printf("\nNothing done\n");
exit (0);
}
Added: trunk/sbin/growfs/tests/Makefile
===================================================================
--- trunk/sbin/growfs/tests/Makefile (rev 0)
+++ trunk/sbin/growfs/tests/Makefile 2018-07-01 20:48:40 UTC (rev 11214)
@@ -0,0 +1,6 @@
+# $MidnightBSD$
+# $FreeBSD: stable/10/sbin/growfs/tests/Makefile 313488 2017-02-09 22:49:48Z ngie $
+
+TAP_TESTS_PERL= legacy_test
+
+.include <bsd.test.mk>
Property changes on: trunk/sbin/growfs/tests/Makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sbin/growfs/tests/legacy_test.pl
===================================================================
--- trunk/sbin/growfs/tests/legacy_test.pl (rev 0)
+++ trunk/sbin/growfs/tests/legacy_test.pl 2018-07-01 20:48:40 UTC (rev 11214)
@@ -0,0 +1,102 @@
+# $MidnightBSD$
+# $FreeBSD: stable/10/sbin/growfs/tests/legacy_test.pl 324690 2017-10-17 15:49:36Z ngie $
+
+use strict;
+use warnings;
+use POSIX;
+use Test::More tests => 19;
+use Fcntl qw(:DEFAULT :seek);
+
+use constant BLK => 512;
+use constant BLKS_PER_MB => 2048;
+
+my $unit;
+END { system "mdconfig -du$unit" if defined $unit };
+
+sub fsck_md {
+ my ($is_clean, $md);
+
+ $md = shift;
+
+ chomp(my @fsck_output = `fsck_ffs -Ffy ${md}a`);
+ $is_clean = WIFEXITED($?) &&
+ (WEXITSTATUS($?) == 0 || WEXITSTATUS($?) == 7);
+ ok($is_clean, "checking ${md}a's filesystem");
+ if ($is_clean) {
+ diag "filesystem reported clean";
+ } else {
+ diag "filesystem not reported clean: " . join("\n", @fsck_output);
+ }
+}
+
+sub setsize {
+ my ($partszMB, $unitszMB) = @_;
+
+ open my $fd, "|-", "disklabel -R md$unit /dev/stdin" or die;
+ print $fd "a: ", ($partszMB * BLKS_PER_MB), " 0 4.2BSD 1024 8192\n";
+ print $fd "c: ", ($unitszMB * BLKS_PER_MB), " 0 unused 0 0\n";
+ close $fd;
+}
+
+sub fill {
+ my ($start, $size, $content) = @_;
+
+ my $content512 = $content x (int(512 / length $content) + 1);
+ substr($content512, 512) = "";
+ sysopen my $fd, "/dev/md$unit", O_RDWR or die "/dev/md$unit: $!";
+ seek($fd, $start * BLK, SEEK_SET);
+ while ($size) {
+ syswrite($fd, $content512) == 512 or die "write: $!";
+ $size--;
+ }
+}
+
+SKIP: {
+ skip "Cannot test without UID 0", 19 if $<;
+
+ chomp(my $md = `mdconfig -s40m`);
+ like($md, qr/^md\d+$/, "Created $md with size 40m") or die;
+ $unit = substr $md, 2;
+
+ for my $type (1..2) {
+
+ initialise: {
+ ok(setsize(10, 40), "Sized ${md}a to 10m");
+ system "newfs -O $type -U ${md}a >/dev/null";
+ is($?, 0, "Initialised the filesystem on ${md}a as UFS$type");
+
+ fsck_md($md);
+ }
+
+ extend20_zeroed: {
+ ok(setsize(20, 40), "Sized ${md}a to 20m");
+ diag "Filling the extent with zeros";
+ fill(10 * BLKS_PER_MB, 10 * BLKS_PER_MB, chr(0));
+ my $out = `growfs -y ${md}a`;
+ is($?, 0, "Extended the filesystem on ${md}a") or print $out;
+
+ my ($unallocated) = $out =~ m{\d+ sectors cannot be allocated};
+ fill(30 * BLKS_PER_MB - $unallocated, $unallocated, chr(0))
+ if $unallocated;
+
+ fsck_md($md);
+ }
+
+ extend30_garbaged: {
+ ok(setsize(30, 40), "Sized ${md}a to 30m");
+ diag "Filling the extent with garbage";
+ fill(20 * BLKS_PER_MB, 10 * BLKS_PER_MB, chr(0xaa) . chr(0x55));
+ my $out = `growfs -y ${md}a`;
+ is($?, 0, "Extended the filesystem on ${md}a") or print $out;
+
+ my ($unallocated) = $out =~ m{\d+ sectors cannot be allocated};
+ fill(30 * BLKS_PER_MB - $unallocated, $unallocated, chr(0))
+ if $unallocated;
+
+ fsck_md($md);
+ }
+ }
+
+ system "mdconfig -du$unit";
+ undef $unit;
+}
Property changes on: trunk/sbin/growfs/tests/legacy_test.pl
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
More information about the Midnightbsd-cvs
mailing list