From owner-svn-src-stable@FreeBSD.ORG Sat Jul 6 08:43:10 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 85E404C0; Sat, 6 Jul 2013 08:43:10 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 77C5F1DF4; Sat, 6 Jul 2013 08:43:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r668hAEg088082; Sat, 6 Jul 2013 08:43:10 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r668h9qe088077; Sat, 6 Jul 2013 08:43:09 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201307060843.r668h9qe088077@svn.freebsd.org> From: Xin LI Date: Sat, 6 Jul 2013 08:43:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252871 - stable/9/sbin/swapon X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jul 2013 08:43:10 -0000 Author: delphij Date: Sat Jul 6 08:43:09 2013 New Revision: 252871 URL: http://svnweb.freebsd.org/changeset/base/252871 Log: MFC r226712 (sobomax): Add new option -F to specify alternative location of the /etc/fstab file. MFC r226742 (ed): Build swapon with WARNS=6. Don't use a variable called stat, because it collides with stat(2). Modified: stable/9/sbin/swapon/Makefile stable/9/sbin/swapon/swapon.8 stable/9/sbin/swapon/swapon.c Directory Properties: stable/9/sbin/swapon/ (props changed) Modified: stable/9/sbin/swapon/Makefile ============================================================================== --- stable/9/sbin/swapon/Makefile Sat Jul 6 08:37:43 2013 (r252870) +++ stable/9/sbin/swapon/Makefile Sat Jul 6 08:43:09 2013 (r252871) @@ -8,7 +8,6 @@ LINKS+= ${BINDIR}/swapon ${BINDIR}/swapc MLINKS= swapon.8 swapoff.8 MLINKS+=swapon.8 swapctl.8 -WARNS?= 3 DPADD= ${LIBUTIL} LDADD= -lutil Modified: stable/9/sbin/swapon/swapon.8 ============================================================================== --- stable/9/sbin/swapon/swapon.8 Sat Jul 6 08:37:43 2013 (r252870) +++ stable/9/sbin/swapon/swapon.8 Sat Jul 6 08:43:09 2013 (r252871) @@ -35,8 +35,14 @@ .Nm swapon , swapoff , swapctl .Nd "specify devices for paging and swapping" .Sh SYNOPSIS -.Nm swapon Fl aq | Ar -.Nm swapoff Fl aq | Ar +.Nm swapon +.Oo Fl F Ar fstab +.Oc +.Fl aq | Ar +.Nm swapoff +.Oo Fl F Ar fstab +.Oc +.Fl aq | Ar .Nm swapctl .Op Fl AghklmsU .Oo @@ -99,6 +105,18 @@ must move swapped pages out of the devic lead to high system loads for a period of time, depending on how much data has been swapped out to that device. .Pp +Other options supported by both +.Nm swapon +and +.Nm swapoff +are as follows: +.Bl -tag -width indent +.It Fl F Ar fstab +Specify the +.Pa fstab +file to use. +.El +.Pp The .Nm swapctl utility exists primarily for those familiar with other Modified: stable/9/sbin/swapon/swapon.c ============================================================================== --- stable/9/sbin/swapon/swapon.c Sat Jul 6 08:37:43 2013 (r252870) +++ stable/9/sbin/swapon/swapon.c Sat Jul 6 08:43:09 2013 (r252871) @@ -67,9 +67,10 @@ main(int argc, char **argv) { struct fstab *fsp; char *ptr; - int stat; + int ret; int ch, doall; int sflag = 0, lflag = 0, hflag = 0, qflag = 0; + const char *etc_fstab; if ((ptr = strrchr(argv[0], '/')) == NULL) ptr = argv[0]; @@ -80,7 +81,8 @@ main(int argc, char **argv) orig_prog = which_prog; doall = 0; - while ((ch = getopt(argc, argv, "AadghklmqsU")) != -1) { + etc_fstab = NULL; + while ((ch = getopt(argc, argv, "AadghklmqsUF:")) != -1) { switch(ch) { case 'A': if (which_prog == SWAPCTL) { @@ -132,6 +134,9 @@ main(int argc, char **argv) usage(); } break; + case 'F': + etc_fstab = optarg; + break; case '?': default: usage(); @@ -139,7 +144,9 @@ main(int argc, char **argv) } argv += optind; - stat = 0; + ret = 0; + if (etc_fstab != NULL) + setfstab(etc_fstab); if (which_prog == SWAPON || which_prog == SWAPOFF) { if (doall) { while ((fsp = getfsent()) != NULL) { @@ -148,7 +155,7 @@ main(int argc, char **argv) if (strstr(fsp->fs_mntops, "noauto")) continue; if (swap_on_off(fsp->fs_spec, 1)) { - stat = 1; + ret = 1; } else { if (!qflag) { printf("%s: %sing %s as swap device\n", @@ -163,7 +170,7 @@ main(int argc, char **argv) usage(); for (; *argv; ++argv) { if (swap_on_off(*argv, 0)) { - stat = 1; + ret = 1; } else if (orig_prog == SWAPCTL) { printf("%s: %sing %s as swap device\n", getprogname(), which_prog == SWAPOFF ? "remov" : "add", @@ -176,7 +183,7 @@ main(int argc, char **argv) else usage(); } - exit(stat); + exit(ret); } static int @@ -210,7 +217,7 @@ usage(void) switch(orig_prog) { case SWAPON: case SWAPOFF: - fprintf(stderr, "-aq | file ...\n"); + fprintf(stderr, "[-F fstab] -aq | file ...\n"); break; case SWAPCTL: fprintf(stderr, "[-AghklmsU] [-a file ... | -d file ...]\n");