From 22853e4a82c6ef7b336527529acb94b14a0b0fd8 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 7 Dec 2006 00:25:43 +0100 Subject: [PATCH] Imported from util-linux-2.10m tarball. --- HISTORY | 59 + MCONFIG | 3 +- Makefile | 1 + VERSION | 2 +- attic/pidof.c | 95 - attic/strings.1 | 96 - attic/strings.c | 212 - clock/Makefile | 5 + clock/clock.h | 1 + clock/cmos.c | 15 +- clock/hwclock.8 | 60 +- clock/hwclock.c | 82 +- clock/kd.c | 3 + clock/shhopt.c | 2 +- configure | 107 + disk-utils/Makefile | 12 +- disk-utils/blockdev.c | 17 +- disk-utils/elvtune.8 | 73 + disk-utils/elvtune.c | 143 + disk-utils/fdformat.c | 5 +- disk-utils/fsck.minix.8 | 4 +- disk-utils/fsck.minix.c | 171 +- disk-utils/minix.h | 60 + disk-utils/mkfs.bfs.c | 5 +- disk-utils/mkfs.minix.c | 108 +- disk-utils/mkswap.8 | 13 +- disk-utils/mkswap.c | 133 +- disk-utils/raw.8 | 8 +- disk-utils/raw.c | 28 +- fdisk/Makefile | 8 +- fdisk/cfdisk.c | 254 +- fdisk/common.h | 7 + fdisk/fdisk.8 | 17 +- fdisk/fdisk.c | 1074 +-- fdisk/fdisk.h | 19 +- fdisk/fdiskaixlabel.c | 7 +- fdisk/fdiskaixlabel.h | 4 +- fdisk/fdiskbsdlabel.c | 337 +- fdisk/fdiskbsdlabel.h | 8 +- fdisk/fdisksgilabel.c | 220 +- fdisk/fdisksgilabel.h | 6 +- fdisk/fdisksunlabel.c | 82 +- fdisk/fdisksunlabel.h | 7 +- fdisk/i386_sys_types.c | 2 + fdisk/llseek.c | 2 +- fdisk/partname.c | 46 + fdisk/sfdisk.8 | 15 +- fdisk/sfdisk.c | 349 +- games/banner.c | 5 +- kbd/kbdrate.c | 4 +- login-utils/Makefile | 13 +- login-utils/agetty.c | 26 +- login-utils/chfn.c | 12 +- login-utils/chsh.c | 1 - login-utils/login.c | 53 +- login-utils/need.8 | 85 + login-utils/need.c | 160 + login-utils/shutdown.8 | 8 +- login-utils/shutdown.c | 14 +- login-utils/simpleinit.8 | 72 +- login-utils/simpleinit.c | 673 +- login-utils/simpleinit.h | 25 + misc-utils/cal.c | 7 +- misc-utils/ddate.c | 36 +- misc-utils/kill.c | 1 + misc-utils/kill.h | 1 + misc-utils/logger.c | 23 +- misc-utils/md5.h | 2 +- misc-utils/namei.c | 42 +- misc-utils/procs.c | 9 +- misc-utils/rename.c | 4 +- misc-utils/script.c | 48 +- misc-utils/setterm.1 | 229 +- misc-utils/setterm.c | 1606 ++-- misc-utils/tsort.c | 77 +- misc-utils/whereis.c | 5 +- misc-utils/write.c | 28 +- mount/Makefile | 56 +- mount/lomount.c | 553 +- mount/losetup.c | 237 - mount/mount.8 | 30 +- mount/mount.c | 436 +- mount/mount_by_label.c | 198 +- mount/mount_by_label.h | 1 + mount/mount_guess_fstype.c | 12 +- mount/nfs_mount4.h | 53 + mount/{nfs_mount3.h => nfs_mount4.h.sv} | 22 +- mount/nfsmount.c | 204 +- mount/nfsmount.h | 325 - mount/nfsmount.x | 78 + mount/nfsmount_clnt.c | 281 - mount/nfsmount_xdr.c | 334 - mount/pivot_root.2 | 97 + mount/pivot_root.8 | 65 + mount/pivot_root.c | 24 + mount/realpath.c | 21 +- mount/rpcsvc/nfsmount.h | 310 +- mount/rpcsvc/nfsmount.x | 78 + mount/rpcsvc/nfsmount_clnt.c | 230 +- mount/rpcsvc/nfsmount_xdr.c | 467 +- mount/swapon.8 | 10 +- partx/Makefile | 14 + {fdisk => partx}/addpart.c | 0 partx/bsd.c | 83 + {fdisk => partx}/delpart.c | 0 partx/dos.c | 106 + partx/partx.c | 395 + partx/partx.h | 26 + partx/solaris.c | 70 + partx/unixware.c | 83 + po/Makefile | 4 +- po/POTFILES.in | 3 - po/cat-id-tbl.c | 3449 ++++----- po/cs.po | 1994 ++--- po/de.po | 5023 +++++++------ po/es.po | 8947 +++++++++++++++++++++++ po/fr.po | 5334 ++++++++------ po/it.po | 6057 ++++++++------- po/pt_BR.po | 5633 +++++++------- rescuept/README | 2 +- rescuept/rescuept.c | 13 +- sys-utils/Makefile | 13 + sys-utils/cytune.c | 6 +- sys-utils/dmesg.c | 11 +- sys-utils/ipcrm.c | 113 +- sys-utils/ipcs.c | 21 +- sys-utils/rdev.c | 11 +- sys-utils/readprofile.c | 44 +- sys-utils/sln.c | 5 +- sys-utils/tunelp.c | 20 +- text-utils/col.1 | 14 +- text-utils/col.c | 17 +- text-utils/column.c | 4 +- text-utils/display.c | 15 +- text-utils/hexdump.c | 9 +- text-utils/hexdump.h | 2 +- text-utils/more.1 | 3 +- text-utils/more.c | 81 +- text-utils/odsyntax.c | 4 +- text-utils/parse.c | 4 +- text-utils/rev.c | 27 +- text-utils/ul.c | 18 +- 142 files changed, 31312 insertions(+), 17744 deletions(-) delete mode 100644 attic/pidof.c delete mode 100644 attic/strings.1 delete mode 100644 attic/strings.c create mode 100644 disk-utils/elvtune.8 create mode 100644 disk-utils/elvtune.c create mode 100644 disk-utils/minix.h create mode 100644 fdisk/partname.c create mode 100644 login-utils/need.8 create mode 100644 login-utils/need.c create mode 100644 login-utils/simpleinit.h create mode 100644 misc-utils/kill.h delete mode 100644 mount/losetup.c create mode 100644 mount/nfs_mount4.h rename mount/{nfs_mount3.h => nfs_mount4.h.sv} (77%) delete mode 100644 mount/nfsmount.h delete mode 100644 mount/nfsmount_clnt.c delete mode 100644 mount/nfsmount_xdr.c create mode 100644 mount/pivot_root.2 create mode 100644 mount/pivot_root.8 create mode 100644 mount/pivot_root.c create mode 100644 partx/Makefile rename {fdisk => partx}/addpart.c (100%) create mode 100644 partx/bsd.c rename {fdisk => partx}/delpart.c (100%) create mode 100644 partx/dos.c create mode 100644 partx/partx.c create mode 100644 partx/partx.h create mode 100644 partx/solaris.c create mode 100644 partx/unixware.c create mode 100644 po/es.po diff --git a/HISTORY b/HISTORY index e89cbf65..9c6099de 100644 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,62 @@ +util-linux 2.10m: + +* chfn fix when PAM is used (Martin-D. Lacasse) +* do not use LC_NUMERIC part of locale in hwclock when writing /etc/adjtime +* mount status return from smb or ncp fix (Mark Peloquin) +* mount new option -l: also print label when listing mounts +* mount add heuristic for xfs (Martin K. Petersen) +* mount UUID and label cache (Erik Troan) +* fdisk partition names more devfs-friendly +* fdisk bsdlabel large disk support +* setterm.1: options documented (Colin Watson) +* rename correction +* German, Spanish, French, Italian, Portuguese messages + (Roger Luethi, Beth Powell, Alvaro Antunes) + +util-linux 2.10l: + +* Merged losetup.c and lomount.c +* ANSIfied everything + +util-linux 2.10k: + +* NFS version 4 mount support (Trond Myklebust) +* hwclock fix (Stefan Ring) +* Added -p option to col, as required by SUS (Joseph S. Myers) + +util-linux 2.10j: + +* fdisk fixes (Michal Jaegermann) + +util-linux 2.10i: + +* new directory partx (with code to play with, not to use) +* minor fdisk changes + +util-linux 2.10h: + +* Added pivot_root (Werner Almesberger) +* Added elvtune (Andrea Arcangeli) +* Added need and extended simpleinit and shutdown (Richard Gooch) +* Removed all #include +* errno fixes (Joseph S. Myers) +* IA-64 fixes (Michael K. Johnson) +* fdisk fixes for OSF/1 on Alpha (David Huggins-Daines) +* fdisk sectorsize fix (Greg Hosler) +* mount speed= option to enable mounting bad CDROMs (Marco d'Itri) +* ipcrm deletes several things at once (Frank Zago) + +util-linux 2.10g: + +* fdisk can now sort partitions into order [untested, beware!] +* Update of mkswap for sparc64 (jj) +* Update of raw (Stephen Tweedie): + Control file was /dev/raw, now /dev/rawctl + Access files were /dev/raw*, now /dev/raw/raw* +* Czech messages (Jiri Pavlovsky) +* German messages (Daniel Egger) +* losetup locks memory (Frank v Waveren) + util-linux 2.10f: * Security fix for mount (okir) diff --git a/MCONFIG b/MCONFIG index 4afbfe0e..f1f0e3d0 100644 --- a/MCONFIG +++ b/MCONFIG @@ -87,6 +87,7 @@ ifeq "$(CC)" "" endif # Different optimizations for different cpus. +# Change the -m486 part if you have a 386. ifeq "$(CPU)" "intel" OPT= -pipe -O2 -m486 -fomit-frame-pointer else @@ -99,7 +100,7 @@ endif LDFLAGS = -s -WARNFLAGS = -Wall +WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes LIB=../lib diff --git a/Makefile b/Makefile index d9c653f4..b67fb3d4 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ clean: distclean: make_include clean cd po && make distclean + cd mount && make distclean -rm -f defines.h make_include # diff --git a/VERSION b/VERSION index 3a554622..d877938d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.10f +2.10m diff --git a/attic/pidof.c b/attic/pidof.c deleted file mode 100644 index 74709c78..00000000 --- a/attic/pidof.c +++ /dev/null @@ -1,95 +0,0 @@ -/* pid -- display the process id of a running command - - Copyright (c) 1994 Salvatore Valente - Copyright (c) 1996 Bruno Haible - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - - -#include -#include -#include - -extern int* get_pids (char*, int); - -char version_string[] = "pid 1.0"; -char* program_name; - -int usage (int status) -{ - FILE* fp = (status == 0 ? stdout : stderr); - fprintf(fp, "Usage: %s command ...\n", program_name); - return status; -} - -static int compar_int (const void* i1, const void* i2) -{ - return *((int *)i1) - *((int *)i2); -} - -int main (int argc, char *argv[]) -{ - int i; - int *pids, *pids0; - int num_allpids = 0; - int *allpids = (int*)0; - int allpids_size = 0; - - program_name = argv[0]; - - /* Argument processing. */ - for (i = 1; i < argc; i++) { - char* arg = argv[i]; - if (!strcmp(arg, "--help")) - return usage(0); - else if (!strcmp(arg, "--version")) { - printf("%s\n", version_string); - return 0; - } - } - - /* Gather the pids. */ - for (i = 1; i < argc; i++) { - char* arg = argv[i]; - pids0 = pids = get_pids(arg, 1); - if (pids) { - while (*pids >= 0) { - int pid = *pids++; - if (num_allpids >= allpids_size) { - allpids_size = 2*allpids_size+1; - allpids = (int*) realloc(allpids, sizeof(int)*allpids_size); - if (!allpids) { - fprintf(stderr, "%s: out of memory\n", program_name); - exit(1); - } - } - allpids[num_allpids++] = pid; - } - free(pids0); - } - } - - /* Sort them. */ - if (num_allpids > 1) - qsort(allpids, num_allpids, sizeof(int), compar_int); - - /* Print them. */ - for (pids = allpids, i = num_allpids; i > 0; pids++, i--) - printf("%d\n", *pids); - - return 0; -} diff --git a/attic/strings.1 b/attic/strings.1 deleted file mode 100644 index 08dda5bf..00000000 --- a/attic/strings.1 +++ /dev/null @@ -1,96 +0,0 @@ -.\" Copyright (c) 1980, 1990 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)strings.1 6.11 (Berkeley) 5/9/91 -.\" -.Dd May 9, 1991 -.Dt STRINGS 1 -.Os BSD 3 -.Sh NAME -.Nm strings -.Nd find printable strings in a file -.Sh SYNOPSIS -.Nm strings -.Op Fl afo -.Op Fl n Ar number -.Op Ar file ... -.Sh DESCRIPTION -.Nm Strings -displays the sequences of printable characters in each of the specified -files, or in the standard input, by default. -By default, a sequence must be at least four characters in length -before being displayed. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl a -By default, -.Nm strings -only searches the text and data segments of object files. -The -.Fl a -option causes -.Nm strings -to search the entire object file. -.It Fl f -Each string is preceded by the name of the file -in which it was found. -.It Fl n -Specifies the minimum number of characters in a sequence to be -.Ar number , -instead of four. -.It Fl o -Each string is preceded by its decimal offset in the -file. -.El -.Pp -.Nm Strings -is useful for identifying random binaries, among other things. -.Sh SEE ALSO -.Xr hexdump 1 -.Sh BUGS -The algorithm for identifying strings is extremely primitive. -In particular, machine code instructions on certain architectures -can resemble sequences of ASCII bytes, which -will fool the algorithm. -.Sh COMPATIBILITY -Historic implementations of -.Nm -only search the initialized data portion of the object file. -This was reasonable as strings were normally stored there. -Given new compiler technology which installs strings in the -text portion of the object file, the default behavior was -changed. -.Sh HISTORY -The -.Nm -command appeared in -.Bx 3.0 . diff --git a/attic/strings.c b/attic/strings.c deleted file mode 100644 index 6c201a74..00000000 --- a/attic/strings.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 1980, 1987 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * Wed Jun 22 22:22:37 1994, faith@cs.unc.edu: - * Added internationalization patches from Vitor Duarte - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEF_LEN 4 /* default minimum string length */ -#if 0 -#define ISSTR(ch) (isascii(ch) && (isprint(ch) || ch == '\t')) -#else -#define ISSTR(ch) (isprint(ch) || ch == '\t') -#endif - -typedef struct exec EXEC; /* struct exec cast */ - -static long foff; /* offset in the file */ -static int hcnt, /* head count */ - head_len, /* length of header */ - read_len; /* length to read */ -static u_char hbfr[sizeof(EXEC)]; /* buffer for struct exec */ - -static void usage(); - -main(argc, argv) - int argc; - char **argv; -{ - extern char *optarg; - extern int optind; - register int ch, cnt; - register u_char *C; - EXEC *head; - int exitcode, minlen; - short asdata, oflg, fflg; - u_char *bfr; - char *file, *p; - - setlocale(LC_CTYPE, ""); - - - /* - * for backward compatibility, allow '-' to specify 'a' flag; no - * longer documented in the man page or usage string. - */ - asdata = exitcode = fflg = oflg = 0; - minlen = -1; - while ((ch = getopt(argc, argv, "-0123456789an:of")) != EOF) - switch((char)ch) { - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - /* - * kludge: strings was originally designed to take - * a number after a dash. - */ - if (minlen == -1) { - p = argv[optind - 1]; - if (p[0] == '-' && p[1] == ch && !p[2]) - minlen = atoi(++p); - else - minlen = atoi(argv[optind] + 1); - } - break; - case '-': - case 'a': - asdata = 1; - break; - case 'f': - fflg = 1; - break; - case 'n': - minlen = atoi(optarg); - break; - case 'o': - oflg = 1; - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if (minlen == -1) - minlen = DEF_LEN; - - if (!(bfr = malloc((u_int)minlen))) { - (void)fprintf(stderr, "strings: %s\n", strerror(errno)); - exit(1); - } - bfr[minlen] = '\0'; - file = "stdin"; - do { - if (*argv) { - file = *argv++; - if (!freopen(file, "r", stdin)) { - (void)fprintf(stderr, - "strings; %s: %s\n", file, strerror(errno)); - exitcode = 1; - goto nextfile; - } - } - foff = 0; -#define DO_EVERYTHING() {read_len = -1; head_len = 0; goto start;} - read_len = -1; - if (asdata) - DO_EVERYTHING() - else { - head = (EXEC *)hbfr; - if ((head_len = - read(fileno(stdin), head, sizeof(EXEC))) == -1) - DO_EVERYTHING() - if (head_len == sizeof(EXEC) && !N_BADMAG(*head)) { - foff = N_TXTOFF(*head); - if (fseek(stdin, foff, SEEK_SET) == -1) - DO_EVERYTHING() - read_len = head->a_text + head->a_data; - head_len = 0; - } - else - hcnt = 0; - } -start: - for (cnt = 0; (ch = getch()) != EOF;) { - if (ISSTR(ch)) { - if (!cnt) - C = bfr; - *C++ = ch; - if (++cnt < minlen) - continue; - if (fflg) - printf("%s:", file); - if (oflg) - printf("%07ld %s", - foff - minlen, (char *)bfr); - else - printf("%s", bfr); - while ((ch = getch()) != EOF && ISSTR(ch)) - putchar((char)ch); - putchar('\n'); - } - cnt = 0; - } -nextfile: ; - } while (*argv); - exit(exitcode); -} - -/* - * getch -- - * get next character from wherever - */ -getch() -{ - ++foff; - if (head_len) { - if (hcnt < head_len) - return((int)hbfr[hcnt++]); - head_len = 0; - } - if (read_len == -1 || read_len-- > 0) - return(getchar()); - return(EOF); -} - -static void -usage() -{ - (void)fprintf(stderr, - "usage: strings [-afo] [-n length] [file ... ]\n"); - exit(1); -} diff --git a/clock/Makefile b/clock/Makefile index fd0522b3..10e96051 100644 --- a/clock/Makefile +++ b/clock/Makefile @@ -20,6 +20,11 @@ hwclock.o: hwclock.c shhopt.h hwclock.o cmos.o rtc.o kd.o: clock.h hwclock: hwclock.o shhopt.o cmos.o rtc.o kd.o +CWFLAGS := $(subst -Wmissing-prototypes,,$(CFLAGS)) + +cmos.o: cmos.c + $(CC) $(CWFLAGS) -c $< -o $@ + install: all $(INSTALLDIR) $(SBINDIR) $(BINDIR) $(USRBINDIR) $(INSTALLBIN) $(SBIN) $(SBINDIR) diff --git a/clock/clock.h b/clock/clock.h index b57b499c..fc91826c 100644 --- a/clock/clock.h +++ b/clock/clock.h @@ -22,6 +22,7 @@ typedef int bool; /* hwclock.c */ extern char *progname; extern int debug; +extern int epoch_option; extern void outsyserr(char *msg); /* cmos.c */ diff --git a/clock/cmos.c b/clock/cmos.c index 827ec54a..16705bf7 100644 --- a/clock/cmos.c +++ b/clock/cmos.c @@ -63,7 +63,7 @@ int inb(int c){ return 0; } #define TM_EPOCH 1900 int cmos_epoch = 1900; /* 1980 for an alpha in ARC console time */ - /* One also sees 1952 (Digital Unix?) + /* One also sees 1952 (Digital Unix) and 1958 (ALPHA_PRE_V1_2_SRM_CONSOLE) */ /* Martin Ostermann writes: @@ -125,6 +125,11 @@ set_cmos_epoch(int ARCconsole, int SRM) { unsigned long epoch; /* Believe the user */ + if (epoch_option != -1) { + cmos_epoch = epoch_option; + return; + } + if (ARCconsole) cmos_epoch = 1980; @@ -138,6 +143,12 @@ set_cmos_epoch(int ARCconsole, int SRM) { return; } + /* The kernel source today says: read the year. If it is + in 11-43 then the epoch is 1980 (this covers 1991-2023). + Otherwise, if it is less than 96 then the epoch is 1952 + (this covers 1952-1962 and 1996-2047). Otherwise, the epoch + is 1900 (this covers 1996-1999, or rather 1996-2155). */ + /* See whether we are dealing with SRM or MILO, as they have different "epoch" ideas. */ @@ -395,7 +406,7 @@ hclock_set_time(const struct tm *tm) { } static inline int -cmos_clock_busy() { +cmos_clock_busy(void) { return #ifdef __alpha__ /* poll bit 4 (UF) of Control Register C */ diff --git a/clock/hwclock.8 b/clock/hwclock.8 index ddf0c7c3..f34bfac0 100644 --- a/clock/hwclock.8 +++ b/clock/hwclock.8 @@ -1,30 +1,30 @@ -.TH CLOCK 8 "02 March 1998" +.TH HWCLOCK 8 "02 March 1998" .SH NAME -clock \- query and set the hardware clock (RTC) +hwclock \- query and set the hardware clock (RTC) .SH SYNOPSIS -.B "hwclock \-\-show" +.BR "hwclock \-r" " or " "hwclock \-\-show" .br -.B "hwclock \-\-set \-\-date=newdate" +.BR "hwclock \-w" " or " "hwclock \-\-systohc" .br -.B "hwclock \-\-systohc" +.BR "hwclock \-s" " or " "hwclock \-\-hctosys" .br -.B "hwclock \-\-hctosys" +.BR "hwclock \-a" " or " "hwclock \-\-adjust" .br -.B "hwclock \-\-getepoch" +.BR "hwclock \-v" " or " "hwclock \-\-version" .br -.B "hwclock \-\-setepoch \-\-epoch=year" +.B "hwclock \-\-set \-\-date=newdate" .br -.B "hwclock \-\-adjust" +.B "hwclock \-\-getepoch" .br -.B "hwclock \-\-version" +.B "hwclock \-\-setepoch \-\-epoch=year" .PP other options: .PP -.B "\-\-utc \-\-localtime \-\-directisa \-\-test \-\-debug" +.B "[\-u|\-\-utc] \-\-localtime \-\-directisa \-\-test \-\-debug" .PP and arcane options for DEC Alpha: .PP -.B "\-\-arc \-\-jensen \-\-srm \-\-funky-toy" +.B "[\-A|\-\-arc] [\-J|\-\-jensen] [\-S|\-\-srm] [\-F|\-\-funky-toy]" .PP Minimum unique abbreviations of all options are acceptable. .PP @@ -67,16 +67,15 @@ option. .B \-\-hctosys Set the System Time from the Hardware Clock. -Also set the kernel's timezone value to the local timezone as indicated by -the TZ environment variable and/or +Also set the kernel's timezone value to the local timezone +as indicated by the TZ environment variable and/or .IR /usr/lib/zoneinfo , as .BR tzset (3) -would interpret them. EXCEPT: always set the Daylight Savings Time part of -the kernel's timezone value to 0 ("not Daylight Savings Time"). If DST -is indicated, just add an hour to the base part. - -See the discussion of timezones below. +would interpret them. +The obsolete tz_dsttime field of the kernel's timezone value is set +to DST_NONE. (For details on what this field used to mean, see +.BR settimeofday (2).) This is a good option to use in one of the system startup scripts. .TP @@ -356,21 +355,14 @@ sets the kernel timezone to the value indicated by TZ and/or .B \-\-hctosys option. .PP -A complication is that the timezone value actually consists of two -parts: 1) how far from the Standard Meridian the locality is -geographically, and 2) whether or not a Daylight Savings Time (DST) -convention is in effect in the locality at the present time. In -practice, the DST part of the timezone value is almost never used, so -if the geographical part were to be set to its correct value, the -users of the timezone value would actually compute the wrong local -time. -.PP -Therefore, -.I hwclock -violates the definition of the kernel's timezone value and always sets -the DST part to zero. If DST is supposed to be in effect, -.I hwclock -simply adds an hour to the geographical part. +The timezone value actually consists of two parts: 1) a field +tz_minuteswest indicating how many minutes local time (not adjusted +for DST) lags behind UTC, and 2) a field tz_dsttime indicating +the type of Daylight Savings Time (DST) convention that is in effect +in the locality at the present time. +This second field is not used under Linux and is always zero. +(See also +.BR settimeofday (2).) .SH How hwclock Accesses the Hardware Clock .PP diff --git a/clock/hwclock.c b/clock/hwclock.c index 8c682380..d45516b4 100644 --- a/clock/hwclock.c +++ b/clock/hwclock.c @@ -19,6 +19,7 @@ * and Martin Ostermann , aeb@cwi.nl, 990212. * * Fix for Award 2094 bug, Dave Coffin (dcoffin@shore.net) 11/12/98 + * Change of local time handling, Stefan Ring */ /* @@ -126,6 +127,9 @@ bool debug; bool badyear; /* Workaround for Award 4.50g BIOS bug: keep the year in a file. */ +int epoch_option = -1; + /* User-specified epoch, used when rtc fails to return epoch. */ + /* * Almost all Award BIOS's made between 04/26/94 and 05/31/95 * have a nasty bug limiting the RTC year byte to the range 94-99. @@ -136,7 +140,7 @@ bool badyear; * I recommend putting this command "hwclock --badyear" in the monthly * crontab, just to be safe. -- Dave Coffin 11/12/98 */ -void +static void write_date_to_file (struct tm *tm) { FILE *fp; @@ -148,7 +152,7 @@ write_date_to_file (struct tm *tm) { perror(LASTDATE); } -void +static void read_date_from_file (struct tm *tm) { int last_mday, last_mon, last_year; FILE *fp; @@ -378,18 +382,17 @@ mktime_tz(struct tm tm, const bool universal, *systime_p = 0; if (debug) printf(_("Invalid values in hardware clock: " - "%2d/%.2d/%.2d %.2d:%.2d:%.2d\n"), - tm.tm_year, tm.tm_mon+1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec - ); + "%4d/%.2d/%.2d %.2d:%.2d:%.2d\n"), + tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); } else { *valid_p = TRUE; *systime_p = mktime_result; if (debug) - printf(_("Hw clock time : %2d/%.2d/%.2d %.2d:%.2d:%.2d = " - "%d seconds since 1969\n"), - tm.tm_year, tm.tm_mon+1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec, (int) *systime_p); + printf(_("Hw clock time : %4d/%.2d/%.2d %.2d:%.2d:%.2d = " + "%ld seconds since 1969\n"), + tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec, (long) *systime_p); } /* now put back the original zone. */ if (zone) setenv("TZ", zone, TRUE); @@ -414,7 +417,8 @@ read_hardware_clock(const bool universal, bool *valid_p, time_t *systime_p){ read_date_from_file(&tm); if (debug) - printf (_("Time read from Hardware Clock: %02d:%02d:%02d\n"), + printf (_("Time read from Hardware Clock: %4d/%.2d/%.2d %02d:%02d:%02d\n"), + tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); mktime_tz(tm, universal, valid_p, systime_p); } @@ -596,8 +600,8 @@ interpret_date_string(const char *date_opt, time_t * const time_p) { int seconds_since_epoch; rc = sscanf(date_resp + sizeof(magic)-1, "%d", &seconds_since_epoch); if (rc < 1) { - fprintf(stderr, _("The date command issued by %s returned" - "something other than an integer where the converted" + fprintf(stderr, _("The date command issued by %s returned " + "something other than an integer where the converted " "time value was expected.\n" "The command was:\n %s\nThe response was:\n %s\n"), MYNAME, date_command, date_resp); @@ -643,29 +647,33 @@ set_system_clock(const bool hclock_valid, const time_t newtime, retcode = 1; } else { struct timeval tv; + struct tm *broken; + int minuteswest; int rc; tv.tv_sec = newtime; tv.tv_usec = 0; - tzset(); /* init timezone from TZ or ...zoneinfo/localtime */ + broken = localtime(&newtime); +#ifdef HAVE_tm_gmtoff + minuteswest = -broken->tm_gmtoff/60; /* GNU extension */ +#else + minuteswest = timezone/60; + if (broken->tm_isdst) + minuteswest -= 60; +#endif if (debug) { printf( _("Calling settimeofday:\n") ); printf( _("\ttv.tv_sec = %ld, tv.tv_usec = %ld\n"), (long) tv.tv_sec, (long) tv.tv_usec ); - printf( _("\ttz.tz_minuteswest = %ld\n"), timezone/60); + printf( _("\ttz.tz_minuteswest = %d\n"), minuteswest); } if (testing) { printf(_("Not setting system clock because running in test mode.\n")); retcode = 0; } else { - /* For documentation of settimeofday(), in addition to its man page, - see kernel/time.c in the Linux source code. - The code used to have `-60*daylight' here, but that is wrong. - The variable `daylight' does not specify whether it is DST now. */ - - const struct timezone tz = { timezone/60, 0 }; + const struct timezone tz = { minuteswest, 0 }; rc = settimeofday(&tv, &tz); if (rc != 0) { @@ -1149,7 +1157,6 @@ main(int argc, char **argv, char **envp) { bool ARCconsole, utc, testing, directisa, Jensen, SRM, funky_toy; bool local_opt; char *date_opt; - int epoch_opt; const optStruct option_def[] = { { 'h', (char *) "help", OPT_FLAG, &help, 0 }, @@ -1163,7 +1170,7 @@ main(int argc, char **argv, char **envp) { { 'v', (char *) "version", OPT_FLAG, &version, 0 }, { 'V', (char *) "version", OPT_FLAG, &version, 0 }, { 0, (char *) "date", OPT_STRING, &date_opt, 0 }, - { 0, (char *) "epoch", OPT_UINT, &epoch_opt, 0 }, + { 0, (char *) "epoch", OPT_UINT, &epoch_option,0 }, { 'u', (char *) "utc", OPT_FLAG, &utc, 0 }, { 0, (char *) "localtime", OPT_FLAG, &local_opt, 0 }, { 0, (char *) "badyear", OPT_FLAG, &badyear, 0 }, @@ -1183,7 +1190,9 @@ main(int argc, char **argv, char **envp) { gettimeofday(&startup_time, NULL); /* Remember what time we were invoked */ - setlocale(LC_ALL, ""); + /* not LC_ALL - the LC_NUMERIC part gives problems when + writing to /etc/adjtime - gqueri@mail.dotcom.fr */ + setlocale(LC_MESSAGES, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); @@ -1192,13 +1201,12 @@ main(int argc, char **argv, char **envp) { version = utc = local_opt = ARCconsole = SRM = funky_toy = directisa = badyear = Jensen = testing = debug = FALSE; date_opt = NULL; - epoch_opt = -1; argc_parse = argc; argv_parse = argv; optParseOptions(&argc_parse, argv_parse, option_def, 0); /* Uses and sets argc_parse, argv_parse. Sets show, systohc, hctosys, adjust, utc, local_opt, version, - testing, debug, set, date_opt, getepoch, setepoch, epoch_opt + testing, debug, set, date_opt, getepoch, setepoch, epoch_option */ /* This is an ugly routine - for example, if I give an incorrect option, it only says "unrecognized option" without telling @@ -1252,12 +1260,17 @@ main(int argc, char **argv, char **envp) { fprintf(stderr, _("Sorry, only the superuser can change the Hardware Clock.\n")); permitted = FALSE; + } else if (hctosys) { + fprintf(stderr, + _("Sorry, only the superuser can change the System Clock.\n")); + permitted = FALSE; } else if (setepoch) { fprintf(stderr, _("Sorry, only the superuser can change " "the Hardware Clock epoch in the kernel.\n")); permitted = FALSE; - } else permitted = TRUE; + } else + permitted = TRUE; } if (!permitted) retcode = 2; @@ -1266,16 +1279,19 @@ main(int argc, char **argv, char **envp) { if (version) { printf(MYNAME " " VERSION "/%s\n",util_linux_version); } else if (getepoch || setepoch) { - manipulate_epoch(getepoch, setepoch, epoch_opt, testing); + manipulate_epoch(getepoch, setepoch, epoch_option, testing); } else { if (debug) printf(MYNAME " " VERSION "/%s\n",util_linux_version); determine_clock_access_method(directisa); - if (!ur) - fprintf(stderr, _("Cannot access the Hardware Clock via any known " - "method. Use --debug option to see the details of our " - "search for an access method.\n")); - else + if (!ur) { + fprintf(stderr, + _("Cannot access the Hardware Clock via any known method.\n")); + if (!debug) + fprintf(stderr, + _("Use the --debug option to see the details of our " + "search for an access method.\n")); + } else manipulate_clock(show, adjust, set, set_time, hctosys, systohc, startup_time, utc, local_opt, testing, &rc); } diff --git a/clock/kd.c b/clock/kd.c index d1c4aca1..8fab619f 100644 --- a/clock/kd.c +++ b/clock/kd.c @@ -158,7 +158,10 @@ probe_for_kd_clock() { } else ret = &kd; } else { + /* probably KDGHWCLK exists on m68k only */ +#ifdef __m68k__ outsyserr(_("Can't open /dev/tty1")); +#endif } return ret; } diff --git a/clock/shhopt.c b/clock/shhopt.c index e55a7293..ac341282 100644 --- a/clock/shhopt.c +++ b/clock/shhopt.c @@ -228,7 +228,7 @@ static void argvRemove(int *argc, char *argv[], int i) * RETURNS Nothing. Aborts in case of error. * */ -void optExecute(const optStruct *opt, char *arg, int lng) +static void optExecute(const optStruct *opt, char *arg, int lng) { switch (opt->type) { case OPT_FLAG: diff --git a/configure b/configure index 6b5d6b6a..4ac10b04 100755 --- a/configure +++ b/configure @@ -20,6 +20,10 @@ # 14. For script.c: do we have and openpty()? # 15. For lib/widechar.h: do we have wide character support? # 16. For clock/kd.c: do we have nanosleep()? +# 17. For mkswap: do we have personality()? +# 18. For pivot_root.c: does define __NR_pivot_root? +# 19. For hwclock.c: does struct tm have a field tm_gmtoff? +# 20. For nfsmount: does the output of rpcgen compile? rm -f make_include defines.h @@ -323,7 +327,9 @@ echo " #include main(){ exit(0); openpty(0, 0, 0, 0, 0); } " > conftest.c +LIBS=-lutil eval $compile +LIBS= if test -s conftest && ./conftest 2>/dev/null; then echo "HAVE_OPENPTY=yes" >> make_include echo "#define HAVE_openpty" >> defines.h @@ -381,3 +387,104 @@ else fi rm -f conftest conftest.c +# +# 17. For mkswap.c: do we have personality()? +# +echo " +int main () { + extern int personality(unsigned long); + personality(0); + exit(0); +} +" > conftest.c +eval $compile +if test -s conftest && ./conftest 2>/dev/null; then + echo "#define HAVE_personality" >> defines.h + echo "You have personality()" +else + echo "You don't have personality()" +fi +rm -f conftest conftest.c + +# +# 18. For pivot_root.c: does define __NR_pivot_root? +# +echo " +#include +int main(void) +{ + return __NR_pivot_root; +} +" >conftest.c +eval $compile +if test -s conftest; then + echo "HAVE_PIVOT_ROOT=yes" >> make_include + echo "You have __NR_pivot_root" +else + echo "You don't have __NR_pivot_root" +fi +rm -f conftest conftest.c + +# +# 19. For hwclock.c: does struct tm have a field tm_gmtoff? +# +echo " +#include +#include +int main(int a, char **v) +{ + struct tm *tm = localtime(0); + if (a == -1) /* false */ + sleep(tm->tm_gmtoff); + exit(0); +} +" >conftest.c +eval $compile +if test -s conftest; then + echo "#define HAVE_tm_gmtoff" >> defines.h + echo "You have a tm_gmtoff field in struct tm" +else + echo "You don't have a tm_gmtoff field in struct tm" +fi +rm -f conftest conftest.c + +# +# 20. For nfsmount: does the output of rpcgen compile? +# +rm -f conftest conftestx.c conftestl.c conftest.h conftest.x +echo " +#ifdef RPC_CLNT +%#include /* for memset() */ +#endif +%#include +typedef opaque fhandle[1]; +union fhstatus switch (unsigned fhs_status) { +case 0: + fhandle fhs_fhandle; +default: + void; +}; +typedef string dirpath<1024>; +struct ppathcnf { + short pc_mask[2]; +}; + +program MOUNTPROG { + version MOUNTVERS { + fhstatus + MOUNTPROC_MNT(dirpath) = 1; + } = 2; +} = 100005; +" > conftest.x +if rpcgen -h -o conftest.h conftest.x && \ + rpcgen -c -o conftestx.c conftest.x && \ + rpcgen -l -o conftestl.c conftest.x && \ + cc -c conftestx.c 2> conferrs && cc -c conftestl.c 2>> conferrs && \ + test ! -s conferrs +then + echo "HAVE_GOOD_RPC=yes" >> make_include + echo "Your rpcgen seems to work" +else + echo "Your rpcgen output does not compile" +fi +rm -f conftest conftestx.c conftestl.c conftest.h conftest.x conferrs diff --git a/disk-utils/Makefile b/disk-utils/Makefile index 36f5e616..ab9237c8 100644 --- a/disk-utils/Makefile +++ b/disk-utils/Makefile @@ -8,23 +8,17 @@ include ../MCONFIG # Where to put man pages? -MAN8= fdformat.8 mkfs.8 mkswap.8 +MAN8= fdformat.8 mkfs.8 mkswap.8 elvtune.8 fsck.minix.8 mkfs.minix.8 mkfs.bfs.8 # Where to put binaries? # See the "install" rule for the links. . . -SBIN= mkfs mkswap blockdev +SBIN= mkfs mkswap blockdev elvtune fsck.minix mkfs.minix mkfs.bfs USRBIN= fdformat ETC= fdprm -ifneq "$(CPU)" "sparc" -# fsck and mkfs will compile, but there is no kernel support on sparc -MAN8:=$(MAN8) fsck.minix.8 mkfs.minix.8 mkfs.bfs.8 -SBIN:=$(SBIN) fsck.minix mkfs.minix mkfs.bfs -endif - ifneq "$(HAVE_FDUTILS)" "yes" USRBIN:=$(USRBIN) setfdprm MAN8:=$(MAN8) setfdprm.8 @@ -39,7 +33,7 @@ endif all: $(SBIN) $(USRBIN) -fsck.minix.o mkfs.minix.o: bitops.h +fsck.minix.o mkfs.minix.o: bitops.h minix.h install: all $(INSTALLDIR) $(SBINDIR) $(USRBINDIR) $(ETCDIR) diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c index 7f1fd7bb..af727f7d 100644 --- a/disk-utils/blockdev.c +++ b/disk-utils/blockdev.c @@ -11,9 +11,22 @@ #include #include -#include #include "nls.h" +/* Since it is impossible to include , let us + give the ioctls explicitly. */ + +#ifndef BLKROSET +#define BLKROSET _IO(0x12,93) +#define BLKROGET _IO(0x12,94) +#define BLKRRPART _IO(0x12,95) +#define BLKGETSIZE _IO(0x12,96) +#define BLKFLSBUF _IO(0x12,97) +#define BLKRASET _IO(0x12,98) +#define BLKRAGET _IO(0x12,99) +#define BLKSSZGET _IO(0x12,104) +#endif + const char *progname; struct bdc { @@ -76,7 +89,7 @@ usage(void) { exit(1); } -int +static int find_cmd(char *s) { int j; diff --git a/disk-utils/elvtune.8 b/disk-utils/elvtune.8 new file mode 100644 index 00000000..21a0bbc0 --- /dev/null +++ b/disk-utils/elvtune.8 @@ -0,0 +1,73 @@ +.\" -*- nroff -*- +.TH ELVTUNE 8 "14 March 2000" "Version 1.0" +.SH NAME +elvtune \- I/O elevator tuner +.SH SYNOPSIS +.B elvtune +[ +.B \-r +.I r_lat +] +[ +.B \-w +.I w_lat +] +[ +.B \-b +.I b_max +] +.B /dev/blkdev1 +[ +.B /dev/blkdev2 ... +] + +.B elvtune +.B -h + +.B elvtune +.B -v +.SH DESCRIPTION +.B elvtune +allows to tune the I/O elevator per blockdevice queue basis. The +tuning can be safely done at runtime. Tuning the elevator means +being able to change disk performance and interactiveness. In the +output of elvtune the address of the queue tuned will be shown +and it can be considered as a queue ID. +For example multiple partitions in the same harddisk will +share the same queue and so tuning one partition will be +like tuning the whole HD. +.SH OPTIONS +.TP +.BI -r \ r_lat +set the max latency that the I/O scheduler will provide on +each read. +.TP +.BI -w \ w_lat +set the max latency that the I/O scheduler will provide on +each write. +.TP +.BI -b \ b_max +max coalescing factor allowed on writes when there are reads +pending in the queue. +.TP +.BI -h +help. +.TP +.BI -v +version. +.SH NOTE +Actually the only fields tunable are those relative +to the IO scheduler. It's not possible to select +a one-way or two-way elevator yet. +.PP +For logical blockdevices like LVM the tuning has to +be done on the +.I physical +devices. Tuning the queue of the LVM logical device +is useless. +.SH RETURN VALUE +0 on success and 1 on failure. +.SH HISTORY +Ioctls for tuning elevator behaviour were added in Linux 2.3.99-pre1. +.SH AUTHORS +Andrea Arcangeli SuSE diff --git a/disk-utils/elvtune.c b/disk-utils/elvtune.c new file mode 100644 index 00000000..00640fed --- /dev/null +++ b/disk-utils/elvtune.c @@ -0,0 +1,143 @@ +/* + * elvtune.c - I/O elevator tuner + * + * Copyright (C) 2000 Andrea Arcangeli SuSE + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * This file may be redistributed under the terms of the GNU General + * Public License, version 2. + */ + +#include +#include +#include +#include +#include +#include + +#define BLKELVGET _IO(0x12,106)/* elevator get */ +#define BLKELVSET _IO(0x12,107)/* elevator set */ + +/* this has to match with the kernel structure */ +typedef struct blkelv_ioctl_arg_s { + void * queue_ID; + int read_latency; + int write_latency; + int max_bomb_segments; +} blkelv_ioctl_arg_t; + +static void +usage(void) { + fprintf(stderr, "usage:\n\telvtune [-r r_lat] [-w w_lat] [-b b_lat] /dev/blkdev1 [/dev/blkdev2...]\n"); + fprintf(stderr, "\telvtune -h\n"); + fprintf(stderr, "\telvtune -v\n"); +} + +static void +version(void) { + fprintf(stderr, "elvtune: version 1.0\n"); +} + +int +main(int argc, char * argv[]) { + int read_value = 0xbeefbeef, write_value = 0xbeefbeef, bomb_value = 0xbeefbeef; + int read_set, write_set, bomb_set, set; + char * devname; + int fd; + blkelv_ioctl_arg_t elevator; + + read_set = write_set = bomb_set = set = 0; + + for (;;) { + int opt; + + opt = getopt(argc, argv, "r:w:b:hv"); + if (opt < 0) + break; + switch (opt) { + case 'r': + read_value = atoi(optarg); + read_set = set = 1; + break; + case 'w': + write_value = atoi(optarg); + write_set = set = 1; + break; + case 'b': + bomb_value = atoi(optarg); + bomb_set = set = 1; + break; + + case 'h': + usage(), exit(0); + case 'v': + version(), exit(0); + + case '?': + default: + case ':': + fprintf(stderr, "parse error\n"); + exit(1); + } + } + + if (optind >= argc) + fprintf(stderr, "missing blockdevice, use -h for help\n"), exit(1); + + while (optind < argc) { + devname = argv[optind++]; + + fd = open(devname, O_RDONLY|O_NONBLOCK); + if (fd < 0) { + perror("open"); + break; + } + + if (ioctl(fd, BLKELVGET, &elevator) < 0) { + perror("ioctl get"); + break; + } + + if (set) { + if (read_set) + elevator.read_latency = read_value; + if (write_set) + elevator.write_latency = write_value; + if (bomb_set) + elevator.max_bomb_segments = bomb_value; + + if (ioctl(fd, BLKELVSET, &elevator) < 0) { + perror("ioctl set"); + break; + } + if (ioctl(fd, BLKELVGET, &elevator) < 0) { + perror("ioctl reget"); + break; + } + } + + printf("\n%s elevator ID %p\n", devname, elevator.queue_ID); + printf("\tread_latency:\t\t%d\n", elevator.read_latency); + printf("\twrite_latency:\t\t%d\n", elevator.write_latency); + printf("\tmax_bomb_segments:\t%d\n\n", elevator.max_bomb_segments); + + if (close(fd) < 0) { + perror("close"); + break; + } + } + + return 0; +} diff --git a/disk-utils/fdformat.c b/disk-utils/fdformat.c index 6c3ef5c9..0251e344 100644 --- a/disk-utils/fdformat.c +++ b/disk-utils/fdformat.c @@ -15,9 +15,12 @@ #include #include #include -#include + #include "nls.h" +/* cannot include */ +#define MAJOR(a) ((a)>>8) + static int ctrl; struct floppy_struct param; diff --git a/disk-utils/fsck.minix.8 b/disk-utils/fsck.minix.8 index f0d85375..68979ced 100644 --- a/disk-utils/fsck.minix.8 +++ b/disk-utils/fsck.minix.8 @@ -36,9 +36,7 @@ will print "FILE SYSTEM HAS CHANGED" and will three times before exiting. Since Linux does not currently have raw devices, there is .I no -need to reboot at this time (versus a system which -.I does -have raw devices). +need to reboot at this time. .SH WARNING .B fsck.minix should diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c index 99a8ca85..1f040eb5 100644 --- a/disk-utils/fsck.minix.c +++ b/disk-utils/fsck.minix.c @@ -96,8 +96,7 @@ #include #include -#include -#include +#include "minix.h" #include "nls.h" #ifdef MINIX2_SUPER_MAGIC2 @@ -169,8 +168,10 @@ static char *zone_map; static unsigned char * inode_count = NULL; static unsigned char * zone_count = NULL; -void recursive_check(unsigned int ino); -void recursive_check2(unsigned int ino); +static void recursive_check(unsigned int ino); +#ifdef HAVE_MINIX2 +static void recursive_check2(unsigned int ino); +#endif #include "bitops.h" @@ -183,22 +184,23 @@ void recursive_check2(unsigned int ino); #define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1),changed=1) #define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1),changed=1) -void leave(int) __attribute__ ((noreturn)); -void leave(int status) -{ +static void +leave(int status) { if (termios_set) tcsetattr(0, TCSANOW, &termios); exit(status); } -void usage(void) { +static void +usage(void) { fprintf(stderr, _("Usage: %s [-larvsmf] /dev/name\n"), program_name); leave(16); } -void die(const char *str) { +static void +die(const char *str) { fprintf(stderr, "%s: %s\n", program_name, str); leave(8); } @@ -207,8 +209,8 @@ void die(const char *str) { * This simply goes through the file-name data and prints out the * current file. */ -void print_current_name(void) -{ +static void +print_current_name(void) { int i=0; while (i= ZONES) { @@ -401,8 +403,8 @@ void write_block(unsigned int nr, char * addr) * It sets 'changed' if the inode has needed changing, and re-writes * any indirect blocks with errors. */ -int map_block(struct minix_inode * inode, unsigned int blknr) -{ +static int +map_block(struct minix_inode * inode, unsigned int blknr) { unsigned short ind[BLOCK_SIZE>>1]; unsigned short dind[BLOCK_SIZE>>1]; int blk_chg, block, result; @@ -436,8 +438,8 @@ int map_block(struct minix_inode * inode, unsigned int blknr) } #ifdef HAVE_MINIX2 -int map_block2 (struct minix2_inode *inode, unsigned int blknr) -{ +static int +map_block2 (struct minix2_inode *inode, unsigned int blknr) { unsigned int ind[BLOCK_SIZE >> 2]; unsigned int dind[BLOCK_SIZE >> 2]; unsigned int tind[BLOCK_SIZE >> 2]; @@ -494,8 +496,8 @@ int map_block2 (struct minix2_inode *inode, unsigned int blknr) } #endif -void write_super_block(void) -{ +static void +write_super_block(void) { /* * Set the state of the filesystem based on whether or not there * are uncorrected errors. The filesystem valid flag is @@ -515,8 +517,8 @@ void write_super_block(void) return; } -void write_tables(void) -{ +static void +write_tables(void) { write_super_block(); if (IMAPS*BLOCK_SIZE != write(IN,inode_map,IMAPS*BLOCK_SIZE)) @@ -527,8 +529,8 @@ void write_tables(void) die(_("Unable to write inodes")); } -void get_dirsize (void) -{ +static void +get_dirsize (void) { int block; char blk[BLOCK_SIZE]; int size; @@ -550,8 +552,8 @@ void get_dirsize (void) /* use defaults */ } -void read_superblock(void) -{ +static void +read_superblock(void) { if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) die(_("seek failed")); if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE)) @@ -584,8 +586,8 @@ void read_superblock(void) die(_("bad s_zmap_blocks field in super-block")); } -void read_tables(void) -{ +static void +read_tables(void) { inode_map = malloc(IMAPS * BLOCK_SIZE); if (!inode_map) die(_("Unable to allocate buffer for inode map")); @@ -625,8 +627,8 @@ void read_tables(void) } } -struct minix_inode * get_inode(unsigned int nr) -{ +static struct minix_inode * +get_inode(unsigned int nr) { struct minix_inode * inode; if (!nr || nr > INODES) @@ -676,9 +678,8 @@ struct minix_inode * get_inode(unsigned int nr) } #ifdef HAVE_MINIX2 -struct minix2_inode * -get_inode2 (unsigned int nr) -{ +static struct minix2_inode * +get_inode2 (unsigned int nr) { struct minix2_inode *inode; if (!nr || nr > INODES) @@ -724,8 +725,8 @@ get_inode2 (unsigned int nr) } #endif -void check_root(void) -{ +static void +check_root(void) { struct minix_inode * inode = Inode + ROOT_INO; if (!inode || !S_ISDIR(inode->i_mode)) @@ -733,8 +734,8 @@ void check_root(void) } #ifdef HAVE_MINIX2 -void check_root2 (void) -{ +static void +check_root2 (void) { struct minix2_inode *inode = Inode2 + ROOT_INO; if (!inode || !S_ISDIR (inode->i_mode)) @@ -742,8 +743,8 @@ void check_root2 (void) } #endif -static int add_zone(unsigned short * znr, int * corrected) -{ +static int +add_zone(unsigned short * znr, int * corrected) { int result; int block; @@ -776,8 +777,8 @@ static int add_zone(unsigned short * znr, int * corrected) } #ifdef HAVE_MINIX2 -static int add_zone2 (unsigned int *znr, int *corrected) -{ +static int +add_zone2 (unsigned int *znr, int *corrected) { int result; int block; @@ -810,8 +811,8 @@ static int add_zone2 (unsigned int *znr, int *corrected) } #endif -static void add_zone_ind(unsigned short * znr, int * corrected) -{ +static void +add_zone_ind(unsigned short * znr, int * corrected) { static char blk[BLOCK_SIZE]; int i, chg_blk=0; int block; @@ -828,8 +829,7 @@ static void add_zone_ind(unsigned short * znr, int * corrected) #ifdef HAVE_MINIX2 static void -add_zone_ind2 (unsigned int *znr, int *corrected) -{ +add_zone_ind2 (unsigned int *znr, int *corrected) { static char blk[BLOCK_SIZE]; int i, chg_blk = 0; int block; @@ -845,8 +845,8 @@ add_zone_ind2 (unsigned int *znr, int *corrected) } #endif -static void add_zone_dind(unsigned short * znr, int * corrected) -{ +static void +add_zone_dind(unsigned short * znr, int * corrected) { static char blk[BLOCK_SIZE]; int i, blk_chg=0; int block; @@ -863,8 +863,7 @@ static void add_zone_dind(unsigned short * znr, int * corrected) #ifdef HAVE_MINIX2 static void -add_zone_dind2 (unsigned int *znr, int *corrected) -{ +add_zone_dind2 (unsigned int *znr, int *corrected) { static char blk[BLOCK_SIZE]; int i, blk_chg = 0; int block; @@ -880,8 +879,7 @@ add_zone_dind2 (unsigned int *znr, int *corrected) } static void -add_zone_tind2 (unsigned int *znr, int *corrected) -{ +add_zone_tind2 (unsigned int *znr, int *corrected) { static char blk[BLOCK_SIZE]; int i, blk_chg = 0; int block; @@ -897,8 +895,8 @@ add_zone_tind2 (unsigned int *znr, int *corrected) } #endif -void check_zones(unsigned int i) -{ +static void +check_zones(unsigned int i) { struct minix_inode * inode; if (!i || i > INODES) @@ -916,9 +914,8 @@ void check_zones(unsigned int i) } #ifdef HAVE_MINIX2 -void -check_zones2 (unsigned int i) -{ +static void +check_zones2 (unsigned int i) { struct minix2_inode *inode; if (!i || i > INODES) @@ -937,8 +934,8 @@ check_zones2 (unsigned int i) } #endif -void check_file(struct minix_inode * dir, unsigned int offset) -{ +static void +check_file(struct minix_inode * dir, unsigned int offset) { static char blk[BLOCK_SIZE]; struct minix_inode * inode; int ino; @@ -1000,9 +997,8 @@ void check_file(struct minix_inode * dir, unsigned int offset) } #ifdef HAVE_MINIX2 -void -check_file2 (struct minix2_inode *dir, unsigned int offset) -{ +static void +check_file2 (struct minix2_inode *dir, unsigned int offset) { static char blk[BLOCK_SIZE]; struct minix2_inode *inode; int ino; @@ -1064,8 +1060,8 @@ check_file2 (struct minix2_inode *dir, unsigned int offset) } #endif -void recursive_check(unsigned int ino) -{ +static void +recursive_check(unsigned int ino) { struct minix_inode * dir; unsigned int offset; @@ -1082,9 +1078,8 @@ void recursive_check(unsigned int ino) } #ifdef HAVE_MINIX2 -void -recursive_check2 (unsigned int ino) -{ +static void +recursive_check2 (unsigned int ino) { struct minix2_inode *dir; unsigned int offset; @@ -1101,8 +1096,8 @@ recursive_check2 (unsigned int ino) } #endif -int bad_zone(int i) -{ +static int +bad_zone(int i) { char buffer[1024]; if (BLOCK_SIZE*i != lseek(IN, BLOCK_SIZE*i, SEEK_SET)) @@ -1110,8 +1105,8 @@ int bad_zone(int i) return (BLOCK_SIZE != read(IN, buffer, BLOCK_SIZE)); } -void check_counts(void) -{ +static void +check_counts(void) { int i; for (i=1 ; i <= INODES ; i++) { @@ -1162,9 +1157,8 @@ void check_counts(void) } #ifdef HAVE_MINIX2 -void -check_counts2 (void) -{ +static void +check_counts2 (void) { int i; for (i = 1; i <= INODES; i++) { @@ -1214,8 +1208,8 @@ check_counts2 (void) } #endif -void check(void) -{ +static void +check(void) { memset(inode_count,0,(INODES + 1) * sizeof(*inode_count)); memset(zone_count,0,ZONES*sizeof(*zone_count)); check_zones(ROOT_INO); @@ -1224,9 +1218,8 @@ void check(void) } #ifdef HAVE_MINIX2 -void -check2 (void) -{ +static void +check2 (void) { memset (inode_count, 0, (INODES + 1) * sizeof (*inode_count)); memset (zone_count, 0, ZONES * sizeof (*zone_count)); check_zones2 (ROOT_INO); @@ -1235,8 +1228,8 @@ check2 (void) } #endif -int main(int argc, char ** argv) -{ +int +main(int argc, char ** argv) { struct termios tmp; int count; int retcode = 0; diff --git a/disk-utils/minix.h b/disk-utils/minix.h new file mode 100644 index 00000000..46f2af3c --- /dev/null +++ b/disk-utils/minix.h @@ -0,0 +1,60 @@ +#ifdef KERNEL_INCLUDES_ARE_CLEAN + +#include +#include + +#else + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; + +struct minix_inode { + u16 i_mode; + u16 i_uid; + u32 i_size; + u32 i_time; + u8 i_gid; + u8 i_nlinks; + u16 i_zone[9]; +}; + +struct minix2_inode { + u16 i_mode; + u16 i_nlinks; + u16 i_uid; + u16 i_gid; + u32 i_size; + u32 i_atime; + u32 i_mtime; + u32 i_ctime; + u32 i_zone[10]; +}; + +struct minix_super_block { + u16 s_ninodes; + u16 s_nzones; + u16 s_imap_blocks; + u16 s_zmap_blocks; + u16 s_firstdatazone; + u16 s_log_zone_size; + u32 s_max_size; + u16 s_magic; + u16 s_state; + u32 s_zones; +}; + +#define BLOCK_SIZE_BITS 10 +#define BLOCK_SIZE (1< #include -#include /* for BLKGETSIZE */ +/* cannot include */ +#ifndef BLKGETSIZE +#define BLKGETSIZE _IO(0x12,96) /* return device size */ +#endif #include "../defines.h" /* for util_linux_version */ diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c index 4887f05d..4eb9aa4b 100644 --- a/disk-utils/mkfs.minix.c +++ b/disk-utils/mkfs.minix.c @@ -72,11 +72,13 @@ #include #include -#include -#include - +#include "minix.h" #include "nls.h" +#ifndef BLKGETSIZE +#define BLKGETSIZE _IO(0x12,96) /* return device size */ +#endif + #ifdef MINIX2_SUPER_MAGIC2 #define HAVE_MINIX2 1 #endif @@ -85,10 +87,6 @@ #error "needs gcc for the bitop-__asm__'s" #endif -#ifndef __linux__ -#define volatile -#endif - #define MINIX_ROOT_INO 1 #define MINIX_BAD_INO 2 @@ -162,24 +160,20 @@ static unsigned long req_nr_inodes = 0; #define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1)) #define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1)) -/* - * Volatile to let gcc know that this doesn't return. When trying - * to compile this under minix, volatile gives a warning, as - * exit() isn't defined as volatile under minix. - */ -volatile void fatal_error(const char * fmt_string,int status) -{ +static void +fatal_error(const char * fmt_string,int status) { fprintf(stderr,fmt_string,program_name,device_name); exit(status); } -volatile void die(char *str) { +static void +die(char *str) { fprintf(stderr, "%s: %s\n", program_name, str); exit(8); } -volatile void usage() -{ +static void +usage(void) { fprintf(stderr, "%s (%s)\n", program_name, util_linux_version); fprintf(stderr, _("Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n"), @@ -192,8 +186,8 @@ volatile void usage() * an already mounted partition. Code adapted from mke2fs, Copyright * (C) 1994 Theodore Ts'o. Also licensed under GPL. */ -static void check_mount(void) -{ +static void +check_mount(void) { FILE * f; struct mntent * mnt; @@ -209,8 +203,8 @@ static void check_mount(void) die(_("%s is mounted; will not make a filesystem here!")); } -static long valid_offset (int fd, int offset) -{ +static long +valid_offset (int fd, int offset) { char ch; if (lseek (fd, offset, 0) < 0) @@ -220,8 +214,8 @@ static long valid_offset (int fd, int offset) return 1; } -static int count_blocks (int fd) -{ +static int +count_blocks (int fd) { int high, low; low = 0; @@ -240,8 +234,8 @@ static int count_blocks (int fd) return (low + 1); } -static int get_size(const char *file) -{ +static int +get_size(const char *file) { int fd; long size; @@ -260,8 +254,8 @@ static int get_size(const char *file) return size; } -void write_tables(void) -{ +static void +write_tables(void) { /* Mark the super block valid. */ Super.s_state |= MINIX_VALID_FS; Super.s_state &= ~MINIX_ERROR_FS; @@ -283,16 +277,16 @@ void write_tables(void) } -void write_block(int blk, char * buffer) -{ +static void +write_block(int blk, char * buffer) { if (blk*BLOCK_SIZE != lseek(DEV, blk*BLOCK_SIZE, SEEK_SET)) die(_("seek failed in write_block")); if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE)) die(_("write failed in write_block")); } -int get_free_block(void) -{ +static int +get_free_block(void) { int blk; if (used_good_blocks+1 >= MAX_GOOD_BLOCKS) @@ -310,16 +304,16 @@ int get_free_block(void) return blk; } -void mark_good_blocks(void) -{ +static void +mark_good_blocks(void) { int blk; for (blk=0 ; blk < used_good_blocks ; blk++) mark_zone(good_blocks_table[blk]); } -inline int next(int zone) -{ +static inline int +next(int zone) { if (!zone) zone = FIRSTZONE-1; while (++zone < ZONES) @@ -328,8 +322,8 @@ inline int next(int zone) return 0; } -void make_bad_inode(void) -{ +static void +make_bad_inode(void) { struct minix_inode * inode = &Inode[MINIX_BAD_INO]; int i,j,zone; int ind=0,dind=0; @@ -379,9 +373,8 @@ end_bad: } #ifdef HAVE_MINIX2 -void -make_bad_inode2 (void) -{ +static void +make_bad_inode2 (void) { struct minix2_inode *inode = &Inode2[MINIX_BAD_INO]; int i, j, zone; int ind = 0, dind = 0; @@ -430,8 +423,8 @@ make_bad_inode2 (void) } #endif -void make_root_inode(void) -{ +static void +make_root_inode(void) { struct minix_inode * inode = &Inode[MINIX_ROOT_INO]; mark_inode(MINIX_ROOT_INO); @@ -453,9 +446,8 @@ void make_root_inode(void) } #ifdef HAVE_MINIX2 -void -make_root_inode2 (void) -{ +static void +make_root_inode2 (void) { struct minix2_inode *inode = &Inode2[MINIX_ROOT_INO]; mark_inode (MINIX_ROOT_INO); @@ -477,8 +469,8 @@ make_root_inode2 (void) } #endif -void setup_tables(void) -{ +static void +setup_tables(void) { int i; unsigned long inodes; @@ -540,8 +532,8 @@ void setup_tables(void) * Perform a test of a block; return the number of * blocks readable/writeable. */ -long do_check(char * buffer, int try, unsigned int current_block) -{ +static long +do_check(char * buffer, int try, unsigned int current_block) { long got; /* Seek to the correct loc. */ @@ -563,8 +555,8 @@ long do_check(char * buffer, int try, unsigned int current_block) static unsigned int currently_testing = 0; -void alarm_intr(int alnum) -{ +static void +alarm_intr(int alnum) { if (currently_testing >= ZONES) return; signal(SIGALRM,alarm_intr); @@ -575,8 +567,8 @@ void alarm_intr(int alnum) fflush(stdout); } -void check_blocks(void) -{ +static void +check_blocks(void) { int try,got; static char buffer[BLOCK_SIZE * TEST_BUFFER_BLOCKS]; @@ -606,10 +598,8 @@ void check_blocks(void) printf(_("one bad block\n")); } -void get_list_blocks(filename) -char *filename; - -{ +static void +get_list_blocks(char *filename) { FILE *listfile; unsigned long blockno; @@ -628,8 +618,8 @@ char *filename; printf(_("one bad block\n")); } -int main(int argc, char ** argv) -{ +int +main(int argc, char ** argv) { int i; char * tmp; struct stat statbuf; diff --git a/disk-utils/mkswap.8 b/disk-utils/mkswap.8 index 368ef3b5..4ee3627a 100644 --- a/disk-utils/mkswap.8 +++ b/disk-utils/mkswap.8 @@ -97,7 +97,7 @@ able to look it up with "cat /proc/cpuinfo" (or you may not - the contents of this file depend on architecture and kernel version). To setup a swap file, it is necessary to create that file before -running +initializing it with .B mkswap , e.g. using a command like @@ -140,13 +140,12 @@ Create a new style swap area. .LP If no \-v option is given, .B mkswap -will default to old style if the size of the swap area does not -exceed the maximum size of an old style swap area, and also if -the current kernel is older than 2.1.117 (and also if PAGE_SIZE -is less than 2048). +will default to new style, but use old style if the current kernel +is older than 2.1.117 (and also if PAGE_SIZE is less than 2048). The new style header does not touch the first block, so may be -preferable (also if the swap area is small), in case you have -a boot loader or disk label there. +preferable, in case you have a boot loader or disk label there. +If you need to use both 2.0 and 2.2 kernels, use the \-v0 option +when creating the swapspace. .SH "SEE ALSO" .BR fdisk (8), diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index 2803587b..96050001 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -24,6 +24,7 @@ * * Sparc fixes, jj@ultra.linux.cz (Jakub Jelinek), 981201 - mangled by aeb. * V1_MAX_PAGES fixes, jj, 990325. + * sparc64 fixes, jj, 000219. * * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support @@ -74,6 +75,57 @@ linux_version_code(void) { return 0; } +#ifdef __sparc__ +# ifdef __arch64__ +# define is_sparc64() 1 +# define is_be64() 1 +# else /* sparc32 */ +static int +is_sparc64(void) { + struct utsname un; + static int sparc64 = -1; + + if (sparc64 != -1) return sparc64; + sparc64 = 0; + + if (uname(&un) < 0) return 0; + if (! strcmp(un.machine, "sparc64")) { + sparc64 = 1; + return 1; + } + if (strcmp(un.machine, "sparc")) + return 0; /* Should not happen */ + +#ifdef HAVE_personality + { + extern int personality(unsigned long); + int oldpers; +#define PERS_LINUX 0x00000000 +#define PERS_LINUX_32BIT 0x00800000 +#define PERS_LINUX32 0x00000008 + + oldpers = personality(PERS_LINUX_32BIT); + if (oldpers != -1) { + if (personality(PERS_LINUX) != -1) { + uname(&un); + if (! strcmp(un.machine, "sparc64")) { + sparc64 = 1; + oldpers = PERS_LINUX32; + } + } + personality(oldpers); + } + } +#endif + + return sparc64; +} +# define is_be64() is_sparc64() +# endif /* sparc32 */ +#else /* !sparc */ +# define is_be64() 0 +#endif + /* * The definition of the union swap_header uses the constant PAGE_SIZE. * Unfortunately, on some architectures this depends on the hardware model, @@ -92,7 +144,7 @@ static int user_pagesize = 0; static int kernel_pagesize; /* obtained via getpagesize(); */ static int defined_pagesize = 0; /* PAGE_SIZE, when that exists */ static int pagesize; -static int *signature_page; +static long *signature_page; struct swap_header_v1 { char bootbits[1024]; /* Space for disklabel etc. */ @@ -104,7 +156,7 @@ struct swap_header_v1 { } *p; static void -init_signature_page() { +init_signature_page(void) { #ifdef PAGE_SIZE defined_pagesize = PAGE_SIZE; #endif @@ -130,7 +182,7 @@ init_signature_page() { fprintf(stderr, _("Assuming pages of size %d (not %d)\n"), pagesize, defined_pagesize); - signature_page = (int *) malloc(pagesize); + signature_page = (long *) malloc(pagesize); memset(signature_page,0,pagesize); p = (struct swap_header_v1 *) signature_page; } @@ -169,14 +221,14 @@ write_signature(char *sig) { refuse a swap space if it is too large. */ /* patch from jj - why does this differ from the above? */ +/* 32bit kernels have a second limitation of 2GB, sparc64 is limited by + the size of virtual address space allocation for vmalloc */ #if defined(__alpha__) #define V1_MAX_PAGES ((1 << 24) - 1) #elif defined(__mips__) #define V1_MAX_PAGES ((1 << 17) - 1) -#elif defined(__sparc_v9__) -#define V1_MAX_PAGES ((3 << 29) - 1) #elif defined(__sparc__) -#define V1_MAX_PAGES (pagesize == 8192 ? ((3 << 29) - 1) : ((1 << 18) - 1)) +#define V1_MAX_PAGES (is_sparc64() ? ((3 << 29) - 1) : ((1 << 18) - 1)) #else #define V1_MAX_PAGES V1_OLD_MAX_PAGES #endif @@ -188,28 +240,68 @@ It is roughly 2GB on i386, PPC, m68k, ARM, 1GB on sparc, 512MB on mips, #define MAX_BADPAGES ((pagesize-1024-128*sizeof(int)-10)/sizeof(int)) +/* + * One more point of lossage - Linux swapspace really is a mess. + * The definition of the bitmap used is architecture dependent, + * and requires one to know whether the machine is bigendian, + * and if so, whether it will use 32-bit or 64-bit units in + * test_bit(). + * davem writes: "... is based upon an unsigned long type of + * the cpu and the native endianness". + * So, it seems we can write `unsigned long' below. + * However, sparc64 uses 64-bit units in the kernel, while + * mkswap may have been translated with 32-bit longs. Thus, + * we need an explicit test for version 0 swap on sparc64. + */ + static void -bit_set (unsigned int *addr, unsigned int nr) { +bit_set (unsigned long *addr, unsigned int nr) { unsigned int r, m; - addr += nr / (8 * sizeof(int)); + if(is_be64()) { + unsigned long long *bitmap = (unsigned long long *) addr; + unsigned long long bitnum = (unsigned long long) nr; + unsigned long long rl, ml; + + bitmap += bitnum / (8 * sizeof(long long)); + rl = *bitmap; + ml = 1ULL << (bitnum & + (8ULL * (unsigned long long)sizeof(long long) - 1ULL)); + *bitmap = rl | ml; + return; + } + + addr += nr / (8 * sizeof(unsigned long)); r = *addr; - m = 1 << (nr & (8 * sizeof(int) - 1)); + m = 1 << (nr & (8 * sizeof(unsigned long) - 1)); *addr = r | m; } static int -bit_test_and_clear (unsigned int *addr, unsigned int nr) { +bit_test_and_clear (unsigned long *addr, unsigned int nr) { unsigned int r, m; - addr += nr / (8 * sizeof(int)); + if(is_be64()) { + unsigned long long *bitmap = (unsigned long long *) addr; + unsigned long long bitnum = (unsigned long long) nr; + unsigned long long rl, ml; + + bitmap += bitnum / (8 * sizeof(long long)); + rl = *bitmap; + ml = 1ULL << (bitnum & + (8ULL * (unsigned long long)sizeof(long long) - 1ULL)); + *bitmap = rl & ~ml; + return ((rl & ml) != 0ULL); + } + + addr += nr / (8 * sizeof(unsigned long)); r = *addr; - m = 1 << (nr & (8 * sizeof(int) - 1)); + m = 1 << (nr & (8 * sizeof(unsigned long) - 1)); *addr = r & ~m; return (r & m) != 0; } -void +static void usage(void) { fprintf(stderr, _("Usage: %s [-c] [-v0|-v1] [-pPAGESZ] /dev/name [blocks]\n"), @@ -217,19 +309,19 @@ usage(void) { exit(1); } -void +static void die(const char *str) { fprintf(stderr, "%s: %s\n", program_name, str); exit(1); } -void +static void page_ok(int page) { if (version==0) bit_set(signature_page, page); } -void +static void page_bad(int page) { if (version == 0) bit_test_and_clear(signature_page, page); @@ -241,7 +333,7 @@ page_bad(int page) { badpages++; } -void +static void check_blocks(void) { unsigned int current_page; int do_seek = 1; @@ -322,7 +414,7 @@ get_size(const char *file) { return size; } -int +static int isnzdigit(char c) { return (c >= '1' && c <= '9'); } @@ -371,7 +463,7 @@ main(int argc, char ** argv) { usage(); break; case 'v': - version = atoi(argv[0]+2); + version = atoi(argv[i]+2); break; default: usage(); @@ -414,7 +506,8 @@ main(int argc, char ** argv) { } if (version == -1) { - if (PAGES <= V0_MAX_PAGES) + /* use version 1 as default, if possible */ + if (PAGES <= V0_MAX_PAGES && PAGES > V1_MAX_PAGES) version = 0; else if (linux_version_code() < MAKE_VERSION(2,1,117)) version = 0; diff --git a/disk-utils/raw.8 b/disk-utils/raw.8 index cb802166..4fd91fac 100644 --- a/disk-utils/raw.8 +++ b/disk-utils/raw.8 @@ -4,14 +4,14 @@ raw \- bind a Linux raw character device .SH SYNOPSIS .B raw -.I /dev/raw +.I /dev/raw/raw .PP .B raw -.I /dev/raw /dev/ +.I /dev/raw/raw /dev/ .PP .B raw .B \-q -.I /dev/raw +.I /dev/raw/raw .PP .B raw .B \-qa @@ -25,7 +25,7 @@ module later). .B raw is used in two modes: it either sets raw device bindings, or it queries existing bindings. When setting a raw device, -.I /dev/raw +.I /dev/raw/raw is the device name of an existing raw device node in the filesystem. The block device to which it is to be bound can be specified either in terms of its diff --git a/disk-utils/raw.c b/disk-utils/raw.c index 5fb95348..54e1008c 100644 --- a/disk-utils/raw.c +++ b/disk-utils/raw.c @@ -1,12 +1,12 @@ /* * raw.c: User mode tool to bind and query raw character devices. * - * Stephen Tweedie, 1999 + * Stephen Tweedie, 1999, 2000 * * This file may be redistributed under the terms of the GNU General * Public License, version 2. * - * Copyright Red Hat Software, 1999 + * Copyright Red Hat Software, 1999, 2000 * */ @@ -19,8 +19,16 @@ #include #include #include -#include +#include +#include +#ifdef OLD_RAW_DEVS +#define RAWCTLDEV "/dev/raw" +#define RAWDEVDIR "/dev/" +#else +#define RAWCTLDEV "/dev/rawctl" +#define RAWDEVDIR "/dev/raw/" +#endif char * progname; @@ -39,9 +47,9 @@ static void usage(int err) { fprintf(stderr, "Usage:\n" - " %s /dev/rawN \n" - " %s /dev/rawN /dev/\n" - " %s -q /dev/rawN\n" + " %s " RAWDEVDIR "rawN \n" + " %s " RAWDEVDIR "rawN /dev/\n" + " %s -q " RAWDEVDIR "rawN\n" " %s -qa\n", progname, progname, progname, progname); exit(err); @@ -164,10 +172,10 @@ int main(int argc, char *argv[]) void open_raw_ctl(void) { - master_fd = open("/dev/raw", O_RDWR, 0); + master_fd = open(RAWCTLDEV, O_RDWR, 0); if (master_fd < 0) { fprintf (stderr, - "Cannot open master raw device '/dev/raw' (%s)\n", + "Cannot open master raw device '" RAWCTLDEV "' (%s)\n", strerror(errno)); exit(2); } @@ -190,7 +198,7 @@ int query(int minor, int quiet) } if (quiet && !rq.block_major && !rq.block_minor) return 0; - printf ("/dev/raw%d: bound to major %d, minor %d\n", + printf (RAWDEVDIR "raw%d: bound to major %d, minor %d\n", minor, (int) rq.block_major, (int) rq.block_minor); return 0; } @@ -210,7 +218,7 @@ int bind(int minor, int block_major, int block_minor) strerror(errno)); exit(3); } - printf ("/dev/raw%d: bound to major %d, minor %d\n", + printf (RAWDEVDIR "raw%d: bound to major %d, minor %d\n", raw_minor, (int) rq.block_major, (int) rq.block_minor); return 0; } diff --git a/fdisk/Makefile b/fdisk/Makefile index 873b2850..a319c2ba 100644 --- a/fdisk/Makefile +++ b/fdisk/Makefile @@ -59,14 +59,14 @@ activate: sfdisk ln -s sfdisk activate fdisk: fdisk.o llseek.o fdiskbsdlabel.o fdisksgilabel.o fdisksunlabel.o \ - fdiskaixlabel.o i386_sys_types.o + fdiskaixlabel.o i386_sys_types.o partname.o fdisk.o: fdisk.c fdisk.h fdiskbsdlabel.o: fdiskbsdlabel.c fdisk.h fdiskbsdlabel.h fdisksunlabel.o: fdisksunlabel.c fdisksunlabel.h fdisk.h fdiskaixlabel.o: fdiskaixlabel.c fdiskaixlabel.h fdisk.h fdisk.o cfdisk.o sfdisk.o fdiskbsdlabel.o fdisksunlabel.o \ - fdisksgilabel.o fdiskaixlabel.o i386_sys_types.o: common.h -sfdisk: sfdisk.o i386_sys_types.o + fdisksgilabel.o fdiskaixlabel.o i386_sys_types.o partname.o: common.h +sfdisk: sfdisk.o i386_sys_types.o partname.o install: all $(INSTALLDIR) $(SBINDIR) @@ -76,4 +76,4 @@ install: all .PHONY: clean clean: - -rm -f *.o *~ core $(SBIN) addpart delpart + -rm -f *.o *~ core $(SBIN) diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c index 4d0eb7ea..055046d7 100644 --- a/fdisk/cfdisk.c +++ b/fdisk/cfdisk.c @@ -74,7 +74,6 @@ #include #include #include -#include /* for BLKRRPART, BLKGETSIZE */ #include "nls.h" #include "common.h" @@ -206,7 +205,7 @@ int kern_heads = 0, kern_sectors = 0; int pt_heads = 0, pt_sectors = 0; -void +static void set_hsc0(unsigned char *h, unsigned char *s, int *c, int sector) { if (sector >= 1024*cylinder_size) sector = 1024*cylinder_size - 1; @@ -217,7 +216,7 @@ set_hsc0(unsigned char *h, unsigned char *s, int *c, int sector) { *c = sector; } -void +static void set_hsc(unsigned char *h, unsigned char *s, unsigned char *c, int sector) { int cc; @@ -226,12 +225,12 @@ set_hsc(unsigned char *h, unsigned char *s, unsigned char *c, int sector) { *s |= (cc >> 2) & 0xC0; } -void +static void set_hsc_begin(struct partition *p, int sector) { set_hsc(& p->head, & p->sector, & p->cyl, sector); } -void +static void set_hsc_end(struct partition *p, int sector) { set_hsc(& p->end_head, & p->end_sector, & p->end_cyl, sector); } @@ -246,7 +245,7 @@ set_hsc_end(struct partition *p, int sector) { /* start_sect and nr_sects are stored little endian on all machines */ /* moreover, they are not aligned correctly */ -void +static void store4_little_endian(unsigned char *cp, unsigned int val) { cp[0] = (val & 0xff); cp[1] = ((val >> 8) & 0xff); @@ -254,28 +253,28 @@ store4_little_endian(unsigned char *cp, unsigned int val) { cp[3] = ((val >> 24) & 0xff); } -unsigned int +static unsigned int read4_little_endian(unsigned char *cp) { return (uint)(cp[0]) + ((uint)(cp[1]) << 8) + ((uint)(cp[2]) << 16) + ((uint)(cp[3]) << 24); } -void +static void set_start_sect(struct partition *p, unsigned int start_sect) { store4_little_endian(p->start4, start_sect); } -unsigned int +static unsigned int get_start_sect(struct partition *p) { return read4_little_endian(p->start4); } -void +static void set_nr_sects(struct partition *p, unsigned int nr_sects) { store4_little_endian(p->size4, nr_sects); } -unsigned int +static unsigned int get_nr_sects(struct partition *p) { return read4_little_endian(p->size4); } @@ -353,11 +352,11 @@ int LABEL_START = 54; int SIZE_START = 70; int COMMAND_LINE_X = 5; -void die_x(int ret); -void draw_screen(void); +static void die_x(int ret); +static void draw_screen(void); /* Guaranteed alloc */ -void * +static void * xmalloc (size_t size) { void *t; @@ -373,14 +372,14 @@ xmalloc (size_t size) { } /* Some libc's have their own basename() */ -char *my_basename(char *devname) -{ +static char * +my_basename(char *devname) { char *s = rindex(devname, '/'); return s ? s+1 : devname; } -char *partition_type_name(unsigned char type) -{ +static char * +partition_type_name(unsigned char type) { struct systypes *s = i386_sys_types; while(s->name && s->type != type) @@ -388,8 +387,8 @@ char *partition_type_name(unsigned char type) return s->name; } -char *partition_type_text(int i) -{ +static char * +partition_type_text(int i) { if (p_info[i].id == UNUSABLE) return _("Unusable"); else if (p_info[i].id == FREE_SPACE) @@ -412,8 +411,8 @@ char *partition_type_text(int i) return partition_type_name(p_info[i].id); } -void fdexit(int ret) -{ +static void +fdexit(int ret) { if (opened) close(fd); @@ -430,8 +429,8 @@ void fdexit(int ret) exit(ret); } -int get_string(char *str, int len, char *def) -{ +static int +get_string(char *str, int len, char *def) { char c; int i = 0; int x, y; @@ -489,8 +488,8 @@ int get_string(char *str, int len, char *def) return i; } -void clear_warning(void) -{ +static void +clear_warning(void) { int i; if (!curses_started || !warning_last_time) @@ -503,8 +502,8 @@ void clear_warning(void) warning_last_time = FALSE; } -void print_warning(char *s) -{ +static void +print_warning(char *s) { if (!curses_started) { fprintf(stderr, "%s\n", s); } else { @@ -515,8 +514,8 @@ void print_warning(char *s) } } -void fatal(char *s, int ret) -{ +static void +fatal(char *s, int ret) { char *err = _("FATAL ERROR"); if (curses_started) { @@ -538,13 +537,13 @@ void fatal(char *s, int ret) } } -void die(int dummy) -{ +static void +die(int dummy) { die_x(0); } -void die_x(int ret) -{ +static void +die_x(int ret) { signal(SIGINT, old_SIGINT); signal(SIGTERM, old_SIGTERM); #ifdef SLCURSES @@ -559,23 +558,24 @@ void die_x(int ret) fdexit(ret); } -void read_sector(char *buffer, int sect_num) -{ +static void +read_sector(char *buffer, int sect_num) { if (ext2_llseek(fd, ((ext2_loff_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0) fatal(_("Cannot seek on disk drive"), 2); if (read(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE) fatal(_("Cannot read disk drive"), 2); } -void write_sector(char *buffer, int sect_num) -{ +static void +write_sector(char *buffer, int sect_num) { if (ext2_llseek(fd, ((ext2_loff_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0) fatal(_("Cannot seek on disk drive"), 2); if (write(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE) fatal(_("Cannot write disk drive"), 2); } -void dos_copy_to_info(char *to, int tosz, char *from, int fromsz) { +static void +dos_copy_to_info(char *to, int tosz, char *from, int fromsz) { int i; for(i=0; i i; p--) @@ -750,8 +750,8 @@ void insert_empty_part(int i, int first, int last) num_parts++; } -void del_part(int i) -{ +static void +del_part(int i) { int num = p_info[i].num; if (i > 0 && (p_info[i-1].id == FREE_SPACE || @@ -805,9 +805,9 @@ void del_part(int i) check_part_info(); } -int add_part(int num, int id, int flags, int first, int last, int offset, - int want_label, char **errmsg) -{ +static int +add_part(int num, int id, int flags, int first, int last, int offset, + int want_label, char **errmsg) { int i, pri = 0, log = 0; if (num_parts == MAXIMUM_PARTS) { @@ -952,8 +952,8 @@ int add_part(int num, int id, int flags, int first, int last, int offset, return 0; } -int find_primary(void) -{ +static int +find_primary(void) { int num = 0, cur = 0; while (cur < num_parts && IS_PRIMARY(num)) @@ -970,8 +970,8 @@ int find_primary(void) return num; } -int find_logical(int i) -{ +static int +find_logical(int i) { int num = -1; int j; @@ -989,8 +989,8 @@ int find_logical(int i) return num; } -void inc_logical(int i) -{ +static void +inc_logical(int i) { int j; for (j = i; j < num_parts; j++) @@ -1025,9 +1025,9 @@ struct MenuItem * Should not be called directly. Call function menuSelect instead. */ -int menuUpdate( int y, int x, struct MenuItem *menuItems, int itemLength, - char *available, int menuType, int current ) -{ +static int +menuUpdate( int y, int x, struct MenuItem *menuItems, int itemLength, + char *available, int menuType, int current ) { int i, lmargin = x, ymargin = y; char *mcd; @@ -1112,9 +1112,9 @@ int menuUpdate( int y, int x, struct MenuItem *menuItems, int itemLength, /* This function takes a list of menu items, lets the user choose one * * and returns the value keyboard shortcut of the selected menu item */ -int menuSelect( int y, int x, struct MenuItem *menuItems, int itemLength, - char *available, int menuType, int menuDefault ) -{ +static int +menuSelect( int y, int x, struct MenuItem *menuItems, int itemLength, + char *available, int menuType, int menuDefault ) { int i, ylast = y, key = 0, current = menuDefault; if( !( menuType & ( MENU_HORIZ | MENU_VERT ) ) ) @@ -1268,8 +1268,8 @@ int menuSelect( int y, int x, struct MenuItem *menuItems, int itemLength, * and waits for a keypress. * * Perhaps calling function menuSelect is a bit overkill but who cares? */ -void menuContinue(void) -{ +static void +menuContinue(void) { static struct MenuItem menuContinueBtn[]= { { 'c', "", N_("Press a key to continue") }, @@ -1283,8 +1283,8 @@ void menuContinue(void) /* Function menuSelect takes way too many parameters * * Luckily, most of time we can do with this function */ -int menuSimple(struct MenuItem *menuItems, int menuDefault) -{ +static int +menuSimple(struct MenuItem *menuItems, int menuDefault) { int i, j, itemLength = 0; char available[MENU_MAX_ITEMS]; @@ -1301,8 +1301,8 @@ int menuSimple(struct MenuItem *menuItems, int menuDefault) /* End of command menu support code */ -void new_part(int i) -{ +static void +new_part(int i) { char response[LINE_LENGTH], def[LINE_LENGTH]; char c; int first = p_info[i].first_sector; @@ -1411,8 +1411,8 @@ void new_part(int i) (void) add_part(num, id, flags, first, last, offset, 0, &errmsg); } -void get_kernel_geometry(void) -{ +static void +get_kernel_geometry(void) { #ifdef HDIO_GETGEO struct hd_geometry geometry; @@ -1423,8 +1423,8 @@ void get_kernel_geometry(void) #endif } -void get_partition_table_geometry(partition_table *bufp) -{ +static void +get_partition_table_geometry(partition_table *bufp) { struct partition *p; int i,h,s,hh,ss; int first = TRUE; @@ -1455,8 +1455,8 @@ void get_partition_table_geometry(partition_table *bufp) } } -void decide_on_geometry(void) -{ +static void +decide_on_geometry(void) { heads = (user_heads ? user_heads : pt_heads ? pt_heads : kern_heads ? kern_heads : 255); @@ -1473,8 +1473,8 @@ void decide_on_geometry(void) print_warning(_("You specified more cylinders than fit on disk")); } -void clear_p_info(void) -{ +static void +clear_p_info(void) { num_parts = 1; p_info[0].first_sector = 0; p_info[0].last_sector = total_size - 1; @@ -1491,8 +1491,8 @@ void clear_p_info(void) ext_info.num = PRIMARY; } -void fill_p_info(void) -{ +static void +fill_p_info(void) { int pn, i, bs, bsz; struct partition *p; partition_table buffer; @@ -1602,8 +1602,8 @@ void fill_p_info(void) } } -void fill_part_table(struct partition *p, partition_info *pi) -{ +static void +fill_part_table(struct partition *p, partition_info *pi) { int begin; p->boot_ind = pi->flags; @@ -1618,8 +1618,8 @@ void fill_part_table(struct partition *p, partition_info *pi) set_hsc_end(p, pi->last_sector); } -void fill_primary_table(partition_table *buffer) -{ +static void +fill_primary_table(partition_table *buffer) { int i; /* Zero out existing table */ @@ -1637,8 +1637,8 @@ void fill_primary_table(partition_table *buffer) buffer->p.magicflag[1] = PART_TABLE_FLAG1; } -void fill_logical_table(partition_table *buffer, partition_info *pi) -{ +static void +fill_logical_table(partition_table *buffer, partition_info *pi) { struct partition *p; int i; @@ -1674,8 +1674,8 @@ void fill_logical_table(partition_table *buffer, partition_info *pi) buffer->p.magicflag[1] = PART_TABLE_FLAG1; } -void write_part_table(void) -{ +static void +write_part_table(void) { int i, ct, done = FALSE, len; partition_table buffer; struct stat s; @@ -1755,8 +1755,8 @@ void write_part_table(void) print_warning(_("Not precisely one primary partition is bootable. DOS MBR cannot boot this.")); } -void fp_printf(FILE *fp, char *format, ...) -{ +static void +fp_printf(FILE *fp, char *format, ...) { va_list args; char buf[1024]; int y, x; @@ -1780,8 +1780,8 @@ void fp_printf(FILE *fp, char *format, ...) } #define MAX_PER_LINE 16 -void print_file_buffer(FILE *fp, char *buffer) -{ +static void +print_file_buffer(FILE *fp, char *buffer) { int i,l; for (i = 0, l = 0; i < SECTOR_SIZE; i++, l++) { @@ -1798,8 +1798,8 @@ void print_file_buffer(FILE *fp, char *buffer) fp_printf(fp, "\n"); } -void print_raw_table(void) -{ +static void +print_raw_table(void) { int i, to_file; partition_table buffer; char fname[LINE_LENGTH]; @@ -1852,8 +1852,8 @@ void print_raw_table(void) } } -void print_p_info_entry(FILE *fp, partition_info *p) -{ +static void +print_p_info_entry(FILE *fp, partition_info *p) { int size; char part_str[40]; @@ -1917,8 +1917,8 @@ void print_p_info_entry(FILE *fp, partition_info *p) fp_printf(fp, "\n"); } -void print_p_info(void) -{ +static void +print_p_info(void) { char fname[LINE_LENGTH]; FILE *fp; int i, to_file, pext = is_extended(ext_info.id); @@ -1969,8 +1969,8 @@ void print_p_info(void) } } -void print_part_entry(FILE *fp, int num, partition_info *pi) -{ +static void +print_part_entry(FILE *fp, int num, partition_info *pi) { int first = 0, start = 0, end = 0, size = 0; unsigned char ss, es, sh, eh; int sc, ec; @@ -2001,8 +2001,8 @@ void print_part_entry(FILE *fp, int num, partition_info *pi) } -void print_part_table(void) -{ +static void +print_part_table(void) { int i, j, to_file; char fname[LINE_LENGTH]; FILE *fp; @@ -2062,8 +2062,8 @@ void print_part_table(void) } } -void print_tables(void) -{ +static void +print_tables(void) { int done = FALSE; static struct MenuItem menuFormat[]= @@ -2096,8 +2096,8 @@ void print_tables(void) } #define END_OF_HELP "EOHS!" -void display_help() -{ +static void +display_help(void) { char *help_text[] = { N_("Help Screen for cfdisk"), "", @@ -2158,8 +2158,8 @@ void display_help() menuContinue(); } -int change_geometry(void) -{ +static int +change_geometry(void) { int ret_val = FALSE; int done = FALSE; char def[LINE_LENGTH]; @@ -2277,8 +2277,8 @@ int change_geometry(void) return ret_val; } -void change_id(int i) -{ +static void +change_id(int i) { char id[LINE_LENGTH], def[LINE_LENGTH]; int num_types = 0; int num_across, num_down; @@ -2351,8 +2351,8 @@ void change_id(int i) p_info[i].id = new_id; } -void draw_partition(int i) -{ +static void +draw_partition(int i) { int size, j; int y = i + DISK_TABLE_START + 2 - (cur_part/NUM_ON_SCREEN)*NUM_ON_SCREEN; char *t; @@ -2429,8 +2429,8 @@ void draw_partition(int i) mvprintw(y, COLUMNS-1, "*"); } -void init_const(void) -{ +static void +init_const(void) { if (!defined) { NAME_START = (((float)NAME_START)/COLUMNS)*COLS; FLAGS_START = (((float)FLAGS_START)/COLUMNS)*COLS; @@ -2451,8 +2451,8 @@ void init_const(void) } } -void draw_screen(void) -{ +static void +draw_screen(void) { int i; char *line; @@ -2514,8 +2514,8 @@ void draw_screen(void) free(line); } -int draw_cursor(int move) -{ +static int +draw_cursor(int move) { if (move != 0 && (cur_part + move < 0 || cur_part + move >= num_parts)) return -1; @@ -2543,8 +2543,8 @@ int draw_cursor(int move) return 0; } -void do_curses_fdisk(void) -{ +static void +do_curses_fdisk(void) { int done = FALSE; char command; @@ -2713,13 +2713,13 @@ void do_curses_fdisk(void) die_x(0); } -void copyright(void) -{ - fprintf(stderr, _("Copyright (C) 1994-1999 Kevin E. Martin & aeb\n")); +static void +copyright(void) { + fprintf(stderr, _("Copyright (C) 1994-2000 Kevin E. Martin & aeb\n")); } -void usage(char *prog_name) -{ +static void +usage(char *prog_name) { /* Unfortunately, xgettext does not handle multi-line strings */ /* so, let's use explicit \n's instead */ fprintf(stderr, _("\n" diff --git a/fdisk/common.h b/fdisk/common.h index a79d9acc..c5e23714 100644 --- a/fdisk/common.h +++ b/fdisk/common.h @@ -1,5 +1,11 @@ /* common stuff for fdisk, cfdisk, sfdisk */ +/* including fails */ +#include +#define BLKRRPART _IO(0x12,95) /* re-read partition table */ +#define BLKGETSIZE _IO(0x12,96) /* return device size */ +#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */ + struct systypes { unsigned char type; char *name; @@ -7,3 +13,4 @@ struct systypes { extern struct systypes i386_sys_types[]; +extern char *partname(char *dev, int pno, int lth); diff --git a/fdisk/fdisk.8 b/fdisk/fdisk.8 index 2a8c85e8..aad93987 100644 --- a/fdisk/fdisk.8 +++ b/fdisk/fdisk.8 @@ -5,9 +5,9 @@ .SH NAME fdisk \- Partition table manipulator for Linux .SH SYNOPSIS -.BI "fdisk [\-u] " device +.BI "fdisk [\-u] [\-b sectorsize]" device .sp -.BI "fdisk \-l [\-u] [" "device ..." ] +.BI "fdisk \-l [\-u] [\-b sectorsize] [" "device ..." ] .sp .BI "fdisk \-s " "partition ..." .sp @@ -169,10 +169,10 @@ program and Linux partitions with the Linux fdisk or Linux cfdisk program. .SH OPTIONS .TP -.B \-v -Print version number of -.B fdisk -program and exit. +.BI "\-b " sectorsize +Specify the sector size of the disk. Valid values are 512, 1024, or 2048. +(Recent kernels know the sector size. Use this only on old kernels or +to override the kernel's ideas.) .TP .B \-l List the partition tables for the specified devices and then exit. @@ -188,6 +188,11 @@ of cylinders. The .I size of the partition (in blocks) is printed on the standard output. +.TP +.B \-v +Print version number of +.B fdisk +program and exit. .SH BUGS There are several *fdisk programs around. Each has its problems and strengths. diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index 56caa9a1..45110ccd 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -7,81 +7,27 @@ * published by the Free Software Foundation: either version 1 or * (at your option) any later version. * - * Before Linux version 0.95c, this program requires a kernel patch. - * - * Modified, Tue Feb 2 18:46:49 1993, faith@cs.unc.edu to better support SCSI. - * Modified, Sat Feb 27 18:11:27 1993, faith@cs.unc.edu: added extfs support. - * Modified, Sat Mar 6 10:14:12 1993, faith@cs.unc.edu: added more comments. - * Modified, Sat Mar 6 12:25:45 1993, faith@cs.unc.edu: - * Added patches from Michael Bischoff (i1041905@ws.rz.tu-bs.de - * or mbi@mo.math.nat.tu-bs.de) to fix the following problems: - * 1) Incorrect mapping of head/sector/cylinder to absolute sector - * 2) Odd sector count causes one sector to be lost - * Modified, Sat Mar 6 12:25:52 1993, faith@cs.unc.edu: improved verification. - * Modified, Sat Apr 17 15:00:00 1993, LeBlanc@mcc.ac.uk: add -s, fix -l. - * Modified, Sat Apr 24 10:00:00 1993, LeBlanc@mcc.ac.uk: fix overlap bug. - * Modified, Wed May 5 21:30:00 1993, LeBlanc@mcc.ac.uk: errors to stderr. - * Modified, Mon Mar 21 20:00:00 1994, LeBlanc@mcc.ac.uk: - * more stderr for messages, avoid division by 0, and - * give reboot message only if ioctl(fd, BLKRRPART) fails. - * Modified, Mon Apr 25 01:01:05 1994, martin@cs.unc.edu: - * 1) Added support for DOS, OS/2, ... compatibility. We should be able - * use this fdisk to partition our drives for other operating systems. - * 2) Added a print the raw data in the partition table command. - * Modified, Wed Jun 22 21:05:30 1994, faith@cs.unc.edu: - * Added/changed a few partition type names to conform to cfdisk. - * (suggested by Sujal, smpatel@wam.umd.edu) - * Modified 3/5/95 leisner@sdsp.mc.xerox.com -- on -l only open - * devices RDONLY (instead of RDWR). This allows you to - * have the disks as rw-r----- with group disk (and if you - * want is safe to setguid fdisk to disk). - * Modified Sat Mar 11 10:02 1995 with more partition types, faith@cs.unc.edu - * Modified, Thu May 4 01:11:45 1995, esr@snark.thyrsus.com: - * It's user-interface cleanup time. - * Actual error messages for out-of-bounds values (what a concept!). - * Enable read-only access to partition table for learners. - * Smart defaults for most numeric prompts. - * Fixed a bug preventing a partition from crossing cylinder 8064, aeb, 950801. - * Read partition table twice to avoid kernel bug - * (from Daniel Quinlan ), Tue Sep 26 10:25:28 1995 - * Modified, Sat Jul 1 23:43:16 MET DST 1995, fasten@cs.bonn.edu: - * editor for NetBSD/i386 (and Linux/Alpha?) disklabels. - * Tue Sep 26 17:07:54 1995: More patches from aeb. Fix segfaults, all >4GB. - * Don't destroy random data if extd partition starts past 4GB, aeb, 950818. - * Don't segfault on bad partition created by previous fdisk. - * Fixed for using variable blocksizes (needed by magnet-optical drive-patch) - * (from orschaer@cip.informatik.uni-erlangen.de) - * Modified, Fri Jul 14 11:13:35 MET DST 1996, jj@sunsite.mff.cuni.cz: - * editor for Sun disklabels. - * Modified, Wed Jul 3 10:14:17 MET DST 1996, jj@sunsite.mff.cuni.cz: - * support for Sun floppies - * Modified, Thu Jul 24 16:42:33 MET DST 1997, fasten@shw.com: - * LINUX_EXTENDED support - * Added Windows 95 partition types, aeb. - * Fixed a bug described by johnf@whitsunday.net.au, aeb, 980408. - * [There are lots of other bugs - nobody should use this program] - * [cfdisk on the other hand is nice and correct] - * Try to avoid reading a CD-ROM. - * Do not print Begin column -- it confuses too many people -- aeb, 980610. - * Modified, Sat Oct 3 14:40:17 MET DST 1998, ANeuper@GUUG.de - * Support SGI's partitioning -- an, 980930. - * Do the verify using LBA, not CHS, limits -- aeb, 981206. - * Corrected single-cylinder partition creating a little, now that - * ankry@mif.pg.gda.pl pointed out a bug; there are more bugs -- aeb, 990214. + * For detailed old history, see older versions. + * Contributions before 2000 by faith@cs.unc.edu, Michael Bischoff, + * LeBlanc@mcc.ac.uk, martin@cs.unc.edu, leisner@sdsp.mc.xerox.com, + * esr@snark.thyrsus.com, aeb@cwi.nl, quinlan@yggdrasil.com, + * fasten@cs.bonn.edu, orschaer@cip.informatik.uni-erlangen.de, + * jj@sunsite.mff.cuni.cz, fasten@shw.com, ANeuper@GUUG.de, + * kgw@suse.de. * - * Sat Mar 20 09:31:05 EST 1999 Arnaldo Carvalho de Melo - * Internationalization + * Modified, Sun Feb 20 2000, kalium@gmx.de + * Added fix operation allowing to reorder primary/extended partition + * entries within the partition table. Some programs or OSes have + * problems using a partition table with entries not ordered + * according to their positions on disk. + * Munged this patch to also make it work for logical partitions. + * aeb, 2000-02-20. * - * Corrected deleting last logical partition -- aeb, 990430. - * Removed all assumptions on file names -- aeb, 990709 - * [modprobe gave ugly error messages, and the number of devices to probe - * increased all the time: hda, sda, eda, rd/c0d0, ida/c0d0, ... - * Also partition naming was very ugly.] + * Wed Mar 1 14:34:53 EST 2000 David Huggins-Daines + * Better support for OSF/1 disklabels on Alpha. * - * Corrected a bug where creating an extended hda3, say, then a logical hda5 - * that does not start at the beginning of hda3, then a logical hda6 that does - * start at the beginning of hda3 would wipe out the partition table describing - * hda5. [Patch by Klaus G. Wagner" ] -- aeb, 990711 + * 2000-04-06, Michal Jaegermann (michal@ellpspace.math.ualberta.ca) + * fixed and added some alpha stuff. */ @@ -94,14 +40,11 @@ #include #include #include -#include "nls.h" - #include -#include #include /* for HDIO_GETGEO */ -#include /* for BLKRRPART, BLKGETSIZE */ +#include "nls.h" #include "common.h" #include "fdisk.h" @@ -122,7 +65,7 @@ #define LINE_LENGTH 80 -#define offset(b, n) ((struct partition *)((b) + 0x1be + \ +#define pt_offset(b, n) ((struct partition *)((b) + 0x1be + \ (n) * sizeof(struct partition))) #define sector(s) ((s) & 0x3f) #define cylinder(s, c) ((c) | (((s) & 0xc0) << 2)) @@ -139,7 +82,7 @@ } /* A valid partition table sector ends in 0x55 0xaa */ -unsigned int +static unsigned int part_table_flag(char *b) { return ((uint) b[510]) + (((uint) b[511]) << 8); } @@ -149,7 +92,7 @@ valid_part_table_flag(unsigned char *b) { return (b[510] == 0x55 && b[511] == 0xaa); } -void +static void write_part_table_flag(char *b) { b[510] = 0x55; b[511] = 0xaa; @@ -157,7 +100,7 @@ write_part_table_flag(char *b) { /* start_sect and nr_sects are stored little endian on all machines */ /* moreover, they are not aligned correctly */ -void +static void store4_little_endian(unsigned char *cp, unsigned int val) { cp[0] = (val & 0xff); cp[1] = ((val >> 8) & 0xff); @@ -165,13 +108,13 @@ store4_little_endian(unsigned char *cp, unsigned int val) { cp[3] = ((val >> 24) & 0xff); } -unsigned int +static unsigned int read4_little_endian(unsigned char *cp) { return (uint)(cp[0]) + ((uint)(cp[1]) << 8) + ((uint)(cp[2]) << 16) + ((uint)(cp[3]) << 24); } -void +static void set_start_sect(struct partition *p, unsigned int start_sect) { store4_little_endian(p->start4, start_sect); } @@ -181,7 +124,7 @@ get_start_sect(struct partition *p) { return read4_little_endian(p->start4); } -void +static void set_nr_sects(struct partition *p, unsigned int nr_sects) { store4_little_endian(p->size4, nr_sects); } @@ -194,13 +137,31 @@ get_nr_sects(struct partition *p) { /* normally O_RDWR, -l option gives O_RDONLY */ static int type_open = O_RDWR; +/* + * Raw disk label. For DOS-type partition tables the MBR, + * with descriptions of the primary partitions. + */ +char MBRbuffer[MAX_SECTOR_SIZE]; + +/* + * per partition table entry data + * + * The four primary partitions have the same sectorbuffer (MBRbuffer) + * and have NULL ext_pointer. + * Each logical partition table entry has two pointers, one for the + * partition and one link to the next one. + */ +struct pte { + struct partition *part_table; /* points into sectorbuffer */ + struct partition *ext_pointer; /* points into sectorbuffer */ + char changed; /* boolean */ + uint offset; /* disk sector number */ + char *sectorbuffer; /* disk sector contents */ +} ptes[MAXIMUM_PARTS]; + char *disk_device, /* must be specified */ *line_ptr, /* interactive input */ - line_buffer[LINE_LENGTH], - changed[MAXIMUM_PARTS], /* marks changed buffers */ - buffer[MAX_SECTOR_SIZE], /* first four partitions */ - *buffers[MAXIMUM_PARTS] /* pointers to buffers */ - = {buffer, buffer, buffer, buffer}; + line_buffer[LINE_LENGTH]; int fd, /* the disk */ ext_index, /* the prime extended partition */ @@ -209,6 +170,8 @@ int fd, /* the disk */ dos_compatible_flag = ~0, partitions = 4; /* maximum partition + 1 */ +uint user_cylinders, user_heads, user_sectors; + uint heads, sectors, cylinders, @@ -216,23 +179,16 @@ uint heads, sector_offset = 1, units_per_sector = 1, display_in_cyl_units = 1, - extended_offset = 0, /* offset of link pointers */ - offsets[MAXIMUM_PARTS] = {0, 0, 0, 0}; + extended_offset = 0; /* offset of link pointers */ +#define dos_label (!sun_label && !sgi_label && !aix_label && !osf_label) int sun_label = 0; /* looking at sun disklabel */ int sgi_label = 0; /* looking at sgi disklabel */ int aix_label = 0; /* looking at aix disklabel */ - -struct partition *part_table[MAXIMUM_PARTS] /* partitions */ - = {offset(buffer, 0), offset(buffer, 1), - offset(buffer, 2), offset(buffer, 3)}, - *ext_pointers[MAXIMUM_PARTS] /* link pointers */ - = {NULL, NULL, NULL, NULL}; - +int osf_label = 0; /* looking at osf disklabel */ jmp_buf listingbuf; -void fatal(enum failure why) -{ +void fatal(enum failure why) { char error[LINE_LENGTH], *message = error; @@ -289,8 +245,66 @@ void fatal(enum failure why) exit(1); } -void menu(void) -{ +static void +seek_sector(int fd, uint secno) { + ext2_loff_t offset = (ext2_loff_t) secno * sector_size; + if (ext2_llseek(fd, offset, SEEK_SET) == (ext2_loff_t) -1) + fatal(unable_to_seek); +} + +static void +read_sector(int fd, uint secno, char *buf) { + seek_sector(fd, secno); + if (read(fd, buf, sector_size) != sector_size) + fatal(unable_to_read); +} + +static void +write_sector(int fd, uint secno, char *buf) { + seek_sector(fd, secno); + if (write(fd, buf, sector_size) != sector_size) + fatal(unable_to_write); +} + +/* Allocate a buffer and read a partition table sector */ +static void +read_pte(int fd, int pno, uint offset) { + struct pte *pe = &ptes[pno]; + + pe->offset = offset; + pe->sectorbuffer = (char *) malloc(sector_size); + if (!pe->sectorbuffer) + fatal(out_of_memory); + read_sector(fd, offset, pe->sectorbuffer); + pe->changed = 0; + pe->part_table = pe->ext_pointer = NULL; +} + +static unsigned int +get_partition_start(struct pte *pe) { + return pe->offset + get_start_sect(pe->part_table); +} + +struct partition * +get_part_table(int i) { + return ptes[i].part_table; +} + +void +set_all_unchanged(void) { + int i; + + for (i = 0; i < MAXIMUM_PARTS; i++) + ptes[i].changed = 0; +} + +void +set_changed(int i) { + ptes[i].changed = 1; +} + +static void +menu(void) { if (sun_label) { puts(_("Command action")); puts(_(" a toggle a read only flag")); /* sun */ @@ -356,11 +370,11 @@ void menu(void) } } -void xmenu(void) -{ +static void +xmenu(void) { if (sun_label) { puts(_("Command action")); - puts(_(" a change number of alternate cylinders")); /*sun*/ + puts(_(" a change number of alternate cylinders")); /*sun*/ puts(_(" c change number of cylinders")); puts(_(" d print the raw data in the partition table")); puts(_(" e change number of extra sectors per cylinder"));/*sun*/ @@ -376,12 +390,45 @@ void xmenu(void) puts(_(" w write table to disk and exit")); puts(_(" y change number of physical cylinders")); /*sun*/ } + else if(sgi_label) { + puts(_("Command action")); + puts(_(" b move beginning of data in a partition")); /* !sun */ + puts(_(" c change number of cylinders")); + puts(_(" d print the raw data in the partition table")); + puts(_(" e list extended partitions")); /* !sun */ + puts(_(" g create an IRIX partition table")); /* sgi */ + puts(_(" h change number of heads")); + puts(_(" m print this menu")); + puts(_(" p print the partition table")); + puts(_(" q quit without saving changes")); + puts(_(" r return to main menu")); + puts(_(" s change number of sectors/track")); + puts(_(" v verify the partition table")); + puts(_(" w write table to disk and exit")); + } + else if(aix_label) { + puts(_("Command action")); + puts(_(" b move beginning of data in a partition")); /* !sun */ + puts(_(" c change number of cylinders")); + puts(_(" d print the raw data in the partition table")); + puts(_(" e list extended partitions")); /* !sun */ + puts(_(" g create an IRIX partition table")); /* sgi */ + puts(_(" h change number of heads")); + puts(_(" m print this menu")); + puts(_(" p print the partition table")); + puts(_(" q quit without saving changes")); + puts(_(" r return to main menu")); + puts(_(" s change number of sectors/track")); + puts(_(" v verify the partition table")); + puts(_(" w write table to disk and exit")); + } else { puts(_("Command action")); puts(_(" b move beginning of data in a partition")); /* !sun */ puts(_(" c change number of cylinders")); puts(_(" d print the raw data in the partition table")); puts(_(" e list extended partitions")); /* !sun */ + puts(_(" f fix partition order")); /* !sun, !aix, !sgi */ puts(_(" g create an IRIX partition table")); /* sgi */ puts(_(" h change number of heads")); puts(_(" m print this menu")); @@ -391,17 +438,17 @@ void xmenu(void) puts(_(" s change number of sectors/track")); puts(_(" v verify the partition table")); puts(_(" w write table to disk and exit")); - } + } } -int +static int get_sysid(int i) { return ( sun_label ? sunlabel->infos[i].id : - sgi_label ? sgi_get_sysid(i) : part_table[i]->sys_ind); + sgi_label ? sgi_get_sysid(i) : ptes[i].part_table->sys_ind); } -struct systypes * +static struct systypes * get_sys_types(void) { return ( sun_label ? sun_sys_types : @@ -444,8 +491,10 @@ void list_types(struct systypes *sys) putchar('\n'); } -void clear_partition(struct partition *p) -{ +static void +clear_partition(struct partition *p) { + if (!p) + return; p->boot_ind = 0; p->head = 0; p->sector = 0; @@ -458,9 +507,9 @@ void clear_partition(struct partition *p) set_nr_sects(p,0); } -void set_partition(int i, struct partition *p, uint start, uint stop, - int sysid, uint offset) -{ +static void +set_partition(int i, struct partition *p, uint start, uint stop, + int sysid, uint offset) { p->boot_ind = 0; p->sys_ind = sysid; set_start_sect(p, start - offset); @@ -471,11 +520,11 @@ void set_partition(int i, struct partition *p, uint start, uint stop, if (dos_compatible_flag && (stop/(sectors*heads) > 1023)) stop = heads*sectors*1024 - 1; set_hsc(p->end_head, p->end_sector, p->end_cyl, stop); - changed[i] = 1; + ptes[i].changed = 1; } -int test_c(char **m, char *mesg) -{ +static int +test_c(char **m, char *mesg) { int val = 0; if (!*m) fprintf(stderr, _("You must set")); @@ -487,8 +536,8 @@ int test_c(char **m, char *mesg) return val; } -int warn_geometry(void) -{ +static int +warn_geometry(void) { char *m = NULL; int prev = 0; if (!heads) @@ -515,85 +564,95 @@ void update_units(void) units_per_sector = 1; /* in sectors */ } -void warn_cylinders(void) -{ - if (!sun_label && !sgi_label && cylinders > 1024 && !nowarn) +static void +warn_cylinders(void) { + if (dos_label && cylinders > 1024 && !nowarn) fprintf(stderr, "\n\ The number of cylinders for this disk is set to %d.\n\ There is nothing wrong with that, but this is larger than 1024,\n\ and could in certain setups cause problems with:\n\ -1) software that runs at boot time (e.g., LILO)\n\ +1) software that runs at boot time (e.g., old versions of LILO)\n\ 2) booting and partitioning software from other OSs\n\ (e.g., DOS FDISK, OS/2 FDISK)\n", cylinders); } -void read_extended(struct partition *p) -{ +static void +read_extended(int ext) { int i; - struct partition *q; + struct pte *pex; + struct partition *p, *q; + + ext_index = ext; + pex = &ptes[ext]; + pex->ext_pointer = pex->part_table; - ext_pointers[ext_index] = part_table[ext_index]; + p = pex->part_table; if (!get_start_sect(p)) fprintf(stderr, _("Bad offset in primary extended partition\n")); else while (IS_EXTENDED (p->sys_ind)) { + struct pte *pe = &ptes[partitions]; + if (partitions >= MAXIMUM_PARTS) { /* This is not a Linux restriction, but this program uses arrays of size MAXIMUM_PARTS. Do not try to `improve' this test. */ + struct pte *pre = &ptes[partitions-1]; + fprintf(stderr, _("Warning: deleting partitions after %d\n"), partitions); - clear_partition(ext_pointers[partitions - 1]); - changed[partitions - 1] = 1; + clear_partition(pre->ext_pointer); + pre->changed = 1; return; } - offsets[partitions] = extended_offset + get_start_sect(p); + + read_pte(fd, partitions, extended_offset + get_start_sect(p)); + if (!extended_offset) extended_offset = get_start_sect(p); - if (ext2_llseek(fd, (ext2_loff_t)offsets[partitions] - * sector_size, SEEK_SET) < 0) - fatal(unable_to_seek); - if (!(buffers[partitions] = (char *) malloc(sector_size))) - fatal(out_of_memory); - if (sector_size != read(fd, buffers[partitions], sector_size)) - fatal(unable_to_read); - part_table[partitions] = ext_pointers[partitions] = NULL; - q = p = offset(buffers[partitions], 0); + + q = p = pt_offset(pe->sectorbuffer, 0); for (i = 0; i < 4; i++, p++) { if (IS_EXTENDED (p->sys_ind)) { - if (ext_pointers[partitions]) - fprintf(stderr, _("Warning: extra link " - "pointer in partition table " - "%d\n"), partitions + 1); + if (pe->ext_pointer) + fprintf(stderr, _("Warning: extra link" + " pointer in partition table " + "%d\n"), partitions + 1); else - ext_pointers[partitions] = p; + pe->ext_pointer = p; } else if (p->sys_ind) { - if (part_table[partitions]) + if (pe->part_table) fprintf(stderr, _("Warning: ignoring extra data " - "in partition table %d\n"), + "in partition table %d\n"), partitions + 1); else - part_table[partitions] = p; + pe->part_table = p; } } - if (!part_table[partitions]) { - if (q != ext_pointers[partitions]) - part_table[partitions] = q; - else part_table[partitions] = q + 1; + + /* very strange code here... */ + if (!pe->part_table) { + if (q != pe->ext_pointer) + pe->part_table = q; + else + pe->part_table = q + 1; } - if (!ext_pointers[partitions]) { - if (q != part_table[partitions]) - ext_pointers[partitions] = q; - else ext_pointers[partitions] = q + 1; + if (!pe->ext_pointer) { + if (q != pe->part_table) + pe->ext_pointer = q; + else + pe->ext_pointer = q + 1; } - p = ext_pointers[partitions++]; + + p = pe->ext_pointer; + partitions++; } } -void create_doslabel(void) -{ +static void +create_doslabel(void) { int i; fprintf(stderr, @@ -604,38 +663,17 @@ void create_doslabel(void) sun_nolabel(); /* otherwise always recognised as sun */ sgi_nolabel(); /* otherwise always recognised as sgi */ - write_part_table_flag(buffer); + write_part_table_flag(MBRbuffer); for (i = 0; i < 4; i++) - clear_partition(part_table[i]); - for (i = 1; i < MAXIMUM_PARTS; i++) - changed[i] = 0; - changed[0] = 1; + if (ptes[i].part_table) + clear_partition(ptes[i].part_table); + set_all_unchanged(); + set_changed(0); get_boot(create_empty); } -/* - * Read MBR. Returns: - * -1: no 0xaa55 flag present (possibly entire disk BSD) - * 0: found or created label - */ -int get_boot(enum action what) -{ - int i, sec_fac; - struct hd_geometry geometry; - - partitions = 4; - sec_fac = sector_size / 512; - - if (what == create_empty) - goto got_table; /* skip reading disk */ - - if ((fd = open(disk_device, type_open)) < 0) { - if ((fd = open(disk_device, O_RDONLY)) < 0) - fatal(unable_to_open); - else - printf(_("You will not be able to write the partition table.\n")); - } - +static void +get_sectorsize(int fd) { #if defined(BLKSSZGET) && defined(HAVE_blkpg_h) /* For a short while BLKSSZGET gave a wrong sector size */ { int arg; @@ -645,36 +683,95 @@ int get_boot(enum action what) printf(_("Note: sector size is %d (not %d)\n"), sector_size, DEFAULT_SECTOR_SIZE); } +#else + sector_size = DEFAULT_SECTOR_SIZE; #endif +} - guess_device_type(fd); +/* + * Ask kernel about geometry. Invent something reasonable + * in case the kernel has no opinion. + */ +void +get_geometry(int fd, struct geom *g) { + int sec_fac; + long longsectors; + struct hd_geometry geometry; + int res1, res2; - if (sector_size != read(fd, buffer, sector_size)) - fatal(unable_to_read); + get_sectorsize(fd); + sec_fac = sector_size / 512; + guess_device_type(fd); + + res1 = ioctl(fd, BLKGETSIZE, &longsectors); #ifdef HDIO_REQ - if (!ioctl(fd, HDIO_REQ, &geometry)) { + res2 = ioctl(fd, HDIO_REQ, &geometry); #else - if (!ioctl(fd, HDIO_GETGEO, &geometry)) { + res2 = ioctl(fd, HDIO_GETGEO, &geometry); #endif + + /* never use geometry.cylinders - it is truncated */ + heads = cylinders = sectors = 0; + sector_offset = 1; + if (res2 == 0) { heads = geometry.heads; sectors = geometry.sectors; - cylinders = geometry.cylinders; - cylinders /= sec_fac; /* do not round up */ - if (dos_compatible_flag) + if (heads * sectors == 0) + res2 = -1; + else if (dos_compatible_flag) sector_offset = sectors; - } else { - long longsectors; - if (!ioctl(fd, BLKGETSIZE, &longsectors)) { - heads = 1; - cylinders = 1; - sectors = longsectors / sec_fac; - } else { - heads = cylinders = sectors = 0; - } } + if (res1 == 0 && res2 == 0) { /* normal case */ + cylinders = longsectors / (heads * sectors); + cylinders /= sec_fac; /* do not round up */ + } else if (res1 == 0) { /* size but no geometry */ + heads = cylinders = 1; + sectors = longsectors / sec_fac; + } + + if (!sectors) + sectors = user_sectors; + if (!heads) + heads = user_heads; + if (!cylinders) + cylinders = user_cylinders; + + if (g) { + g->heads = heads; + g->sectors = sectors; + g->cylinders = cylinders; + } +} + +/* + * Read MBR. Returns: + * -1: no 0xaa55 flag present (possibly entire disk BSD) + * 0: found or created label + */ +int +get_boot(enum action what) { + int i; + + partitions = 4; + + if (what == create_empty) + goto got_table; /* skip reading disk */ + + if ((fd = open(disk_device, type_open)) < 0) { + if ((fd = open(disk_device, O_RDONLY)) < 0) + fatal(unable_to_open); + else + printf(_("You will not be able to write the partition table.\n")); + } + + get_geometry(fd, NULL); + update_units(); + if (sector_size != read(fd, MBRbuffer, sector_size)) + fatal(unable_to_read); + got_table: if (check_sun_label()) @@ -686,12 +783,15 @@ got_table: if (check_aix_label()) return 0; - if (!valid_part_table_flag(buffer)) { + if (check_osf_label()) + return 0; + + if (!valid_part_table_flag(MBRbuffer)) { switch(what) { case fdisk: fprintf(stderr, _("Device contains neither a valid DOS partition" - " table, nor Sun or SGI disklabel\n")); + " table, nor Sun, SGI or OSF disklabel\n")); #ifdef __sparc__ create_sunlabel(); #else @@ -713,21 +813,39 @@ got_table: warn_cylinders(); warn_geometry(); - for (i = 0; i < 4; i++) - if(IS_EXTENDED (part_table[i]->sys_ind)) { + for (i = 0; i < 4; i++) { + struct pte *pe = &ptes[i]; + + pe->part_table = pt_offset(MBRbuffer, i); + pe->ext_pointer = NULL; + pe->changed = 0; + pe->offset = 0; + pe->sectorbuffer = MBRbuffer; + } + + for (i = 0; i < 4; i++) { + struct pte *pe = &ptes[i]; + + if (IS_EXTENDED (pe->part_table->sys_ind)) { if (partitions != 4) fprintf(stderr, _("Ignoring extra extended " "partition %d\n"), i + 1); - else read_extended(part_table[ext_index = i]); + else + read_extended(i); } - for (i = 3; i < partitions; i++) - if (!valid_part_table_flag(buffers[i])) { + } + + for (i = 3; i < partitions; i++) { + struct pte *pe = &ptes[i]; + + if (!valid_part_table_flag(pe->sectorbuffer)) { fprintf(stderr, _("Warning: invalid flag 0x%04x of partition " "table %d will be corrected by w(rite)\n"), - part_table_flag(buffers[i]), i + 1); - changed[i] = 1; + part_table_flag(pe->sectorbuffer), i + 1); + pe->changed = 1; } + } return 0; } @@ -874,7 +992,7 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg) } } if (use_default) - printf(_("Using default value %d\n"), i = dflt); + printf(_("Using default value %d\n"), i = dflt); if (i >= low && i <= high) break; else @@ -883,12 +1001,16 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg) return i; } -int get_partition(int warn, int max) -{ - int i = read_int(1, 0, max, 0, _("Partition number")) - 1; +int +get_partition(int warn, int max) { + struct pte *pe; + int i; + + i = read_int(1, 0, max, 0, _("Partition number")) - 1; + pe = &ptes[i]; if (warn && ( - (!sun_label && !sgi_label && !part_table[i]->sys_ind) + (!sun_label && !sgi_label && !pe->part_table->sys_ind) || (sun_label && (!sunlabel->partitions[i].num_sectors || !sunlabel->infos[i].id)) @@ -897,8 +1019,8 @@ int get_partition(int warn, int max) return i; } -char *const str_units(int n) /* n==1: use singular */ -{ +char * const +str_units(int n) { /* n==1: use singular */ if (n == 1) return display_in_cyl_units ? _("cylinder") : _("sector"); else @@ -913,22 +1035,21 @@ void change_units(void) str_units(PLURAL)); } -void toggle_active(int i) -{ - struct partition *p = part_table[i]; +static void +toggle_active(int i) { + struct pte *pe = &ptes[i]; + struct partition *p = pe->part_table; if (IS_EXTENDED (p->sys_ind) && !p->boot_ind) fprintf(stderr, _("WARNING: Partition %d is an extended partition\n"), i + 1); - if (p->boot_ind) - p->boot_ind = 0; - else p->boot_ind = ACTIVE_FLAG; - changed[i] = 1; + p->boot_ind = (p->boot_ind ? 0 : ACTIVE_FLAG); + pe->changed = 1; } -void toggle_dos(void) -{ +static void +toggle_dos_compatibility_flag(void) { dos_compatible_flag = ~dos_compatible_flag; if (dos_compatible_flag) { sector_offset = sectors; @@ -940,9 +1061,11 @@ void toggle_dos(void) } } -void delete_partition(int i) -{ - struct partition *p = part_table[i], *q = ext_pointers[i]; +static void +delete_partition(int i) { + struct pte *pe = &ptes[i]; + struct partition *p = pe->part_table; + struct partition *q = pe->ext_pointer; /* Note that for the fifth partition (i == 4) we don't actually * decrement partitions. @@ -950,7 +1073,7 @@ void delete_partition(int i) if (warn_geometry()) return; - changed[i] = 1; + pe->changed = 1; if (sun_label) { sun_delete_partition(i); @@ -962,21 +1085,21 @@ void delete_partition(int i) } if (i < 4) { if (IS_EXTENDED (p->sys_ind) && i == ext_index) { - while (partitions > 4) - free(buffers[--partitions]); - ext_pointers[ext_index] = NULL; + partitions = 4; + ptes[ext_index].ext_pointer = NULL; extended_offset = 0; } clear_partition(p); } else if (!q->sys_ind && i > 4) { - free(buffers[--partitions]); - clear_partition(ext_pointers[--i]); - changed[i] = 1; + --partitions; + --i; + clear_partition(ptes[i].ext_pointer); + ptes[i].changed = 1; } else if (i > 3) { if (i > 4) { - p = ext_pointers[i - 1]; + p = ptes[i-1].ext_pointer; p->boot_ind = 0; p->head = q->head; p->sector = q->sector; @@ -987,37 +1110,33 @@ void delete_partition(int i) p->end_cyl = q->end_cyl; set_start_sect(p, get_start_sect(q)); set_nr_sects(p, get_nr_sects(q)); - changed[i - 1] = 1; + ptes[i-1].changed = 1; } else { - if(part_table[5]) /* prevent SEGFAULT */ - set_start_sect(part_table[5], - get_start_sect(part_table[5]) + - offsets[5] - extended_offset); - offsets[5] = extended_offset; - changed[5] = 1; + struct pte *pe = &ptes[5]; + + if(pe->part_table) /* prevent SEGFAULT */ + set_start_sect(pe->part_table, + get_partition_start(pe) - + extended_offset); + pe->offset = extended_offset; + pe->changed = 1; } if (partitions > 5) { partitions--; - free(buffers[i]); while (i < partitions) { - changed[i] = changed[i + 1]; - buffers[i] = buffers[i + 1]; - offsets[i] = offsets[i + 1]; - part_table[i] = part_table[i + 1]; - ext_pointers[i] = ext_pointers[i + 1]; + ptes[i] = ptes[i+1]; i++; } - } - else - clear_partition(part_table[i]); + } else + clear_partition(ptes[i].part_table); } } -void change_sysid(void) -{ +static void +change_sysid(void) { char *temp; int i = get_partition(0, partitions), sys, origsys; - struct partition *p = part_table[i]; + struct partition *p = ptes[i].part_table; origsys = sys = get_sysid(i); @@ -1064,12 +1183,12 @@ void change_sysid(void) if (sgi_label) { sgi_change_sysid(i, sys); } else - part_table[i]->sys_ind = sys; + p->sys_ind = sys; printf (_("Changed system type of partition %d " "to %x (%s)\n"), i + 1, sys, (temp = partition_type(sys)) ? temp : _("Unknown")); - changed[i] = 1; + ptes[i].changed = 1; break; } } @@ -1080,8 +1199,7 @@ void change_sysid(void) * Jan. 1990 (version 1.2.1 by Gordon W. Ross Aug. 1990; Modified by S. * Lubkin Oct. 1991). */ -static void long2chs(ulong ls, uint *c, uint *h, uint *s) -{ +static void long2chs(ulong ls, uint *c, uint *h, uint *s) { int spc = heads * sectors; *c = ls / spc; @@ -1090,8 +1208,7 @@ static void long2chs(ulong ls, uint *c, uint *h, uint *s) *s = ls % sectors + 1; /* sectors count from 1 */ } -static void check_consistency(struct partition *p, int partition) -{ +static void check_consistency(struct partition *p, int partition) { uint pbc, pbh, pbs; /* physical beginning c, h, s */ uint pec, peh, pes; /* physical ending c, h, s */ uint lbc, lbh, lbs; /* logical beginning c, h, s */ @@ -1152,18 +1269,91 @@ static void check_consistency(struct partition *p, int partition) } } -void list_disk_geometry(void) -{ +static void +list_disk_geometry(void) { printf(_("\nDisk %s: %d heads, %d sectors, %d cylinders\nUnits = " "%s of %d * %d bytes\n\n"), disk_device, heads, sectors, cylinders, str_units(PLURAL), units_per_sector, sector_size); } -void list_table(int xtra) -{ +/* + * Check whether partition entries are ordered by their starting positions. + * Return 0 if OK. Return i if partition i should have been earlier. + * Two separate checks: primary and logical partitions. + */ +static int +wrong_p_order(int *prev) { + struct pte *pe; + struct partition *p; + uint last_p_start_pos = 0, p_start_pos; + int i, last_i = 0; + + for (i = 0 ; i < partitions; i++) { + if (i == 4) { + last_i = 4; + last_p_start_pos = 0; + } + pe = &ptes[i]; + if ((p = pe->part_table)->sys_ind) { + p_start_pos = get_partition_start(pe); + + if (last_p_start_pos > p_start_pos) { + if (prev) + *prev = last_i; + return i; + } + + last_p_start_pos = p_start_pos; + last_i = i; + } + } + return 0; +} + +static void +fix_partition_table_order(void) { + struct pte *pei, *pek, ptebuf; + int i,k; + + if(!wrong_p_order(NULL)) { + printf(_("Nothing to do. Ordering is correct already.\n\n")); + return; + } + + while ((i = wrong_p_order(&k)) != 0) { + /* partition i should have come earlier, move it */ + pei = &ptes[i]; + pek = &ptes[k]; + + if (i < 4) { + /* We have to move data in the MBR */ + struct partition *pi, *pk, *pe, pbuf; + + pe = pei->ext_pointer; + pei->ext_pointer = pek->ext_pointer; + pek->ext_pointer = pe; + + pi = pei->part_table; + pk = pek->part_table; + + memmove(&pbuf, pi, sizeof(struct partition)); + memmove(pi, pk, sizeof(struct partition)); + memmove(pk, &pbuf, sizeof(struct partition)); + } else { + /* Only change is change in numbering */ + ptebuf = *pei; + *pei = *pek; + *pek = ptebuf; + } + pei->changed = pek->changed = 1; + + } +} + +static void +list_table(int xtra) { struct partition *p; char *type; - int digit_last = 0; int i, w; if (sun_label) { @@ -1176,26 +1366,30 @@ void list_table(int xtra) return; } - w = strlen(disk_device); + list_disk_geometry(); + + if (osf_label) { + xbsd_print_disklabel(xtra); + return; + } + /* Heuristic: we list partition 3 of /dev/foo as /dev/foo3, but if the device name ends in a digit, say /dev/foo1, then the partition is called /dev/foo1p3. */ - if (isdigit(disk_device[w-1])) - digit_last = 1; - - list_disk_geometry(); - + w = strlen(disk_device); + if (w && isdigit(disk_device[w-1])) + w++; if (w < 5) w = 5; - /* FIXME! let's see how this shows up with other languagues - acme@conectiva.com.br */ - printf(_("%*s Boot Start End Blocks Id System\n"), - (digit_last ? w + 2 : w + 1), _("Device")); + w+1, _("Device")); for (i = 0 ; i < partitions; i++) { - if ((p = part_table[i])->sys_ind) { + struct pte *pe = &ptes[i]; + + p = pe->part_table; + if (p->sys_ind) { unsigned int psects = get_nr_sects(p); unsigned int pblocks = psects; unsigned int podd = 0; @@ -1207,12 +1401,12 @@ void list_table(int xtra) if (sector_size > 1024) pblocks *= (sector_size / 1024); printf( - "%*s%s%-2d %c %9ld %9ld %9ld%c %2x %s\n", -/* device */ w, disk_device, (digit_last ? "p" : ""), i+1, + "%s %c %9ld %9ld %9ld%c %2x %s\n", + partname(disk_device, i+1, w+2), /* boot flag */ !p->boot_ind ? ' ' : p->boot_ind == ACTIVE_FLAG ? '*' : '?', -/* start */ (long) cround(get_start_sect(p) + offsets[i]), -/* end */ (long) cround(get_start_sect(p) + offsets[i] + psects +/* start */ (long) cround(get_partition_start(pe)), +/* end */ (long) cround(get_partition_start(pe) + psects - (psects ? 1 : 0)), /* odd flag on end */ (long) pblocks, podd ? '+' : ' ', /* type id */ p->sys_ind, @@ -1221,22 +1415,28 @@ void list_table(int xtra) check_consistency(p, i); } } + + /* Is partition table in disk order? It need not be, but... */ + /* partition table entries are not checked for correct order if this + is a sgi, sun or aix labeled disk... */ + if (dos_label && wrong_p_order(NULL)) { + printf(_("\nPartition table entries are not in disk order\n")); + } } -void x_list_table(int extend) -{ - struct partition *p, **q; +static void +x_list_table(int extend) { + struct pte *pe; + struct partition *p; int i; - if (extend) - q = ext_pointers; - else - q = part_table; printf(_("\nDisk %s: %d heads, %d sectors, %d cylinders\n\n"), disk_device, heads, sectors, cylinders); printf(_("Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n")); - for (i = 0 ; i < partitions; i++) - if ((p = q[i]) != NULL) { + for (i = 0 ; i < partitions; i++) { + pe = &ptes[i]; + p = (extend ? pe->ext_pointer : pe->part_table); + if (p != NULL) { printf("%2d %02x%4d%4d%5d%4d%4d%5d%9d%9d %02x\n", i + 1, p->boot_ind, p->head, sector(p->sector), @@ -1247,26 +1447,29 @@ void x_list_table(int extend) if (p->sys_ind) check_consistency(p, i); } + } } -void fill_bounds(uint *first, uint *last) -{ +static void +fill_bounds(uint *first, uint *last) { int i; - struct partition *p = part_table[0]; + struct pte *pe = &ptes[0]; + struct partition *p; - for (i = 0; i < partitions; p = part_table[++i]) { + for (i = 0; i < partitions; pe++,i++) { + p = pe->part_table; if (!p->sys_ind || IS_EXTENDED (p->sys_ind)) { first[i] = 0xffffffff; last[i] = 0; } else { - first[i] = get_start_sect(p) + offsets[i]; + first[i] = get_partition_start(pe); last[i] = first[i] + get_nr_sects(p) - 1; } } } -void check(int n, uint h, uint s, uint c, uint start) -{ +static void +check(int n, uint h, uint s, uint c, uint start) { uint total, real_s, real_c; real_s = sector(s) - 1; @@ -1290,9 +1493,8 @@ void check(int n, uint h, uint s, uint c, uint start) "total %d\n"), n, start, total); } - -void verify(void) -{ +static void +verify(void) { int i, j; uint total = 1; uint first[partitions], last[partitions]; @@ -1312,10 +1514,13 @@ void verify(void) } fill_bounds(first, last); - for (i = 0; i < partitions; p = part_table[++i]) + for (i = 0; i < partitions; i++) { + struct pte *pe = &ptes[i]; + + p = pe->part_table; if (p->sys_ind && !IS_EXTENDED (p->sys_ind)) { check_consistency(p, i); - if (get_start_sect(p) + offsets[i] < first[i]) + if (get_partition_start(pe) < first[i]) printf(_("Warning: bad start-of-data in " "partition %d\n"), i + 1); check(i + 1, p->end_head, p->end_sector, p->end_cyl, @@ -1332,14 +1537,16 @@ void verify(void) last[i] : last[j]; } } + } if (extended_offset) { - uint e_last = get_start_sect(part_table[ext_index]) + - get_nr_sects(part_table[ext_index]) - 1; + struct pte *pex = &ptes[ext_index]; + uint e_last = get_start_sect(pex->part_table) + + get_nr_sects(pex->part_table) - 1; - for (p = part_table[i = 4]; i < partitions; - p = part_table[++i]) { + for (i = 4; i < partitions; i++) { total++; + p = ptes[i].part_table; if (!p->sys_ind) { if (i != 4 || i + 1 < partitions) printf(_("Warning: partition %d " @@ -1359,15 +1566,16 @@ void verify(void) printf(_("%d unallocated sectors\n"), total); } -void add_partition(int n, int sys) -{ +static void +add_partition(int n, int sys) { char mesg[256]; /* 48 does not suffice in Japanese */ int i, read = 0; - struct partition *p = part_table[n], *q = part_table[ext_index]; + struct partition *p = ptes[n].part_table; + struct partition *q = ptes[ext_index].part_table; uint start, stop = 0, limit, temp, first[partitions], last[partitions]; - if (p->sys_ind) { + if (p && p->sys_ind) { printf(_("Partition %d is already defined. Delete " "it before re-adding it.\n"), n + 1); return; @@ -1395,7 +1603,7 @@ void add_partition(int n, int sys) for (i = 0; i < partitions; i++) { int lastplusoff; - if (start == offsets[i]) + if (start == ptes[i].offset) start += sector_offset; lastplusoff = last[i] + ((n<4) ? 0 : sector_offset); if (start >= first[i] && start <= lastplusoff) @@ -1421,26 +1629,28 @@ void add_partition(int n, int sys) } } while (start != temp || !read); if (n > 4) { /* NOT for fifth partition */ - offsets[n] = start - sector_offset; - if (offsets[n] == extended_offset) { /* must be corrected */ - offsets[n]++; + struct pte *pe = &ptes[n]; + + pe->offset = start - sector_offset; + if (pe->offset == extended_offset) { /* must be corrected */ + pe->offset++; if (sector_offset == 1) start++; } } for (i = 0; i < partitions; i++) { - if (start < offsets[i] && limit >= offsets[i]) - limit = offsets[i] - 1; + struct pte *pe = &ptes[i]; + + if (start < pe->offset && limit >= pe->offset) + limit = pe->offset - 1; if (start < first[i] && limit >= first[i]) limit = first[i] - 1; } if (start > limit) { printf(_("No free sectors available\n")); - if (n > 4) { - free(buffers[n]); + if (n > 4) partitions--; - } return; } if (cround(start) == cround(limit)) { @@ -1457,22 +1667,25 @@ void add_partition(int n, int sys) } } - set_partition(n, p, start, stop, sys, offsets[n]); + set_partition(n, p, start, stop, sys, ptes[n].offset); if (IS_EXTENDED (sys)) { + struct pte *pe4 = &ptes[4]; + struct pte *pen = &ptes[n]; + ext_index = n; - offsets[4] = extended_offset = start; - ext_pointers[n] = p; - if (!(buffers[4] = calloc(1, sector_size))) + pen->ext_pointer = p; + pe4->offset = extended_offset = start; + if (!(pe4->sectorbuffer = calloc(1, sector_size))) fatal(out_of_memory); - part_table[4] = offset(buffers[4], 0); - ext_pointers[4] = part_table[4] + 1; - changed[4] = 1; + pe4->part_table = pt_offset(pe4->sectorbuffer, 0); + pe4->ext_pointer = pe4->part_table + 1; + pe4->changed = 1; partitions = 5; } else { if (n > 4) - set_partition(n - 1, ext_pointers[n - 1], - offsets[n], stop, EXTENDED, + set_partition(n - 1, ptes[n-1].ext_pointer, + ptes[n].offset, stop, EXTENDED, extended_offset); #if 0 if ((limit = get_nr_sects(p)) & 1) @@ -1482,21 +1695,24 @@ void add_partition(int n, int sys) } } -void add_logical(void) -{ - if (partitions > 5 || part_table[4]->sys_ind) { - if (!(buffers[partitions] = calloc(1, sector_size))) +static void +add_logical(void) { + if (partitions > 5 || ptes[4].part_table->sys_ind) { + struct pte *pe = &ptes[partitions]; + + if (!(pe->sectorbuffer = calloc(1, sector_size))) fatal(out_of_memory); - part_table[partitions] = offset(buffers[partitions], 0); - ext_pointers[partitions] = part_table[partitions] + 1; - offsets[partitions] = 0; + pe->part_table = pt_offset(pe->sectorbuffer, 0); + pe->ext_pointer = pe->part_table + 1; + pe->offset = 0; + pe->changed = 1; partitions++; } add_partition(partitions - 1, LINUX_NATIVE); } -void new_partition(void) -{ +static void +new_partition(void) { int i, free_primary = 0; if (warn_geometry()) @@ -1518,7 +1734,7 @@ void new_partition(void) } for (i = 0; i < 4; i++) - free_primary += !part_table[i]->sys_ind; + free_primary += !ptes[i].part_table->sys_ind; if (!free_primary) { if (extended_offset) add_logical(); @@ -1552,30 +1768,33 @@ void new_partition(void) } } -void write_table(void) -{ +static void +write_table(void) { int i; - changed[3] = changed[0] || changed[1] || changed[2] || changed[3]; - if (!sun_label && !sgi_label) { - for (i = 3; i < partitions; i++) { - if (changed[i]) { - write_part_table_flag(buffers[i]); - if (ext2_llseek(fd, (ext2_loff_t)offsets[i] - * sector_size, SEEK_SET) < 0) - fatal(unable_to_seek); - if (write(fd, buffers[i], sector_size) != sector_size) - fatal(unable_to_write); + if (dos_label) { + for (i=0; i<3; i++) + if(ptes[i].changed) + ptes[3].changed = 1; + for (i = 3; i < partitions; i++) { + struct pte *pe = &ptes[i]; + + if (pe->changed) { + write_part_table_flag(pe->sectorbuffer); + write_sector(fd, pe->offset, pe->sectorbuffer); + } } - } } else if (sgi_label) { - /* no test on change? the printf below might be mistaken */ - sgi_write_table(); + /* no test on change? the printf below might be mistaken */ + sgi_write_table(); } else if (sun_label) { - if (changed[3] || changed[4] || changed[5] || - changed[6] || changed[7]) { - sun_write_table(); - } + int needw = 0; + + for (i=0; i<8; i++) + if(ptes[i].changed) + needw = 1; + if (needw) + sun_write_table(); } printf(_("The partition table has been altered!\n\n")); @@ -1624,15 +1843,15 @@ reread_partition_table(int leave) { } #define MAX_PER_LINE 16 -void print_buffer(char buffer[]) -{ +static void +print_buffer(char pbuffer[]) { int i, l; for (i = 0, l = 0; i < sector_size; i++, l++) { if (l == 0) printf("0x%03X:", i); - printf(" %02X", (unsigned char) buffer[i]); + printf(" %02X", (unsigned char) pbuffer[i]); if (l == MAX_PER_LINE - 1) { printf("\n"); l = -1; @@ -1643,20 +1862,21 @@ void print_buffer(char buffer[]) printf("\n"); } -void print_raw(void) -{ +static void +print_raw(void) { int i; printf(_("Device: %s\n"), disk_device); if (sun_label || sgi_label) - print_buffer(buffer); + print_buffer(MBRbuffer); else for (i = 3; i < partitions; i++) - print_buffer(buffers[i]); + print_buffer(ptes[i].sectorbuffer); } -void move_begin(int i) -{ - struct partition *p = part_table[i]; +static void +move_begin(int i) { + struct pte *pe = &ptes[i]; + struct partition *p = pe->part_table; uint new, first; if (warn_geometry()) @@ -1665,38 +1885,42 @@ void move_begin(int i) printf(_("Partition %d has no data area\n"), i + 1); return; } - first = get_start_sect(p) + offsets[i]; - new = read_int(first, first, - get_start_sect(p) + get_nr_sects(p) + offsets[i] - 1, - first, _("New beginning of data")) - offsets[i]; + first = get_partition_start(pe); + new = read_int(first, first, first + get_nr_sects(p) - 1, first, + _("New beginning of data")) - pe->offset; if (new != get_nr_sects(p)) { first = get_nr_sects(p) + get_start_sect(p) - new; set_nr_sects(p, first); set_start_sect(p, new); - changed[i] = 1; + pe->changed = 1; } } -void xselect(void) -{ +static void +xselect(void) { + char c; + while(1) { putchar('\n'); - switch (tolower(read_char(_("Expert command (m for help): ")))) { + c = tolower(read_char(_("Expert command (m for help): "))); + switch (c) { case 'a': if (sun_label) sun_set_alt_cyl(); break; case 'b': - if (!sun_label && !sgi_label) + if (dos_label) move_begin(get_partition(0, partitions)); break; case 'c': - cylinders = read_int(1, cylinders, 131071, - 0, _("Number of cylinders")); + user_cylinders = cylinders = + read_int(1, cylinders, 131071, 0, + _("Number of cylinders")); if (sun_label) sun_set_ncyl(cylinders); - warn_cylinders(); + if (dos_label) + warn_cylinders(); break; case 'd': print_raw(); @@ -1706,14 +1930,18 @@ void xselect(void) sgi_set_xcyl(); else if (sun_label) sun_set_xcyl(); - else + else if (dos_label) x_list_table(1); break; + case 'f': + if(dos_label) + fix_partition_table_order(); + break; case 'g': create_sgilabel(); break; case 'h': - heads = read_int(1, heads, 256, 0, + user_heads = heads = read_int(1, heads, 256, 0, _("Number of heads")); update_units(); break; @@ -1738,7 +1966,7 @@ void xselect(void) case 'r': return; case 's': - sectors = read_int(1, sectors, 63, 0, + user_sectors = sectors = read_int(1, sectors, 63, 0, _("Number of sectors")); if (dos_compatible_flag) { sector_offset = sectors; @@ -1764,7 +1992,7 @@ void xselect(void) } } -int +static int is_ide_cdrom(char *device) { /* No device was given explicitly, and we are trying some likely things. But opening /dev/hdc may produce errors like @@ -1792,8 +2020,8 @@ is_ide_cdrom(char *device) { return 0; } -void try(char *device, int user_specified) -{ +static void +try(char *device, int user_specified) { disk_device = device; if (!setjmp(listingbuf)) { if (!user_specified) @@ -1827,8 +2055,8 @@ void try(char *device, int user_specified) /* for fdisk -l: try all things in /proc/partitions that look like a partition name (do not end in a digit) */ -void -tryprocpt() { +static void +tryprocpt(void) { FILE *procpt; char line[100], ptname[100], devname[120], *s; int ma, mi, sz; @@ -1851,16 +2079,14 @@ tryprocpt() { } } -int -dir_exists(char *dirname) { - struct stat statbuf; +static void +dummy(int *kk) {} - return (stat(dirname, &statbuf) == 0 && S_ISDIR(statbuf.st_mode)); +static void +unknown_command(int c) { + printf(_("%c: unknown command\n"), c); } -void -dummy(int *kk) {} - int main(int argc, char **argv) { int j, c; @@ -1878,7 +2104,7 @@ main(int argc, char **argv) { * fdisk -s [partition] ... * fdisk [-b sectorsize] [-u] device */ - while ((c = getopt(argc, argv, "b:lsuv")) != EOF) { + while ((c = getopt(argc, argv, "b:lsuvV")) != EOF) { switch (c) { case 'b': /* ugly: this sector size is really per device, @@ -1899,6 +2125,7 @@ main(int argc, char **argv) { case 'u': display_in_cyl_units = 0; break; + case 'V': case 'v': printf("fdisk v" UTIL_LINUX_VERSION "\n"); exit(0); @@ -1968,19 +2195,34 @@ main(int argc, char **argv) { get_boot(fdisk); +#ifdef __alpha__ + /* On alpha, if we detect a disklabel, go directly to + disklabel mode (typically you'll be switching from DOS + partition tables to disklabels, not the other way around) + - dhuggins@linuxcare.com */ + if (osf_label) { + printf(_("Detected an OSF/1 disklabel on %s, entering disklabel mode.\n" + "To return to DOS partition table mode, use the 'r' command.\n"), + disk_device); + bselect(); + } +#endif + while (1) { putchar('\n'); - switch (tolower(read_char(_("Command (m for help): ")))) { + c = tolower(read_char(_("Command (m for help): "))); + switch (c) { case 'a': - if (sun_label) + if (dos_label) + toggle_active(get_partition(1, partitions)); + else if (sun_label) toggle_sunflags(get_partition(1, partitions), 0x01); + else if (sgi_label) + sgi_set_bootpartition( + get_partition(1, partitions)); else - if (sgi_label) - sgi_set_bootpartition( - get_partition(1, partitions)); - else - toggle_active(get_partition(1, partitions)); + unknown_command(c); break; case 'b': if (sgi_label) { @@ -1995,15 +2237,16 @@ main(int argc, char **argv) { bselect(); break; case 'c': - if (sun_label) + if (dos_label) + toggle_dos_compatibility_flag(); + else if (sun_label) toggle_sunflags(get_partition(1, partitions), 0x10); - else - if (sgi_label) - sgi_set_swappartition( + else if (sgi_label) + sgi_set_swappartition( get_partition(1, partitions)); - else - toggle_dos(); + else + unknown_command(c); break; case 'd': delete_partition( @@ -2013,10 +2256,13 @@ main(int argc, char **argv) { if (sgi_label) create_sgiinfo(); else - menu(); + unknown_command(c); case 'l': list_types(get_sys_types()); break; + case 'm': + menu(); + break; case 'n': new_partition(); break; @@ -2046,14 +2292,16 @@ main(int argc, char **argv) { write_table(); /* does not return */ break; case 'x': - if( sgi_label ) { + if(sgi_label) { fprintf(stderr, _("\n\tSorry, no experts menu for SGI " "partition tables available.\n\n")); } else xselect(); break; - default: menu(); + default: + unknown_command(c); + menu(); } } return 0; diff --git a/fdisk/fdisk.h b/fdisk/fdisk.h index 551b02f6..868251df 100644 --- a/fdisk/fdisk.h +++ b/fdisk/fdisk.h @@ -53,6 +53,12 @@ enum failure {usage, usage2, ioctl_error, enum action {fdisk, require, try_only, create_empty}; +struct geom { + unsigned int heads; + unsigned int sectors; + unsigned int cylinders; +}; + /* prototypes for fdisk.c */ extern char *disk_device, *line_ptr; @@ -60,8 +66,10 @@ extern int fd, partitions; extern uint display_in_cyl_units, units_per_sector; +extern void change_units(void); extern struct partition *part_table[]; extern void fatal(enum failure why); +extern void get_geometry(int fd, struct geom *); extern int get_boot(enum action what); extern int get_partition(int warn, int max); extern void list_types(struct systypes *sys); @@ -69,7 +77,10 @@ extern int read_line (void); extern char read_char(char *mesg); extern int read_hex(struct systypes *sys); extern void reread_partition_table(int leave); -uint read_int(uint low, uint dflt, uint high, uint base, char *mesg); +extern struct partition *get_part_table(int); +extern int valid_part_table_flag(unsigned char *b); +extern uint read_int(uint low, uint dflt, uint high, uint base, char *mesg); + #define PLURAL 0 #define SINGULAR 1 @@ -78,9 +89,13 @@ extern char *const str_units(int); extern unsigned int get_start_sect(struct partition *p); extern unsigned int get_nr_sects(struct partition *p); +extern int osf_label; + /* prototypes for fdiskbsdlabel.c */ extern void bselect(void); -extern int btrydev (char * dev); +extern int check_osf_label(void); +extern int btrydev(char * dev); +extern void xbsd_print_disklabel(int); /* prototypes for fdisksgilabel.c */ extern int valid_part_table_flag(unsigned char *b); diff --git a/fdisk/fdiskaixlabel.c b/fdisk/fdiskaixlabel.c index 7540f9a6..395de53e 100644 --- a/fdisk/fdiskaixlabel.c +++ b/fdisk/fdiskaixlabel.c @@ -22,9 +22,8 @@ static short volumes=1; * only dealing with free blocks here */ -void -aix_info( void ) -{ +static void +aix_info( void ) { puts( _("\n\tThere is a valid AIX label on this disk.\n" "\tUnfortunately Linux cannot handle these\n" @@ -46,7 +45,7 @@ aix_nolabel( void ) aixlabel->magic = 0; aix_label = 0; partitions = 4; - memset( buffer, 0, sizeof(buffer) ); /* avoid fdisk cores */ + memset( MBRbuffer, 0, sizeof(MBRbuffer) ); /* avoid fdisk cores */ return; } diff --git a/fdisk/fdiskaixlabel.h b/fdisk/fdiskaixlabel.h index fd95bc01..ca6919d7 100644 --- a/fdisk/fdiskaixlabel.h +++ b/fdisk/fdiskaixlabel.h @@ -18,8 +18,8 @@ typedef struct { #define AIX_INFO_MAGIC_SWAPPED 0x59290700 /* fdisk.c */ -#define aixlabel ((aix_partition *)buffer) -extern char buffer[MAX_SECTOR_SIZE]; +#define aixlabel ((aix_partition *)MBRbuffer) +extern char MBRbuffer[MAX_SECTOR_SIZE]; extern char changed[MAXIMUM_PARTS]; extern uint heads, sectors, cylinders; extern int show_begin; diff --git a/fdisk/fdiskbsdlabel.c b/fdisk/fdiskbsdlabel.c index 980bc38c..0f3c6813 100644 --- a/fdisk/fdiskbsdlabel.c +++ b/fdisk/fdiskbsdlabel.c @@ -36,6 +36,10 @@ Changes: 19990319 - Arnaldo Carvalho de Melo - i18n/nls + + 20000101 - David Huggins-Daines - Better + support for OSF/1 disklabels on Alpha. Also fixed unaligned + accesses in alpha_bootblock_checksum() */ #include @@ -61,7 +65,6 @@ static void xbsd_delete_part (void); static void xbsd_new_part (void); -static void xbsd_print_disklabel (int show_all); static void xbsd_write_disklabel (void); static int xbsd_create_disklabel (void); static void xbsd_edit_disklabel (void); @@ -75,33 +78,49 @@ static int xbsd_initlabel (struct partition *p, struct xbsd_disklabel *d, int p static int xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d); static int xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d); static void sync_disks (void); -#if defined (i386) || defined (__sparc__) || defined (__arm__) -static int xbsd_translate_fstype (int linux_type); -static void xbsd_link_part (void); -#endif + #if defined (__alpha__) void alpha_bootblock_checksum (char *boot); #endif -static struct xbsd_disklabel xbsd_dlabel; -static char buffer[BSD_BBSIZE]; -#if defined (i386) || defined (__sparc__) || defined (__arm__) +#if !defined (__alpha__) +static int xbsd_translate_fstype (int linux_type); +static void xbsd_link_part (void); static struct partition *xbsd_part; static int xbsd_part_index; #endif +#if defined (__alpha__) +/* We access this through a u_int64_t * when checksumming */ +static char disklabelbuffer[BSD_BBSIZE] __attribute__((aligned(8))); +#else +static char disklabelbuffer[BSD_BBSIZE]; +#endif + +static struct xbsd_disklabel xbsd_dlabel; + +#define bsd_cround(n) \ + (display_in_cyl_units ? ((n)/xbsd_dlabel.d_secpercyl) + 1 : (n)) + +int +check_osf_label(void) { + if (xbsd_readlabel (NULL, &xbsd_dlabel) == 0) + return 0; + osf_label = 1; + return 1; +} + int btrydev (char * dev) { if (xbsd_readlabel (NULL, &xbsd_dlabel) == 0) - return -1; + return -1; printf(_("\nBSD label for device: %s\n"), dev); xbsd_print_disklabel (0); return 0; } -void -bmenu (void) -{ +static void +bmenu (void) { puts (_("Command action")); puts (_(" d delete a BSD partition")); puts (_(" e edit drive data")); @@ -111,49 +130,53 @@ bmenu (void) puts (_(" n add a new BSD partition")); puts (_(" p print BSD partition table")); puts (_(" q quit without saving changes")); -#if defined (i386) || defined (__sparc__) || defined (__arm__) puts (_(" r return to main menu")); -#endif puts (_(" s show complete disklabel")); puts (_(" t change a partition's filesystem id")); + puts (_(" u change units (cylinders/sectors)")); puts (_(" w write disklabel to disk")); -#if defined (i386) || defined (__sparc__) || defined (__arm__) +#if !defined (__alpha__) puts (_(" x link BSD partition to non-BSD partition")); #endif } -int +#if !defined (__alpha__) +static int hidden(int type) { return type ^ 0x10; } -int +static int is_netbsd_partition_type(int type) { return (type == NETBSD_PARTITION || type == hidden(NETBSD_PARTITION)); } +#endif void bselect (void) { -#if defined (i386) || defined (__sparc__) || defined (__arm__) +#if !defined (__alpha__) int t, ss; + struct partition *p; - for (t=0; t<4; t++) - if (is_netbsd_partition_type(part_table[t] -> sys_ind)) { - xbsd_part = part_table[t]; + for (t=0; t<4; t++) { + p = get_part_table(t); + if (p && is_netbsd_partition_type(p->sys_ind)) { + xbsd_part = p; xbsd_part_index = t; ss = get_start_sect(xbsd_part); if (ss == 0) { - fprintf (stderr, _("Partition %s%d has invalid starting sector 0.\n"), - disk_device, t+1); - return; + fprintf (stderr, _("Partition %s has invalid starting sector 0.\n"), + partname(disk_device, t+1, 0)); + return; } - printf (_("Reading disklabel of %s%d at sector %d.\n"), - disk_device, t+1, ss + BSD_LABELSECTOR); + printf (_("Reading disklabel of %s at sector %d.\n"), + partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR); if (xbsd_readlabel (xbsd_part, &xbsd_dlabel) == 0) - if (xbsd_create_disklabel () == 0) + if (xbsd_create_disklabel () == 0) return; break; } + } if (t == 4) { printf (_("There is no *BSD partition on %s.\n"), disk_device); @@ -168,22 +191,20 @@ bselect (void) { #endif - while (1) - { + while (1) { putchar ('\n'); - switch (tolower (read_char (_("BSD disklabel command (m for help): ")))) - { + switch (tolower (read_char (_("BSD disklabel command (m for help): ")))) { case 'd': - xbsd_delete_part (); + xbsd_delete_part (); break; case 'e': - xbsd_edit_disklabel (); + xbsd_edit_disklabel (); break; case 'i': - xbsd_write_bootstrap (); + xbsd_write_bootstrap (); break; case 'l': - xbsd_list_types (); + xbsd_list_types (); break; case 'n': xbsd_new_part (); @@ -194,18 +215,21 @@ bselect (void) { case 'q': close (fd); exit ( EXIT_SUCCESS ); + case 'r': + return; case 's': xbsd_print_disklabel (1); break; case 't': - xbsd_change_fstype (); + xbsd_change_fstype (); + break; + case 'u': + change_units(); break; case 'w': xbsd_write_disklabel (); break; -#if defined (i386) || defined (__sparc__) || defined (__arm__) - case 'r': - return; +#if !defined (__alpha__) case 'x': xbsd_link_part (); break; @@ -225,7 +249,7 @@ xbsd_delete_part (void) i = xbsd_get_part_index (xbsd_dlabel.d_npartitions); xbsd_dlabel.d_partitions[i].p_size = 0; xbsd_dlabel.d_partitions[i].p_offset = 0; - xbsd_dlabel.d_partitions[i].p_fstype = BSD_FS_UNUSED; + xbsd_dlabel.d_partitions[i].p_fstype = BSD_FS_UNUSED; if (xbsd_dlabel.d_npartitions == i + 1) while (xbsd_dlabel.d_partitions[xbsd_dlabel.d_npartitions-1].p_size == 0) xbsd_dlabel.d_npartitions--; @@ -241,7 +265,7 @@ xbsd_new_part (void) if (!xbsd_check_new_partition (&i)) return; -#if defined (i386) || defined (__sparc__) || defined (__arm__) +#if !defined (__alpha__) && !defined (__powerpc__) begin = get_start_sect(xbsd_part); end = begin + get_nr_sects(xbsd_part) - 1; #elif defined (__alpha__) || defined (__powerpc__) @@ -250,39 +274,37 @@ xbsd_new_part (void) #endif sprintf (mesg, _("First %s"), str_units(SINGULAR)); - begin = read_int (cround (begin), cround (begin), cround (end), + begin = read_int (bsd_cround (begin), bsd_cround (begin), bsd_cround (end), 0, mesg); if (display_in_cyl_units) - begin = (begin - 1) * units_per_sector; + begin = (begin - 1) * xbsd_dlabel.d_secpercyl; sprintf (mesg, _("Last %s or +size or +sizeM or +sizeK"), str_units(SINGULAR)); - end = read_int (cround (begin), cround (end), cround (end), - cround (begin), mesg); + end = read_int (bsd_cround (begin), bsd_cround (end), bsd_cround (end), + bsd_cround (begin), mesg); if (display_in_cyl_units) - end = end * units_per_sector - 1; + end = end * xbsd_dlabel.d_secpercyl - 1; xbsd_dlabel.d_partitions[i].p_size = end - begin + 1; xbsd_dlabel.d_partitions[i].p_offset = begin; - xbsd_dlabel.d_partitions[i].p_fstype = BSD_FS_UNUSED; + xbsd_dlabel.d_partitions[i].p_fstype = BSD_FS_UNUSED; } -static void -xbsd_print_disklabel (int show_all) -{ +void +xbsd_print_disklabel (int show_all) { struct xbsd_disklabel *lp = &xbsd_dlabel; struct xbsd_partition *pp; FILE *f = stdout; int i, j; - if (show_all) - { -#if defined (i386) || defined (__sparc__) || defined (__arm__) - fprintf(f, "# %s%d:\n", disk_device, xbsd_part_index+1); -#elif defined (__alpha__) + if (show_all) { +#if defined (__alpha__) fprintf(f, "# %s:\n", disk_device); +#else + fprintf(f, "# %s:\n", partname(disk_device, xbsd_part_index+1, 0)); #endif if ((unsigned) lp->d_type < BSD_DKMAXTYPES) fprintf(f, _("type: %s\n"), xbsd_dktypenames[lp->d_type]); @@ -309,8 +331,10 @@ xbsd_print_disklabel (int show_all) fprintf(f, _("interleave: %d\n"), lp->d_interleave); fprintf(f, _("trackskew: %d\n"), lp->d_trackskew); fprintf(f, _("cylinderskew: %d\n"), lp->d_cylskew); - fprintf(f, _("headswitch: %ld\t\t# milliseconds\n"), (long) lp->d_headswitch); - fprintf(f, _("track-to-track seek: %ld\t# milliseconds\n"), (long) lp->d_trkseek); + fprintf(f, _("headswitch: %ld\t\t# milliseconds\n"), + (long) lp->d_headswitch); + fprintf(f, _("track-to-track seek: %ld\t# milliseconds\n"), + (long) lp->d_trkseek); fprintf(f, _("drivedata: ")); for (i = NDDATA - 1; i >= 0; i--) if (lp->d_drivedata[i]) @@ -321,19 +345,33 @@ xbsd_print_disklabel (int show_all) fprintf(f, "%ld ", (long) lp->d_drivedata[j]); } fprintf (f, _("\n%d partitions:\n"), lp->d_npartitions); - fprintf (f, _("# size offset fstype [fsize bsize cpg]\n")); + fprintf (f, _("# start end size fstype [fsize bsize cpg]\n")); pp = lp->d_partitions; for (i = 0; i < lp->d_npartitions; i++, pp++) { if (pp->p_size) { - fprintf(f, " %c: %8ld %8ld ", 'a' + i, - (long) pp->p_size, (long) pp->p_offset); + if (display_in_cyl_units && lp->d_secpercyl) { + fprintf(f, " %c: %8ld%c %8ld%c %8ld%c ", + 'a' + i, + (long) pp->p_offset / lp->d_secpercyl + 1, + (pp->p_offset % lp->d_secpercyl) ? '*' : ' ', + (long) (pp->p_offset + pp->p_size + lp->d_secpercyl - 1) + / lp->d_secpercyl, + ((pp->p_offset + pp->p_size) % lp->d_secpercyl) ? '*' : ' ', + (long) pp->p_size / lp->d_secpercyl, + (pp->p_size % lp->d_secpercyl) ? '*' : ' '); + } else { + fprintf(f, " %c: %8ld %8ld %8ld ", + 'a' + i, + (long) pp->p_offset, + (long) pp->p_offset + pp->p_size - 1, + (long) pp->p_size); + } if ((unsigned) pp->p_fstype < BSD_FSMAXTYPES) fprintf(f, "%8.8s", xbsd_fstypes[pp->p_fstype].name); else fprintf(f, "%8x", pp->p_fstype); - switch (pp->p_fstype) - { - case BSD_FS_UNUSED: + switch (pp->p_fstype) { + case BSD_FS_UNUSED: fprintf(f, " %5ld %5ld %5.5s ", (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, ""); break; @@ -345,76 +383,55 @@ xbsd_print_disklabel (int show_all) break; default: - fprintf(f, "%20.20s", ""); + fprintf(f, "%22.22s", ""); break; } - fprintf(f, "\t# (Cyl. %4ld", (long) -#if 0 - pp->p_offset / lp->d_secpercyl); /* differs from Linux fdisk */ -#else - pp->p_offset / lp->d_secpercyl + 1); -#endif - if (pp->p_offset % lp->d_secpercyl) - putc('*', f); - else - putc(' ', f); - fprintf(f, "- %ld", - (long) (pp->p_offset + - pp->p_size + lp->d_secpercyl - 1) / -#if 0 - lp->d_secpercyl - 1); /* differs from Linux fdisk */ -#else - lp->d_secpercyl); -#endif - if (pp->p_size % lp->d_secpercyl) - putc('*', f); - fprintf(f, ")\n"); + fprintf(f, "\n"); } } } static void -xbsd_write_disklabel (void) -{ -#if defined (i386) || defined (__sparc__) || defined (__arm__) - printf (_("Writing disklabel to %s%d.\n"), disk_device, xbsd_part_index+1); - xbsd_writelabel (xbsd_part, &xbsd_dlabel); -#elif defined (__alpha__) - printf (_("Writing disklabel to %s.\n"), disk_device); - xbsd_writelabel (NULL, &xbsd_dlabel); +xbsd_write_disklabel (void) { +#if defined (__alpha__) + printf (_("Writing disklabel to %s.\n"), disk_device); + xbsd_writelabel (NULL, &xbsd_dlabel); +#else + printf (_("Writing disklabel to %s.\n"), + partname(disk_device, xbsd_part_index+1, 0)); + xbsd_writelabel (xbsd_part, &xbsd_dlabel); #endif - reread_partition_table(0); /* no exit yet */ + reread_partition_table(0); /* no exit yet */ } static int -xbsd_create_disklabel (void) -{ - char c; +xbsd_create_disklabel (void) { + char c; -#if defined (i386) || defined (__sparc__) || defined (__arm__) - fprintf (stderr, _("%s%d contains no disklabel.\n"), - disk_device, xbsd_part_index+1); -#elif defined (__alpha__) - fprintf (stderr, _("%s contains no disklabel.\n"), disk_device); +#if defined (__alpha__) + fprintf (stderr, _("%s contains no disklabel.\n"), disk_device); +#else + fprintf (stderr, _("%s contains no disklabel.\n"), + partname(disk_device, xbsd_part_index+1, 0)); #endif - while (1) - if ((c = tolower (read_char (_("Do you want to create a disklabel? (y/n) ")))) == 'y') - { -#if defined (i386) || defined (__sparc__) || defined (__arm__) - if (xbsd_initlabel (xbsd_part, &xbsd_dlabel, xbsd_part_index) == 1) -#elif defined (__alpha__) || defined (__powerpc__) - if (xbsd_initlabel (NULL, &xbsd_dlabel, 0) == 1) + while (1) { + c = read_char (_("Do you want to create a disklabel? (y/n) ")); + if (tolower(c) == 'y') { + if (xbsd_initlabel ( +#if defined (__alpha__) || defined (__powerpc__) + NULL, &xbsd_dlabel, 0 +#else + xbsd_part, &xbsd_dlabel, xbsd_part_index #endif - { - xbsd_print_disklabel (1); - return 1; - } - else - return 0; - } - else if (c == 'n') - return 0; + ) == 1) { + xbsd_print_disklabel (1); + return 1; + } else + return 0; + } else if (c == 'n') + return 0; + } } static int @@ -437,7 +454,7 @@ xbsd_edit_disklabel (void) d = &xbsd_dlabel; -#ifdef __alpha__ +#if defined (__alpha__) || defined (__ia64__) d -> d_secsize = (u_long) edit_int ((u_long) d -> d_secsize ,_("bytes/sector")); d -> d_nsectors = (u_long) edit_int ((u_long) d -> d_nsectors ,_("sectors/track")); d -> d_ntracks = (u_long) edit_int ((u_long) d -> d_ntracks ,_("tracks/cylinder")); @@ -507,18 +524,18 @@ xbsd_write_bootstrap (void) dkbasename = line_ptr; } sprintf (path, "%s/%sboot", bootdir, dkbasename); - if (!xbsd_get_bootstrap (path, buffer, (int) xbsd_dlabel.d_secsize)) + if (!xbsd_get_bootstrap (path, disklabelbuffer, (int) xbsd_dlabel.d_secsize)) return; /* We need a backup of the disklabel (xbsd_dlabel might have changed). */ - d = &buffer[BSD_LABELSECTOR * SECTOR_SIZE]; + d = &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE]; bcopy (d, &dl, sizeof (struct xbsd_disklabel)); /* The disklabel will be overwritten by 0's from bootxx anyway */ bzero (d, sizeof (struct xbsd_disklabel)); sprintf (path, "%s/boot%s", bootdir, dkbasename); - if (!xbsd_get_bootstrap (path, &buffer[xbsd_dlabel.d_secsize], + if (!xbsd_get_bootstrap (path, &disklabelbuffer[xbsd_dlabel.d_secsize], (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize)) return; @@ -532,24 +549,25 @@ xbsd_write_bootstrap (void) bcopy (&dl, d, sizeof (struct xbsd_disklabel)); -#if defined (i386) || defined (__sparc__) || defined (__arm__) - sector = get_start_sect(xbsd_part); -#elif defined (__powerpc__) +#if defined (__powerpc__) sector = 0; #elif defined (__alpha__) sector = 0; - alpha_bootblock_checksum (buffer); + alpha_bootblock_checksum (disklabelbuffer); +#else + sector = get_start_sect(xbsd_part); #endif - if (ext2_llseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1) + if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1) fatal (unable_to_seek); - if (BSD_BBSIZE != write (fd, buffer, BSD_BBSIZE)) + if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE)) fatal (unable_to_write); -#if defined (i386) || defined (__sparc__) || defined (__arm__) - printf (_("Bootstrap installed on %s%d.\n"), disk_device, xbsd_part_index+1); -#elif defined (__alpha__) +#if defined (__alpha__) printf (_("Bootstrap installed on %s.\n"), disk_device); +#else + printf (_("Bootstrap installed on %s.\n"), + partname (disk_device, xbsd_part_index+1, 0)); #endif sync_disks (); @@ -629,14 +647,10 @@ xbsd_dkcksum (struct xbsd_disklabel *lp) static int xbsd_initlabel (struct partition *p, struct xbsd_disklabel *d, int pindex) { - struct hd_geometry geometry; struct xbsd_partition *pp; + struct geom g; - if (ioctl (fd, HDIO_GETGEO, &geometry) == -1) - { - perror ("ioctl"); - return 0; - } + get_geometry (fd, &g); bzero (d, sizeof (struct xbsd_disklabel)); d -> d_magic = BSD_DISKMAGIC; @@ -650,16 +664,18 @@ xbsd_initlabel (struct partition *p, struct xbsd_disklabel *d, int pindex) d -> d_subtype = BSD_DSTYPE_INDOSPART & pindex; #endif -#if defined (i386) || defined (__sparc__) || defined (__arm__) +#if !defined (__alpha__) d -> d_flags = BSD_D_DOSPART; #else d -> d_flags = 0; #endif - d -> d_secsize = SECTOR_SIZE; /* bytes/sector */ - d -> d_nsectors = geometry.sectors; /* sectors/track */ - d -> d_ntracks = geometry.heads; /* tracks/cylinder (heads) */ - d -> d_ncylinders = geometry.cylinders; - d -> d_secpercyl = geometry.sectors * geometry.heads; /* sectors/cylinder */ + d -> d_secsize = SECTOR_SIZE; /* bytes/sector */ + d -> d_nsectors = g.sectors; /* sectors/track */ + d -> d_ntracks = g.heads; /* tracks/cylinder (heads) */ + d -> d_ncylinders = g.cylinders; + d -> d_secpercyl = g.sectors * g.heads; /* sectors/cylinder */ + if (d -> d_secpercyl == 0) + d -> d_secpercyl = 1; /* avoid segfaults */ d -> d_secperunit = d -> d_secpercyl * d -> d_ncylinders; d -> d_rpm = 3600; @@ -673,7 +689,7 @@ xbsd_initlabel (struct partition *p, struct xbsd_disklabel *d, int pindex) d -> d_bbsize = BSD_BBSIZE; d -> d_sbsize = BSD_SBSIZE; -#if defined (i386) || defined (__sparc__) || defined (__arm__) +#if !defined (__alpha__) d -> d_npartitions = 4; pp = &d -> d_partitions[2]; /* Partition C should be the NetBSD partition */ pp -> p_offset = get_start_sect(p); @@ -699,18 +715,18 @@ xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d) { int t, sector; -#if defined (i386) || defined (__sparc__) || defined (__arm__) +#if !defined (__alpha__) sector = (p ? get_start_sect(p) : 0); #elif defined (__alpha__) sector = 0; #endif - if (ext2_llseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1) + if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1) fatal (unable_to_seek); - if (BSD_BBSIZE != read (fd, buffer, BSD_BBSIZE)) + if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE)) fatal (unable_to_read); - bcopy (&buffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], + bcopy (&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], d, sizeof (struct xbsd_disklabel)); for (t = d -> d_npartitions; t < BSD_MAXPARTITIONS; t++) @@ -733,7 +749,7 @@ xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d) { int sector; -#if defined (i386) || defined (__sparc__) || defined (__arm__) +#if !defined (__alpha__) && !defined (__powerpc__) sector = get_start_sect(p) + BSD_LABELSECTOR; #elif defined (__alpha__) || defined (__powerpc__) sector = BSD_LABELSECTOR; @@ -745,17 +761,18 @@ xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d) /* This is necessary if we want to write the bootstrap later, otherwise we'd write the old disklabel with the bootstrap. */ - bcopy (d, &buffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], + bcopy (d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], sizeof (struct xbsd_disklabel)); #if defined (__alpha__) && BSD_LABELSECTOR == 0 - alpha_bootblock_checksum (buffer); - if (ext2_llseek (fd, 0, SEEK_SET) == -1) + alpha_bootblock_checksum (disklabelbuffer); + if (ext2_llseek (fd, (ext2_loff_t) 0, SEEK_SET) == -1) fatal (unable_to_seek); - if (BSD_BBSIZE != write (fd, buffer, BSD_BBSIZE)) + if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE)) fatal (unable_to_write); #else - if (ext2_llseek (fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1) + if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE + BSD_LABELOFFSET, + SEEK_SET) == -1) fatal (unable_to_seek); if (sizeof (struct xbsd_disklabel) != write (fd, d, sizeof (struct xbsd_disklabel))) fatal (unable_to_write); @@ -774,7 +791,7 @@ sync_disks (void) sleep (4); } -#if defined (i386) || defined (__sparc__) || defined (__arm__) +#if !defined (__alpha__) static int xbsd_translate_fstype (int linux_type) { @@ -798,16 +815,18 @@ static void xbsd_link_part (void) { int k, i; + struct partition *p; k = get_partition (1, partitions); if (!xbsd_check_new_partition (&i)) return; - xbsd_dlabel.d_partitions[i].p_size = get_nr_sects(part_table[k]); - xbsd_dlabel.d_partitions[i].p_offset = get_start_sect(part_table[k]); - xbsd_dlabel.d_partitions[i].p_fstype = - xbsd_translate_fstype (part_table[k] -> sys_ind); + p = get_part_table(k); + + xbsd_dlabel.d_partitions[i].p_size = get_nr_sects(p); + xbsd_dlabel.d_partitions[i].p_offset = get_start_sect(p); + xbsd_dlabel.d_partitions[i].p_fstype = xbsd_translate_fstype(p->sys_ind); } #endif diff --git a/fdisk/fdiskbsdlabel.h b/fdisk/fdiskbsdlabel.h index 1a06a08d..68747d48 100644 --- a/fdisk/fdiskbsdlabel.h +++ b/fdisk/fdiskbsdlabel.h @@ -43,10 +43,10 @@ #define BSD_LINUX_BOOTDIR "/usr/ucb/mdec" -#if defined (i386) || defined (__sparc__) || defined (__arm__) +#if defined (i386) || defined (__sparc__) || defined (__arm__) || defined (__mips__) #define BSD_LABELSECTOR 1 #define BSD_LABELOFFSET 0 -#elif defined (__alpha__) || defined (__powerpc__) +#elif defined (__alpha__) || defined (__powerpc__) || defined (__ia64__) #define BSD_LABELSECTOR 0 #define BSD_LABELOFFSET 64 #else @@ -182,10 +182,11 @@ static char *xbsd_dktypenames[] = { #define BSD_FS_BOOT 13 /* partition contains bootstrap */ #define BSD_FS_ADOS 14 /* AmigaDOS fast file system */ #define BSD_FS_HFS 15 /* Macintosh HFS */ +#define BSD_FS_ADVFS 16 /* Digital Unix AdvFS */ /* this is annoying, but it's also the way it is :-( */ #ifdef __alpha__ -#define BSD_FS_EXT2 8 /* MS-DOS file system */ +#define BSD_FS_EXT2 8 /* ext2 file system */ #else #define BSD_FS_MSDOS 8 /* MS-DOS file system */ #endif @@ -212,6 +213,7 @@ static struct systypes xbsd_fstypes[] = { {BSD_FS_BOOT, "boot"}, {BSD_FS_ADOS, "ADOS"}, {BSD_FS_HFS, "HFS"}, + {BSD_FS_ADVFS, "AdvFS"}, { 0, NULL } }; #define BSD_FSMAXTYPES (SIZE(xbsd_fstypes)-1) diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c index b2870e65..97e6c595 100644 --- a/fdisk/fdisksgilabel.c +++ b/fdisk/fdisksgilabel.c @@ -36,17 +36,40 @@ static short volumes=1; typedef struct { int first; int last; } freeblocks; static freeblocks freelist[17]; /* 16 partitions can produce 17 vacant slots */ -void setfreelist( int i, int f, int l ) \ - { freelist[i].first = f; freelist[i].last = l; return; } -void add2freelist( int f, int l ) \ - { int i = 0; for( ; i<17 ; i++ ) { if(freelist[i].last==0) break; }\ - setfreelist( i, f, l ); return; } -void clearfreelist( void ) \ - { int i = 0; for( ; i<17 ; i++ ) { setfreelist( i, 0, 0 ); } return; } -int isinfreelist( int b ) \ - { int i = 0; for( ; i<17 ; i++ )\ - { if( ( freelist[i].first <= b ) && ( freelist[i].last >= b) )\ - { return freelist[i].last; } } return 0; } + +static void +setfreelist( int i, int f, int l ) { + freelist[i].first = f; + freelist[i].last = l; +} + +static void +add2freelist( int f, int l ) { + int i = 0; + for( ; i<17 ; i++ ) { + if(freelist[i].last==0) break; + } + setfreelist( i, f, l ); +} + +static void +clearfreelist(void) { + int i = 0; + for( ; i<17 ; i++ ) { + setfreelist( i, 0, 0 ); + } +} + +static int +isinfreelist( int b ) { + int i = 0; + for( ; i<17 ; i++ ) { + if (freelist[i].first <= b && freelist[i].last >= b) { + return freelist[i].last; + } + } + return 0; +} /* return last vacant block of this stride (never 0). */ /* the '>=' is not quite correct, but simplifies the code */ /* @@ -63,53 +86,49 @@ struct systypes sgi_sys_types[] = { {SGI_EFS, N_("SGI efs")}, {0x08, N_("SGI lvol")}, {0x09, N_("SGI rlvol")}, - {0x0A, N_("SGI xfs")}, - {0x0B, N_("SGI xlvol")}, - {0x0C, N_("SGI rxlvol")}, + {0x0a, N_("SGI xfs")}, + {0x0b, N_("SGI xlvol")}, + {0x0c, N_("SGI rxlvol")}, {LINUX_SWAP, N_("Linux swap")}, {LINUX_NATIVE,N_("Linux native")}, + {0x8e, N_("Linux LVM")}, {0, NULL } }; -static inline unsigned short __swap16(unsigned short x) { +static inline unsigned short +__swap16(unsigned short x) { return (((__u16)(x) & 0xFF) << 8) | (((__u16)(x) & 0xFF00) >> 8); } -static inline __u32 __swap32(__u32 x) { + +static inline __u32 +__swap32(__u32 x) { return (((__u32)(x) & 0xFF) << 24) | (((__u32)(x) & 0xFF00) << 8) | (((__u32)(x) & 0xFF0000) >> 8) | (((__u32)(x) & 0xFF000000) >> 24); } -static -int -sgi_get_nsect( void ) -{ +static int +sgi_get_nsect(void) { return SSWAP16(sgilabel->devparam.nsect); } -static -int -sgi_get_ntrks( void ) -{ +static int +sgi_get_ntrks(void) { return SSWAP16(sgilabel->devparam.ntrks); } #if 0 static int -sgi_get_head_vol0( void ) -{ +sgi_get_head_vol0(void) { return SSWAP16(sgilabel->devparam.head_vol0); } static int -sgi_get_bytes( void ) -{ +sgi_get_bytes(void) { return SSWAP16(sgilabel->devparam.bytes); } #endif -static -int -sgi_get_pcylcount( void ) -{ +static int +sgi_get_pcylcount(void) { return SSWAP16(sgilabel->devparam.pcylcount); } @@ -121,23 +140,19 @@ sgi_nolabel() partitions = 4; } -unsigned int -two_s_complement_32bit_sum( - unsigned int* base, - int size /* in bytes */ ) -{ +static unsigned int +two_s_complement_32bit_sum(unsigned int* base, int size /* in bytes */ ) { int i=0; unsigned int sum=0; + size = size / sizeof( unsigned int ); for( i=0; i 512) { fprintf(stderr, _("According to MIPS Computer Systems, Inc the " @@ -174,8 +189,7 @@ int check_sgi_label() } void -sgi_list_table( int xtra ) -{ +sgi_list_table( int xtra ) { int i, w; char *type; @@ -241,14 +255,12 @@ sgi_list_table( int xtra ) } int -sgi_get_start_sector( int i ) -{ +sgi_get_start_sector( int i ) { return SSWAP32(sgilabel->partitions[i].start_sector); } int -sgi_get_num_sectors( int i ) -{ +sgi_get_num_sectors( int i ) { return SSWAP32(sgilabel->partitions[i].num_sectors); } @@ -259,13 +271,13 @@ sgi_get_sysid( int i ) } int -sgi_get_bootpartition( void ) +sgi_get_bootpartition(void) { return SSWAP16(sgilabel->boot_part); } int -sgi_get_swappartition( void ) +sgi_get_swappartition(void) { return SSWAP16(sgilabel->swap_part); } @@ -274,25 +286,20 @@ void sgi_set_bootpartition( int i ) { sgilabel->boot_part = SSWAP16(((short)i)); - return; } -int -sgi_get_lastblock( void ) -{ +static int +sgi_get_lastblock(void) { return heads * sectors * cylinders; } void -sgi_set_swappartition( int i ) -{ +sgi_set_swappartition( int i ) { sgilabel->swap_part = SSWAP16(((short)i)); - return; } static int -sgi_check_bootfile( const char* aFile ) -{ +sgi_check_bootfile( const char* aFile ) { if( strlen( aFile ) < 3 ) /* "/a\n" is minimum */ { printf( _("\nInvalid Bootfile!\n" @@ -342,23 +349,21 @@ sgi_set_bootfile( const char* aFile ) } printf( _("\n\tBootfile is changed to \"%s\".\n"), sgilabel->boot_file ); } - return; } void -create_sgiinfo( void ) +create_sgiinfo(void) { /* I keep SGI's habit to write the sgilabel to the second block */ sgilabel->directory[0].vol_file_start = SSWAP32( 2 ); sgilabel->directory[0].vol_file_size = SSWAP32( sizeof( sgiinfo ) ); strncpy( sgilabel->directory[0].vol_file_name, "sgilabel",8 ); - return; } -sgiinfo * fill_sgiinfo( void ); +sgiinfo * fill_sgiinfo(void); void -sgi_write_table( void ) +sgi_write_table(void) { sgilabel->csum = 0; sgilabel->csum = SSWAP32( two_s_complement_32bit_sum( @@ -385,13 +390,10 @@ sgi_write_table( void ) fatal(unable_to_write); free( info ); } - return; } -static -int -compare_start( int *x, int *y ) -{ +static int +compare_start( int *x, int *y ) { /* * sort according to start sectors * and prefers largest partition: @@ -410,10 +412,8 @@ compare_start( int *x, int *y ) return( a - b ); } -static -int -sgi_gaps() -{ +static int +sgi_gaps(void) { /* * returned value is: * = 0 : disk is properly filled to the rim @@ -582,12 +582,11 @@ sgi_change_sysid( int i, int sys ) return; } sgilabel->partitions[i].id = SSWAP32(sys); - return; } -int -sgi_entire( void ) -{ /* returns partition index of first entry marked as entire disk */ +/* returns partition index of first entry marked as entire disk */ +static int +sgi_entire(void) { int i=0; for( i=0; i<16; i++ ) if( sgi_get_sysid(i) == SGI_VOLUME ) @@ -595,52 +594,33 @@ sgi_entire( void ) return -1; } -int -sgi_num_partitions( void ) -{ - int i=0, - n=0; - for( i=0; i<16; i++ ) - if( sgi_get_num_sectors(i)!=0 ) - n++; - return n; -} - -static -void -sgi_set_partition( int i, uint start, uint length, int sys ) -{ +static void +sgi_set_partition( int i, uint start, uint length, int sys ) { sgilabel->partitions[i].id = SSWAP32( sys ); sgilabel->partitions[i].num_sectors = SSWAP32( length ); sgilabel->partitions[i].start_sector = SSWAP32( start ); - changed[i] = 1; - if( sgi_gaps(0) < 0 ) /* rebuild freelist */ + set_changed(i); + if( sgi_gaps() < 0 ) /* rebuild freelist */ printf(_("Do You know, You got a partition overlap on the disk?\n")); - return; } -static -void -sgi_set_entire( void ) -{ +static void +sgi_set_entire(void) { int n; - for( n=10; nsys_ind ) + if( get_part_table(i)->sys_ind ) { - old[i].sysid = part_table[i]->sys_ind; - old[i].start = get_start_sect( part_table[i] ); - old[i].nsect = get_nr_sects( part_table[i] ); + old[i].sysid = get_part_table(i)->sys_ind; + old[i].start = get_start_sect( get_part_table(i) ); + old[i].nsect = get_nr_sects( get_part_table(i) ); printf( _("Trying to keep parameters of partition %d.\n"), i ); if( debug ) printf( _("ID=%02x\tSTART=%d\tLENGTH=%d\n"), @@ -788,7 +765,7 @@ create_sgilabel( void ) } } } - memset(buffer, 0, SECTOR_SIZE); + memset(MBRbuffer, 0, sizeof(MBRbuffer)); sgilabel->magic = SSWAP32(SGI_LABEL_MAGIC); sgilabel->boot_part = SSWAP16(0); sgilabel->swap_part = SSWAP16(1); strncpy( @@ -833,35 +810,34 @@ create_sgilabel( void ) sgi_set_partition( i, old[i].start, old[i].nsect, old[i].sysid ); } } - return; } void -sgi_set_ilfact( void ) +sgi_set_ilfact(void) { /* do nothing in the beginning */ } void -sgi_set_rspeed( void ) +sgi_set_rspeed(void) { /* do nothing in the beginning */ } void -sgi_set_pcylcount( void ) +sgi_set_pcylcount(void) { /* do nothing in the beginning */ } void -sgi_set_xcyl( void ) +sgi_set_xcyl(void) { /* do nothing in the beginning */ } void -sgi_set_ncyl( void ) +sgi_set_ncyl(void) { /* do nothing in the beginning */ } @@ -870,7 +846,7 @@ sgi_set_ncyl( void ) */ sgiinfo* -fill_sgiinfo( void ) +fill_sgiinfo(void) { sgiinfo*info=calloc( 1, sizeof(sgiinfo) ); info->magic=SSWAP32(SGI_INFO_MAGIC); diff --git a/fdisk/fdisksgilabel.h b/fdisk/fdisksgilabel.h index fa35f8f3..a0c3a105 100644 --- a/fdisk/fdisksgilabel.h +++ b/fdisk/fdisksgilabel.h @@ -93,16 +93,16 @@ typedef struct { : (__u32)(x)) /* fdisk.c */ -#define sgilabel ((sgi_partition *)buffer) +#define sgilabel ((sgi_partition *)MBRbuffer) #define sgiparam (sgilabel->devparam) -extern char buffer[MAX_SECTOR_SIZE]; -extern char changed[MAXIMUM_PARTS]; +extern char MBRbuffer[MAX_SECTOR_SIZE]; extern uint heads, sectors, cylinders; extern int show_begin; extern int sgi_label; extern char *partition_type(unsigned char type); extern void update_units(void); extern char read_chars(char *mesg); +extern void set_changed(int); /* fdisksgilabel.c */ extern struct systypes sgi_sys_types[]; diff --git a/fdisk/fdisksunlabel.c b/fdisk/fdisksunlabel.c index 48916ad4..3ec5624a 100644 --- a/fdisk/fdisksunlabel.c +++ b/fdisk/fdisksunlabel.c @@ -51,6 +51,7 @@ struct systypes sun_sys_types[] = { {8, N_("SunOS home")}, {LINUX_SWAP, N_("Linux swap")}, {LINUX_NATIVE, N_("Linux native")}, + {0x8e, N_("Linux LVM")}, { 0, NULL } }; @@ -87,25 +88,25 @@ void guess_device_type(int fd) { } } -void set_sun_partition(int i, uint start, uint stop, int sysid) -{ +static void +set_sun_partition(int i, uint start, uint stop, int sysid) { sunlabel->infos[i].id = sysid; sunlabel->partitions[i].start_cylinder = SSWAP32(start / (heads * sectors)); sunlabel->partitions[i].num_sectors = SSWAP32(stop - start); - changed[i] = 1; + set_changed(i); } -void sun_nolabel(void) -{ +void +sun_nolabel(void) { sun_label = 0; sunlabel->magic = 0; partitions = 4; } -int check_sun_label(void) -{ +int +check_sun_label(void) { unsigned short *ush; int csum; @@ -148,6 +149,10 @@ struct sun_predefined_drives { {"Quantum","ProDrive 80S",1,832,2,834,6,34,3662}, {"Quantum","ProDrive 105S",1,974,2,1019,6,35,3662}, {"CDC","Wren IV 94171-344",3,1545,2,1549,9,46,3600}, +{"IBM","DPES-31080",0,4901,2,4903,4,108,5400}, +{"IBM","DORS-32160",0,1015,2,1017,67,62,5400}, +{"IBM","DNES-318350",0,11199,2,11474,10,320,7200}, +{"SEAGATE","ST34371",0,3880,2,3882,16,135,7228}, {"","SUN0104",1,974,2,1019,6,35,3662}, {"","SUN0207",4,1254,2,1272,9,36,3600}, {"","SUN0327",3,1545,2,1549,9,46,3600}, @@ -162,8 +167,8 @@ struct sun_predefined_drives { {"IOMEGA","Jaz",0,1019,2,1021,64,32,5394}, }; -struct sun_predefined_drives * -sun_autoconfigure_scsi() { +static struct sun_predefined_drives * +sun_autoconfigure_scsi(void) { struct sun_predefined_drives *p = NULL; #ifdef SCSI_IOCTL_GET_IDLUN @@ -193,16 +198,18 @@ sun_autoconfigure_scsi() { pfd = fopen("/proc/scsi/scsi","r"); if (pfd) { while (fgets(buffer2,2048,pfd)) { - if (!strcmp(buffer, buffer2)) { + if (!strcmp(buffer, buffer2)) { if (fgets(buffer2,2048,pfd)) { q = strstr(buffer2,"Vendor: "); if (q) { q += 8; vendor = q; - q = strstr(q," Model: "); + q = strstr(q," "); + *q++ = 0; /* truncate vendor name */ + q = strstr(q,"Model: "); if (q) { *q = 0; - q += 8; + q += 7; model = q; q = strstr(q," Rev: "); if (q) { @@ -247,7 +254,7 @@ void create_sunlabel(void) #else other_endian = 0; #endif - memset(buffer, 0, SECTOR_SIZE); + memset(MBRbuffer, 0, sizeof(MBRbuffer)); sunlabel->magic = SSWAP16(SUN_LABEL_MAGIC); if (!floppy) { puts(_("Drive type\n" @@ -328,14 +335,19 @@ void create_sunlabel(void) sunlabel->ntrks = SSWAP16(p->ntrks); sunlabel->nsect = SSWAP16(p->nsect); sunlabel->rspeed = SSWAP16(p->rspeed); + sunlabel->ilfact = SSWAP16(1); cylinders = p->ncyl; heads = p->ntrks; sectors = p->nsect; puts(_("You may change all the disk params from the x menu")); } - sprintf(buffer, "%s%s%s cyl %d alt %d hd %d sec %d", - p ? p->vendor : "", (p && *p->vendor) ? " " : "", p ? p->model : (floppy ? _("3,5\" floppy") : _("Linux custom")), - cylinders, SSWAP16(sunlabel->nacyl), heads, sectors); + + sprintf(sunlabel->info, "%s%s%s cyl %d alt %d hd %d sec %d", + p ? p->vendor : "", + (p && *p->vendor) ? " " : "", + p ? p->model : (floppy ? _("3,5\" floppy") : _("Linux custom")), + cylinders, SSWAP16(sunlabel->nacyl), heads, sectors); + sunlabel->ntrks = SSWAP16(heads); sunlabel->nsect = SSWAP16(sectors); sunlabel->ncyl = SSWAP16(cylinders); @@ -358,26 +370,28 @@ void create_sunlabel(void) csum ^= *ush++; sunlabel->csum = csum; } - for (i = 1; i < MAXIMUM_PARTS; i++) - changed[i] = 0; - changed[0] = 1; + + set_all_unchanged(); + set_changed(0); get_boot(create_empty); } -void toggle_sunflags(int i, unsigned char mask) -{ +void +toggle_sunflags(int i, unsigned char mask) { if (sunlabel->infos[i].flags & mask) sunlabel->infos[i].flags &= ~mask; else sunlabel->infos[i].flags |= mask; - changed[i] = 1; + set_changed(i); } -void fetch_sun(uint *starts, uint *lens, uint *start, uint *stop) -{ +static void +fetch_sun(uint *starts, uint *lens, uint *start, uint *stop) { int i, continuous = 1; *start = 0; *stop = cylinders * heads * sectors; for (i = 0; i < partitions; i++) { - if (sunlabel->partitions[i].num_sectors && sunlabel->infos[i].id && sunlabel->infos[i].id != WHOLE_DISK) { + if (sunlabel->partitions[i].num_sectors + && sunlabel->infos[i].id + && sunlabel->infos[i].id != WHOLE_DISK) { starts[i] = SSWAP32(sunlabel->partitions[i].start_cylinder) * heads * sectors; lens[i] = SSWAP32(sunlabel->partitions[i].num_sectors); if (continuous) { @@ -386,7 +400,9 @@ void fetch_sun(uint *starts, uint *lens, uint *start, uint *stop) else if (starts[i] + lens[i] >= *stop) *stop = starts[i]; else - continuous = 0; /* There will be probably more gaps than one, so lets check afterwards */ + continuous = 0; + /* There will be probably more gaps + than one, so lets check afterwards */ } } else { starts[i] = 0; @@ -396,16 +412,17 @@ void fetch_sun(uint *starts, uint *lens, uint *start, uint *stop) } static uint *verify_sun_starts; -int verify_sun_cmp(int *a, int *b) -{ + +static int +verify_sun_cmp(int *a, int *b) { if (*a == -1) return 1; if (*b == -1) return -1; if (verify_sun_starts[*a] > verify_sun_starts[*b]) return 1; return -1; } -void verify_sun(void) -{ +void +verify_sun(void) { uint starts[8], lens[8], start, stop; int i,j,k,starto,endo; int array[8]; @@ -466,8 +483,8 @@ void verify_sun(void) printf(_("Unused gap - sectors %d-%d\n"),start,stop); } -void add_sun_partition(int n, int sys) -{ +void +add_sun_partition(int n, int sys) { uint start, stop, stop2; uint starts[8], lens[8]; int whole_disk = 0; @@ -701,4 +718,3 @@ sun_write_table(void) { if (write(fd, sunlabel, SECTOR_SIZE) != SECTOR_SIZE) fatal(unable_to_write); } - diff --git a/fdisk/fdisksunlabel.h b/fdisk/fdisksunlabel.h index 1a75713c..424f462e 100644 --- a/fdisk/fdisksunlabel.h +++ b/fdisk/fdisksunlabel.h @@ -30,21 +30,22 @@ typedef struct { #define SUN_LABEL_MAGIC 0xDABE #define SUN_LABEL_MAGIC_SWAPPED 0xBEDA -#define sunlabel ((sun_partition *)buffer) +#define sunlabel ((sun_partition *)MBRbuffer) #define SSWAP16(x) (other_endian ? __swap16(x) \ : (__u16)(x)) #define SSWAP32(x) (other_endian ? __swap32(x) \ : (__u32)(x)) /* fdisk.c */ -extern char changed[MAXIMUM_PARTS]; -extern char buffer[MAX_SECTOR_SIZE]; +extern char MBRbuffer[MAX_SECTOR_SIZE]; extern uint heads, sectors, cylinders; extern int show_begin; extern int sun_label; extern char *partition_type(unsigned char type); extern void update_units(void); extern char read_chars(char *mesg); +extern void set_all_unchanged(void); +extern void set_changed(int); /* fdisksunlabel.c */ #define SUNOS_SWAP 3 diff --git a/fdisk/i386_sys_types.c b/fdisk/i386_sys_types.c index f3624724..0cad6fa7 100644 --- a/fdisk/i386_sys_types.c +++ b/fdisk/i386_sys_types.c @@ -58,8 +58,10 @@ struct systypes i386_sys_types[] = { {0x85, N_("Linux extended")}, {0x86, N_("NTFS volume set")}, {0x87, N_("NTFS volume set")}, + {0x8e, N_("Linux LVM")}, {0x93, N_("Amoeba")}, {0x94, N_("Amoeba BBT")}, /* (bad block table) */ + {0x9f, N_("BSD/OS")}, /* BSDI */ {0xa0, N_("IBM Thinkpad hibernation")}, {0xa5, N_("BSD/386")}, {0xa6, N_("OpenBSD")}, diff --git a/fdisk/llseek.c b/fdisk/llseek.c index a9cd5a3a..9e00d3e6 100644 --- a/fdisk/llseek.c +++ b/fdisk/llseek.c @@ -25,7 +25,7 @@ extern ext2_loff_t ext2_llseek (unsigned int, ext2_loff_t, unsigned int); #else /* HAVE_LLSEEK */ -#ifdef __alpha__ +#if defined(__alpha__) || defined(__ia64__) #define my_llseek lseek diff --git a/fdisk/partname.c b/fdisk/partname.c new file mode 100644 index 00000000..b09b958a --- /dev/null +++ b/fdisk/partname.c @@ -0,0 +1,46 @@ +#include +#include +#include +#include "common.h" + +/* + * return partition name - uses static storage unless buf is supplied + */ +static char * +partnamebf(char *dev, int pno, int lth, int bufsiz, char *bufp) { + static char buffer[80]; + char *p; + int w, wp; + + if (!bufp) { + bufp = buffer; + bufsiz = sizeof(buffer); + } + + w = strlen(dev); + p = ""; + + if (isdigit(dev[w-1])) + p = "p"; + + /* devfs kludge - note: fdisk partition names are not supposed + to equal kernel names, so there is no reason to do this */ + if (strcmp (dev + w - 4, "disc") == 0) { + w -= 4; + p = "part"; + } + + wp = strlen(p); + + if (lth) { + sprintf(bufp, "%*.*s%s%-2u", lth-wp-2, w, dev, p, pno); + } else { + sprintf(bufp, "%.*s%s%-2u", w, dev, p, pno); + } + return bufp; +} + +char * +partname(char *dev, int pno, int lth) { + return partnamebf(dev, pno, lth, 0, NULL); +} diff --git a/fdisk/sfdisk.8 b/fdisk/sfdisk.8 index e7f3e82b..0c62c2e9 100644 --- a/fdisk/sfdisk.8 +++ b/fdisk/sfdisk.8 @@ -265,6 +265,17 @@ Certain Disk Managers and boot loaders (such as OSBS, but not LILO or the OS/2 Boot Manager) also live in this empty space, so maybe you want this option if you use one. .TP +.BR \-E " or " \-\-DOS-extended +Take the starting sector numbers of "inner" extended partitions +to be relative to the starting cylinder boundary of the outer one, +(like some versions of DOS do) rather than to the starting sector +(like Linux does). +(The fact that there is a difference here means that one should +always let extended partitions start at cylinder boundaries if +DOS and Linux should interpret the partition table in the same way. +Of course one can only know where cylinder boundaries are when +one knows what geometry DOS will use for this disk.) +.TP .BR \-\-IBM " or " \-\-leave\-last Certain IBM diagnostic programs assume that they can use the last cylinder on a disk for disk-testing purposes. If you think @@ -339,7 +350,7 @@ details, see the .B lilo documentation. .LP -Each partition has a type, its `Id', and if this type is 5 +Each partition has a type, its `Id', and if this type is 5 or f .IR "" "(`" "extended partition" "')" the starting sector of the partition again contains 4 partition descriptors. MSDOS only uses the @@ -347,7 +358,7 @@ first two of these: the first one an actual data partition, and the second one again an extended partition (or empty). In this way one gets a chain of extended partitions. Other operating systems have slightly different conventions. -Linux also accepts type 85 as equivalent to 5 - this can be +Linux also accepts type 85 as equivalent to 5 and f - this can be useful if one wants to have extended partitions under Linux past the 1024 cylinder boundary, without DOS FDISK hanging. (If there is no good reason, you should just use 5, which is diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c index 7bf7fd83..206ea28d 100644 --- a/fdisk/sfdisk.c +++ b/fdisk/sfdisk.c @@ -45,9 +45,9 @@ #include #include #include +#include #include /* _syscall */ #include /* HDIO_GETGEO */ -#include /* BLKGETSIZE */ #include "nls.h" #include "common.h" @@ -69,8 +69,11 @@ int exit_status = 0; int force = 0; /* 1: do what I say, even if it is stupid ... */ int quiet = 0; /* 1: suppress all warnings */ +/* IA-64 gcc spec file currently does -DLinux... */ +#undef Linux int Linux = 0; /* 1: suppress warnings irrelevant for Linux */ int DOS = 0; /* 1: shift extended partitions by #sectors, not 1 */ +int DOS_extended = 0; /* 1: use starting cylinder boundary of extd partn */ int dump = 0; /* 1: list in a format suitable for later input */ int verify = 0; /* 1: check that listed partition is reasonable */ int no_write = 0; /* 1: do not actually write to disk */ @@ -80,7 +83,7 @@ int opt_list = 0; char *save_sector_file = NULL; char *restore_sector_file = NULL; -void +static void warn(char *s, ...) { va_list p; @@ -91,7 +94,7 @@ warn(char *s, ...) { va_end(p); } -void +static void error(char *s, ...) { va_list p; @@ -102,7 +105,7 @@ error(char *s, ...) { va_end(p); } -void +static void fatal(char *s, ...) { va_list p; @@ -125,23 +128,25 @@ fatal(char *s, ...) { * On the other hand, a 32 bit sector number is OK until 2TB. * The routines _llseek and sseek below are the only ones that * know about the loff_t type. + * + * Note: we use 512-byte sectors here, irrespective of the hardware ss. */ -#ifndef __alpha__ +#if !defined (__alpha__) && !defined (__ia64__) static _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh); #endif -int +static int sseek(char *dev, unsigned int fd, unsigned long s) { loff_t in, out; in = ((loff_t) s << 9); out = 1; -#ifndef __alpha__ +#if !defined (__alpha__) && !defined (__ia64__) if (_llseek (fd, in>>32, in & 0xffffffff, &out, SEEK_SET) != 0) { #else - if ((out = lseek(fd, in, SEEK_SET)) != in) { + if ((out = lseek(fd, in, SEEK_SET)) != in) { #endif perror("llseek"); error(_("seek error on %s - cannot seek to %lu\n"), dev, s); @@ -172,7 +177,7 @@ struct sector { char data[512]; } *sectorhead; -void +static void free_sectors(void) { struct sector *s; @@ -183,7 +188,7 @@ free_sectors(void) { } } -struct sector * +static struct sector * get_sector(char *dev, int fd, unsigned long sno) { struct sector *s; @@ -198,7 +203,8 @@ get_sector(char *dev, int fd, unsigned long sno) { fatal(_("out of memory - giving up\n")); if (read(fd, s->data, sizeof(s->data)) != sizeof(s->data)) { - perror("read"); + if (errno) /* 0 in case we read past end-of-disk */ + perror("read"); error(_("read error on %s - cannot read sector %lu\n"), dev, sno); free(s); return 0; @@ -212,7 +218,7 @@ get_sector(char *dev, int fd, unsigned long sno) { return s; } -int +static int msdos_signature (struct sector *s) { if (*(unsigned short *) (s->data + 0x1fe) != 0xaa55) { error(_("ERROR: sector %lu does not have an msdos signature\n"), @@ -222,7 +228,7 @@ msdos_signature (struct sector *s) { return 1; } -int +static int write_sectors(char *dev, int fd) { struct sector *s; @@ -241,7 +247,7 @@ write_sectors(char *dev, int fd) { return 1; } -void +static void ulong_to_chars(unsigned long u, char *uu) { int i; @@ -251,7 +257,7 @@ ulong_to_chars(unsigned long u, char *uu) { } } -unsigned long +static unsigned long chars_to_ulong(unsigned char *uu) { int i; unsigned long u = 0; @@ -261,7 +267,7 @@ chars_to_ulong(unsigned char *uu) { return u; } -int +static int save_sectors(char *dev, int fdin) { struct sector *s; char ss[516]; @@ -295,9 +301,9 @@ save_sectors(char *dev, int fdin) { return 1; } -void reread_disk_partition(char *dev, int fd); +static void reread_disk_partition(char *dev, int fd); -int +static int restore_sectors(char *dev) { int fdin, fdout, ct; struct stat statbuf; @@ -370,6 +376,8 @@ restore_sectors(char *dev) { * unsigned short cylinders; * unsigned long start; * }; + * + * For large disks g.cylinders is truncated, so we use BLKGETSIZE. */ /* @@ -383,52 +391,64 @@ restore_sectors(char *dev) { struct geometry { unsigned long cylindersize; unsigned long heads, sectors, cylinders; + unsigned long start; } B, F, U; -void -get_cylindersize(char *dev, int fd, int silent) { +static struct geometry +get_geometry(char *dev, int fd, int silent) { struct hd_geometry g; - int ioctl_ok = 0; + long size; + struct geometry R; - B.heads = B.sectors = B.cylinders = 0; + if (ioctl(fd, BLKGETSIZE, &size)) { + size = 0; + if (!silent) + printf(_("Disk %s: cannot get size\n"), dev); + } + if (ioctl(fd, HDIO_GETGEO, &g)) { + g.heads = g.sectors = g.cylinders = g.start = 0; + if (!silent) + printf(_("Disk %s: cannot get geometry\n"), dev); + } + R.heads = g.heads; + R.sectors = g.sectors; + R.cylindersize = R.heads * R.sectors; + R.cylinders = (R.cylindersize ? size / R.cylindersize : 0); + R.start = g.start; + return R; +} - if (!ioctl(fd, HDIO_GETGEO, &g)) { - ioctl_ok = 1; +static void +get_cylindersize(char *dev, int fd, int silent) { + struct geometry R; - B.heads = g.heads; - B.sectors = g.sectors; - B.cylinders = g.cylinders; - } + R = get_geometry(dev, fd, silent); - if (U.heads) - B.heads = U.heads; - if (U.sectors) - B.sectors = U.sectors; - if (U.cylinders) - B.cylinders = U.cylinders; + B.heads = (U.heads ? U.heads : R.heads); + B.sectors = (U.sectors ? U.sectors : R.sectors); + B.cylinders = (U.cylinders ? U.cylinders : R.cylinders); B.cylindersize = B.heads * B.sectors; - if (ioctl_ok) { - if (g.start && !force) { - warn( - _("Warning: start=%d - this looks like a partition rather than\n" - "the entire disk. Using fdisk on it is probably meaningless.\n" - "[Use the --force option if you really want this]\n"), g.start); - exit(1); - } - if (B.heads != g.heads) - warn(_("Warning: HDIO_GETGEO says that there are %d heads\n"), - g.heads); - if (B.sectors != g.sectors) - warn(_("Warning: HDIO_GETGEO says that there are %d sectors\n"), - g.sectors); - if (B.cylinders != g.cylinders) - warn(_("Warning: HDIO_GETGEO says that there are %d cylinders\n"), - g.cylinders); - } else if (!silent) - if (!B.heads || !B.sectors || !B.cylinders) - printf(_("Disk %s: cannot get geometry\n"), dev); + if (R.start && !force) { + warn( + _("Warning: start=%d - this looks like a partition rather than\n" + "the entire disk. Using fdisk on it is probably meaningless.\n" + "[Use the --force option if you really want this]\n"), R.start); + exit(1); + } + + if (R.heads && B.heads != R.heads) + warn(_("Warning: HDIO_GETGEO says that there are %d heads\n"), + R.heads); + if (R.sectors && B.sectors != R.sectors) + warn(_("Warning: HDIO_GETGEO says that there are %d sectors\n"), + R.sectors); + if (R.cylinders && B.cylinders != R.cylinders + && B.cylinders < 65536 && R.cylinders < 65536) + warn(_("Warning: BLKGETSIZE/HDIO_GETGEO says that there are %d cylinders\n"), + R.cylinders); + if (B.sectors > 63) warn(_("Warning: unlikely number of sectors (%d) - usually at most 63\n" "This will give problems with all software that uses C/H/S addressing.\n"), @@ -444,7 +464,7 @@ chs zero_chs = { 0,0,0 }; typedef struct { unsigned long h,s,c; } longchs; longchs zero_longchs; -chs +static chs longchs_to_chs (longchs aa, struct geometry G) { chs a; @@ -461,7 +481,7 @@ longchs_to_chs (longchs aa, struct geometry G) { return a; } -longchs +static longchs chs_to_longchs (chs a) { longchs aa; @@ -472,7 +492,7 @@ chs_to_longchs (chs a) { return aa; } -longchs +static longchs ulong_to_longchs (unsigned long sno, struct geometry G) { longchs aa; @@ -486,27 +506,29 @@ ulong_to_longchs (unsigned long sno, struct geometry G) { } } -unsigned long -longchs_to_ulong (longchs aa, struct geometry G) { - return (aa.c*G.cylindersize + aa.h*G.sectors + aa.s - 1); -} - -chs +static chs ulong_to_chs (unsigned long sno, struct geometry G) { return longchs_to_chs(ulong_to_longchs(sno, G), G); } -unsigned long +#if 0 +static unsigned long +longchs_to_ulong (longchs aa, struct geometry G) { + return (aa.c*G.cylindersize + aa.h*G.sectors + aa.s - 1); +} + +static unsigned long chs_to_ulong (chs a, struct geometry G) { return longchs_to_ulong(chs_to_longchs(a), G); } +#endif -int +static int is_equal_chs (chs a, chs b) { return (a.h == b.h && a.s == b.s && a.c == b.c); } -int +static int chs_ok (chs a, char *v, char *w) { longchs aa = chs_to_longchs(a); int ret = 1; @@ -549,7 +571,7 @@ chs_ok (chs a, char *v, char *w) { /* List of partition types now in i386_sys_types.c */ -const char * +static const char * sysname(unsigned char type) { struct systypes *s; @@ -559,7 +581,7 @@ sysname(unsigned char type) { return _("Unknown"); } -void +static void list_types(void) { struct systypes *s; @@ -568,14 +590,14 @@ list_types(void) { printf("%2x %s\n", s->type, _(s->name)); } -int +static int is_extended(unsigned char type) { return (type == EXTENDED_PARTITION || type == LINUX_EXTENDED || type == WIN98_EXTENDED); } -int +static int is_bsd(unsigned char type) { return (type == BSD_PARTITION); } @@ -597,7 +619,7 @@ struct partition { /* Unfortunately, partitions are not aligned, and non-Intel machines are unhappy with non-aligned integers. So, we need a copy by hand. */ -int +static int copy_to_int(unsigned char *cp) { unsigned int m; @@ -608,7 +630,7 @@ copy_to_int(unsigned char *cp) { return m; } -void +static void copy_from_int(int m, char *cp) { *cp++ = (m & 0xff); m >>= 8; *cp++ = (m & 0xff); m >>= 8; @@ -616,7 +638,7 @@ copy_from_int(int m, char *cp) { *cp++ = (m & 0xff); } -void +static void copy_to_part(char *cp, struct partition *p) { p->bootable = *cp++; p->begin_chs.h = *cp++; @@ -630,7 +652,7 @@ copy_to_part(char *cp, struct partition *p) { p->nr_sects = copy_to_int(cp+4); } -void +static void copy_from_part(struct partition *p, char *cp) { *cp++ = p->bootable; *cp++ = p->begin_chs.h; @@ -661,14 +683,14 @@ struct part_desc { #define BSD_TYPE 1 } zero_part_desc; -struct part_desc * +static struct part_desc * outer_extended_partition(struct part_desc *p) { while (p->ep) p = p->ep; return p; } -int +static int is_parent(struct part_desc *pp, struct part_desc *p) { while (p) { if (pp == p) @@ -684,7 +706,7 @@ struct disk_desc { } oldp, newp; /* determine where on the disk this information goes */ -void +static void add_sector_and_offset(struct disk_desc *z) { int pno; struct part_desc *p; @@ -697,7 +719,7 @@ add_sector_and_offset(struct disk_desc *z) { } /* tell the kernel to reread the partition tables */ -int +static int reread_ioctl(int fd) { if(ioctl(fd, BLKRRPART)) { perror("BLKRRPART"); @@ -706,7 +728,7 @@ reread_ioctl(int fd) { return 0; } -int +static int is_blockdev(int fd) { struct stat statbuf; @@ -714,7 +736,7 @@ is_blockdev(int fd) { } /* reread after writing */ -void +static void reread_disk_partition(char *dev, int fd) { printf(_("Re-reading the partition table ...\n")); fflush(stdout); @@ -733,7 +755,7 @@ reread_disk_partition(char *dev, int fd) { } /* find Linux name of this partition, assuming that it will have a name */ -int +static int index_to_linux(int pno, struct disk_desc *z) { int i, ct = 1; struct part_desc *p = &(z->partitions[0]); @@ -743,7 +765,7 @@ index_to_linux(int pno, struct disk_desc *z) { return ct; } -int +static int linux_to_index(int lpno, struct disk_desc *z) { int i, ct = 0; struct part_desc *p = &(z->partitions[0]); @@ -754,7 +776,7 @@ linux_to_index(int lpno, struct disk_desc *z) { return -1; } -int +static int asc_to_index(char *pnam, struct disk_desc *z) { int pnum, pno; @@ -784,7 +806,7 @@ int one_only = 0; int one_only_pno; int increment = 0; -void +static void set_format(char c) { switch(c) { default: @@ -796,7 +818,7 @@ set_format(char c) { } } -unsigned long +static unsigned long unitsize(int format) { default_format = (B.cylindersize ? F_CYLINDER : F_MEGABYTE); if (!format && !(format = specified_format)) @@ -816,7 +838,7 @@ unitsize(int format) { } } -unsigned long +static unsigned long get_disksize(int format) { unsigned long cs = B.cylinders; if (cs && leave_last) @@ -824,7 +846,7 @@ get_disksize(int format) { return (cs * B.cylindersize) / unitsize(format); } -void +static void out_partition_header(char *dev, int format, struct geometry G) { if (dump) { printf(_("# partition table of %s\n"), dev); @@ -894,7 +916,7 @@ out_roundup_size(int width, unsigned long n, unsigned long unit) { putchar(' '); } -int +static int get_fdisk_geometry(struct part_desc *p) { chs b = p->p.end_chs; longchs bb = chs_to_longchs(b); @@ -904,7 +926,7 @@ get_fdisk_geometry(struct part_desc *p) { return (F.sectors != B.sectors || F.heads != B.heads); } -void +static void out_partition(char *dev, int format, struct part_desc *p, struct disk_desc *z, struct geometry G) { unsigned long start, end, size; @@ -916,7 +938,7 @@ out_partition(char *dev, int format, struct part_desc *p, pno = p - &(z->partitions[0]); /* our index */ lpno = index_to_linux(pno, z); /* name of next one that has a name */ if(pno == linux_to_index(lpno, z)) /* was that us? */ - printf("%8s%-2u", dev, lpno); /* yes */ + printf("%s", partname(dev, lpno, 10)); /* yes */ else if(show_extended) printf(" - "); else @@ -1009,7 +1031,7 @@ out_partition(char *dev, int format, struct part_desc *p, } } -void +static void out_partitions(char *dev, struct disk_desc *z) { struct part_desc *p; int pno, format = 0; @@ -1020,7 +1042,7 @@ out_partitions(char *dev, struct disk_desc *z) { for (pno=0; pno < z->partno; pno++) { p = &(z->partitions[pno]); if (p->size != 0 && p->p.sys_type != 0) { - if (get_fdisk_geometry(p)) + if (get_fdisk_geometry(p) && !dump) printf( _("Warning: The first partition looks like it was made\n" " for C/H/S=*/%ld/%ld (instead of %ld/%ld/%ld).\n" @@ -1046,7 +1068,7 @@ disj(struct part_desc *p, struct part_desc *q) { && q->start + q->size <= p->start + p->size)); } -char * +static char * pnumber(struct part_desc *p, struct disk_desc *z) { static char buf[20]; int this, next; @@ -1062,7 +1084,7 @@ pnumber(struct part_desc *p, struct disk_desc *z) { return buf; } -int +static int partitions_ok(struct disk_desc *z) { struct part_desc *partitions = &(z->partitions[0]), *p, *q; int partno = z->partno; @@ -1258,6 +1280,20 @@ extended_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z) here = start = ep->start; + if (B.cylindersize && start % B.cylindersize) { + /* This is BAD */ + if (DOS_extended) { + here = start -= (start % B.cylindersize); + printf(_("Warning: shifted start of the extd partition from %ld to %ld\n"), + ep->start, start); + printf(_("(For listing purposes only. Do not change its contents.)\n")); + } else { + printf(_("Warning: extended partition does not start at a " + "cylinder boundary.\n")); + printf(_("DOS and Linux will interpret the contents differently.\n")); + } + } + while (moretodo) { moretodo = 0; @@ -1365,6 +1401,22 @@ bsd_partition(char *dev, int fd, struct part_desc *ep, struct disk_desc *z) { z->partno = pno; } +#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r)) + +static int +linux_version_code(void) { + struct utsname my_utsname; + int p, q, r; + + if (uname(&my_utsname) == 0) { + p = atoi(strtok(my_utsname.release, ".")); + q = atoi(strtok(NULL, ".")); + r = atoi(strtok(NULL, ".")); + return MAKE_VERSION(p,q,r); + } + return 0; +} + static int msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) { int i; @@ -1373,6 +1425,7 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) { struct sector *s; struct part_desc *partitions = &(z->partitions[0]); int pno = z->partno; + int bsd_later = (linux_version_code() >= MAKE_VERSION(2,3,40)); if (!(s = get_sector(dev, fd, start))) return 0; @@ -1421,7 +1474,7 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) { } extended_partition(dev, fd, &partitions[i], z); } - if (is_bsd(partitions[i].p.sys_type)) { + if (!bsd_later && is_bsd(partitions[i].p.sys_type)) { if (!partitions[i].size) { printf(_("strange..., a BSD partition of size 0?\n")); continue; @@ -1429,6 +1482,19 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) { bsd_partition(dev, fd, &partitions[i], z); } } + + if (bsd_later) { + for (i=0; i<4; i++) { + if (is_bsd(partitions[i].p.sys_type)) { + if (!partitions[i].size) { + printf(_("strange..., a BSD partition of size 0?\n")); + continue; + } + bsd_partition(dev, fd, &partitions[i], z); + } + } + } + return 1; } @@ -1447,7 +1513,7 @@ amiga_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) { return 0; } -void +static void get_partitions(char *dev, int fd, struct disk_desc *z) { z->partno = 0; @@ -1460,7 +1526,7 @@ get_partitions(char *dev, int fd, struct disk_desc *z) { } } -int +static int write_partitions(char *dev, int fd, struct disk_desc *z) { struct sector *s; struct part_desc *partitions = &(z->partitions[0]), *p; @@ -1543,7 +1609,7 @@ struct dumpfld { #define RD_EOF (-1) #define RD_CMD (-2) -int +static int read_stdin(unsigned char **fields, unsigned char *line, int fieldssize, int linesize) { unsigned char *lp, *ip; int c, fno; @@ -1635,7 +1701,7 @@ read_stdin(unsigned char **fields, unsigned char *line, int fieldssize, int line } /* read a number, use default if absent */ -int +static int get_ul(char *u, unsigned long *up, unsigned long def, int base) { char *nu; @@ -1672,7 +1738,7 @@ int all_logicals_inside_outermost_extended = 1; enum { NESTED, CHAINED, ONESECTOR } boxes = NESTED; /* find the default value for - assuming entire units */ -unsigned long +static unsigned long first_free(int pno, int is_extended, struct part_desc *ep, int format, unsigned long mid, struct disk_desc *z) { unsigned long ff, fff; @@ -1716,7 +1782,7 @@ first_free(int pno, int is_extended, struct part_desc *ep, int format, } /* find the default value for - assuming entire units */ -unsigned long +static unsigned long max_length(int pno, int is_extended, struct part_desc *ep, int format, unsigned long start, struct disk_desc *z) { unsigned long fu; @@ -1745,7 +1811,7 @@ max_length(int pno, int is_extended, struct part_desc *ep, int format, /* compute starting sector of a partition inside an extended one */ /* ep is 0 or points to surrounding extended partition */ -int +static int compute_start_sect(struct part_desc *p, struct part_desc *ep) { unsigned long base; int inc = (DOS && B.sectors) ? B.sectors : 1; @@ -1785,7 +1851,7 @@ compute_start_sect(struct part_desc *p, struct part_desc *ep) { } /* build the extended partition surrounding a given logical partition */ -int +static int build_surrounding_extended(struct part_desc *p, struct part_desc *ep, struct disk_desc *z) { int inc = (DOS && B.sectors) ? B.sectors : 1; @@ -1819,7 +1885,7 @@ build_surrounding_extended(struct part_desc *p, struct part_desc *ep, return 1; } -int +static int read_line(int pno, struct part_desc *ep, char *dev, int interactive, struct disk_desc *z) { unsigned char line[1000]; @@ -1837,7 +1903,7 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, if (interactive) { if (pct == 0 && (show_extended || pno == 0)) warn("\n"); - warn("%8s%d: ", dev, lpno); + warn("%s:", partname(dev, lpno, 10)); } /* read input line - skip blank lines when reading from a file */ @@ -1932,7 +1998,8 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, p.size -= (p.size % unitsize(format)); } if (p.size > ml1) { - warn(_("Warning: exceeds max allowable size (%lu)\n"), ml1 / unitsize(0)); + warn(_("Warning: given size (%lu) exceeds max allowable size (%lu)\n"), + (p.size + unitsize(0) - 1) / unitsize(0), ml1 / unitsize(0)); if (!force) return 0; } @@ -2022,7 +2089,7 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive, /* ep either points to the extended partition to contain this one, or to the empty partition that may become extended or is 0 */ -int +static int read_partition(char *dev, int interactive, int pno, struct part_desc *ep, struct disk_desc *z) { struct part_desc *p = &(z->partitions[pno]); @@ -2050,7 +2117,7 @@ read_partition(char *dev, int interactive, int pno, struct part_desc *ep, return 1; } -void +static void read_partition_chain(char *dev, int interactive, struct part_desc *ep, struct disk_desc *z) { int i, base; @@ -2082,7 +2149,7 @@ read_partition_chain(char *dev, int interactive, struct part_desc *ep, } } -void +static void read_input(char *dev, int interactive, struct disk_desc *z) { int i; struct part_desc *partitions = &(z->partitions[0]), *ep; @@ -2191,6 +2258,7 @@ static const struct option long_opts[] = { { "sectors", required_argument, NULL, 'S' }, { "activate", optional_argument, NULL, 'A' }, { "DOS", no_argument, NULL, 'D' }, + { "DOS-extended", no_argument, NULL, 'E' }, { "Linux", no_argument, NULL, 'L' }, { "re-read", no_argument, NULL, 'R' }, { "list-types", no_argument, NULL, 'T' }, @@ -2219,7 +2287,7 @@ static struct devd { { "ed", "abcd" } }; -int +static int is_ide_cdrom(char *device) { /* No device was given explicitly, and we are trying some likely things. But opening /dev/hdc may produce errors like @@ -2244,14 +2312,14 @@ is_ide_cdrom(char *device) { return 0; } -void do_list(char *dev, int silent); -void do_size(char *dev, int silent); -void do_geom(char *dev, int silent); -void do_fdisk(char *dev); -void do_reread(char *dev); -void do_change_id(char *dev, char *part, char *id); -void do_unhide(char **av, int ac, char *arg); -void do_activate(char **av, int ac, char *arg); +static void do_list(char *dev, int silent); +static void do_size(char *dev, int silent); +static void do_geom(char *dev, int silent); +static void do_fdisk(char *dev); +static void do_reread(char *dev); +static void do_change_id(char *dev, char *part, char *id); +static void do_unhide(char **av, int ac, char *arg); +static void do_activate(char **av, int ac, char *arg); int total_size; @@ -2325,6 +2393,8 @@ main(int argc, char **argv) { U.cylinders = atoi(optarg); break; case 'D': DOS = 1; break; + case 'E': + DOS_extended = 1; break; case 'H': U.heads = atoi(optarg); break; case 'L': @@ -2463,7 +2533,7 @@ main(int argc, char **argv) { * H. Listing the current situation */ -int +static int my_open (char *dev, int rw, int silent) { int fd, mode; @@ -2476,7 +2546,7 @@ my_open (char *dev, int rw, int silent) { return fd; } -void +static void do_list (char *dev, int silent) { int fd; struct disk_desc *z; @@ -2502,25 +2572,23 @@ do_list (char *dev, int silent) { } } -void +static void do_geom (char *dev, int silent) { int fd; - struct hd_geometry g; + struct geometry R; fd = my_open(dev, 0, silent); if (fd < 0) return; - /* get_cylindersize(dev, fd, silent); */ - if (!ioctl(fd, HDIO_GETGEO, &g)) - printf(_("%s: %d cylinders, %d heads, %d sectors/track\n"), - dev, g.cylinders, g.heads, g.sectors); - else - printf(_("%s: unknown geometry\n"), dev); + R = get_geometry(dev, fd, silent); + if (R.cylinders) + printf(_("%s: %ld cylinders, %ld heads, %ld sectors/track\n"), + dev, R.cylinders, R.heads, R.sectors); } /* for compatibility with earlier fdisk: provide option -s */ -void +static void do_size (char *dev, int silent) { int fd; long size; @@ -2575,7 +2643,7 @@ do_size (char *dev, int silent) { * The present syntax was chosen to be (somewhat) compatible with the * activate from the LILO package. */ -void +static void set_active (struct disk_desc *z, char *pnam) { int pno; @@ -2583,7 +2651,7 @@ set_active (struct disk_desc *z, char *pnam) { z->partitions[pno].p.bootable = 0x80; } -void +static void do_activate (char **av, int ac, char *arg) { char *dev = av[0]; int fd; @@ -2605,7 +2673,7 @@ do_activate (char **av, int ac, char *arg) { if (z->partitions[pno].p.bootable) { lpno = index_to_linux(pno, z); if (pno == linux_to_index(lpno, z)) - printf("%s%d\n", dev, lpno); + printf("%s\n", partname(dev, lpno, 0)); else printf("%s#%d\n", dev, pno); if (z->partitions[pno].p.bootable != 0x80) @@ -2639,7 +2707,7 @@ do_activate (char **av, int ac, char *arg) { "but the DOS MBR will only boot a disk with 1 active partition.\n"), i); } -void +static void set_unhidden (struct disk_desc *z, char *pnam) { int pno; unsigned char id; @@ -2656,7 +2724,7 @@ set_unhidden (struct disk_desc *z, char *pnam) { /* * maybe remove and make part of --change-id */ -void +static void do_unhide (char **av, int ac, char *arg) { char *dev = av[0]; int fd, rw, i; @@ -2684,7 +2752,8 @@ do_unhide (char **av, int ac, char *arg) { exit_status = 1; } -void do_change_id(char *dev, char *pnam, char *id) { +static void +do_change_id(char *dev, char *pnam, char *id) { int fd, rw, pno; struct disk_desc *z; unsigned long i; @@ -2714,7 +2783,7 @@ void do_change_id(char *dev, char *pnam, char *id) { exit_status = 1; } -void +static void do_reread(char *dev) { int fd; @@ -2727,7 +2796,7 @@ do_reread(char *dev) { * I. Writing the new situation */ -void +static void do_fdisk(char *dev){ int fd; int c, answer; @@ -2748,15 +2817,15 @@ do_fdisk(char *dev){ if(!no_write && !no_reread) { warn(_("Checking that no-one is using this disk right now ...\n")); if(reread_ioctl(fd)) { - printf(_("\nThis disk is currently in use - repartitioning is probably a bad idea." - "Umount all file systems, and swapoff all swap partitions on this disk." + printf(_("\nThis disk is currently in use - repartitioning is probably a bad idea.\n" + "Umount all file systems, and swapoff all swap partitions on this disk.\n" "Use the --no-reread flag to suppress this check.\n")); if (!force) { printf(_("Use the --force flag to overrule all checks.\n")); exit(1); } } else - warn(_("OK")); + warn(_("OK\n")); } z = &oldp; diff --git a/games/banner.c b/games/banner.c index 36688b27..31206a43 100644 --- a/games/banner.c +++ b/games/banner.c @@ -1018,10 +1018,7 @@ int debug, i, j, linen, max, nchars, pc, term, trace, x, y; int width = DWIDTH; /* -w option: scrunch letters to 80 columns */ int -main(argc, argv) - int argc; - char **argv; -{ +main(int argc, char **argv) { int ch; extern char *__progname; __progname = argv[0]; diff --git a/kbd/kbdrate.c b/kbd/kbdrate.c index 0a9064f3..747757da 100644 --- a/kbd/kbdrate.c +++ b/kbd/kbdrate.c @@ -95,7 +95,7 @@ static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150, static int valid_delays[] = { 250, 500, 750, 1000 }; #define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int )) -int +static int KDKBDREP_ioctl_ok(double rate, int delay, int silent) { #ifdef KDKBDREP /* This ioctl is defined in but is not @@ -145,7 +145,7 @@ KDKBDREP_ioctl_ok(double rate, int delay, int silent) { #endif /* KDKBDREP */ } -int +static int KIOCSRATE_ioctl_ok(double rate, int delay, int silent) { #ifdef KIOCSRATE struct kbd_rate kbdrate_s; diff --git a/login-utils/Makefile b/login-utils/Makefile index e277d1ba..0960854e 100644 --- a/login-utils/Makefile +++ b/login-utils/Makefile @@ -18,7 +18,8 @@ MAN1.PASSWD= passwd.1 MAN8.GETTY= agetty.8 -MAN8.INIT= fastboot.8 fasthalt.8 halt.8 reboot.8 simpleinit.8 shutdown.8 +MAN8.INIT= fastboot.8 fasthalt.8 halt.8 reboot.8 simpleinit.8 shutdown.8 \ + need.8 MAN8.PUTILS= vipw.8 vigr.8 @@ -27,7 +28,7 @@ MAN8.PUTILS= vipw.8 vigr.8 SBIN.GETTY= agetty -SBIN.INIT= simpleinit shutdown +SBIN.INIT= simpleinit shutdown need BIN.PUTILS= login @@ -109,10 +110,15 @@ newgrp: newgrp.o setpwnam.o: $(LIB)/pathnames.h shutdown.o: $(LIB)/pathnames.h $(LIB)/linux_reboot.h shutdown: shutdown.o $(LIB)/my_reboot.o -simpleinit.o: $(LIB)/pathnames.h $(LIB)/linux_reboot.h +simpleinit.o: $(LIB)/pathnames.h $(LIB)/linux_reboot.h simpleinit.h +need.o: simpleinit.h + simpleinit: simpleinit.o $(LIB)/my_reboot.o $(CC) $(LDFLAGS) -o $@ $^ $(CRYPT) +need: need.o + $(CC) $(LDFLAGS) -o $@ $^ + vipw.o: $(LIB)/pathnames.h vipw: vipw.o @@ -177,6 +183,7 @@ install-init: $(SBIN.INIT) (cd $(SHUTDOWNDIR); ln -sf shutdown fastboot) (cd $(SHUTDOWNDIR); ln -sf shutdown halt) (cd $(SHUTDOWNDIR); ln -sf shutdown fasthalt) + (cd $(SHUTDOWNDIR); ln -sf need display-services) install-getty: $(SBIN.GETTY) diff --git a/login-utils/agetty.c b/login-utils/agetty.c index 9360be0a..6ae4e833 100644 --- a/login-utils/agetty.c +++ b/login-utils/agetty.c @@ -24,11 +24,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #include #include "nls.h" @@ -42,7 +42,6 @@ #ifdef USE_SYSLOG #include -extern void closelog(); #endif /* @@ -216,12 +215,13 @@ static struct Speedtab speedtab[] = { { 0, 0 }, }; -#define P_(s) () +#define P_(s) s +int main P_((int argc, char **argv)); void parse_args P_((int argc, char **argv, struct options *op)); void parse_speeds P_((struct options *op, char *arg)); void update_utmp P_((char *line)); void open_tty P_((char *tty, struct termio *tp, int local)); -void termio_init P_((struct termio *tp, int speed, int local)); +void termio_init P_((struct termio *tp, int speed, struct options *op)); void auto_baud P_((struct termio *tp)); void do_prompt P_((struct options *op, struct termio *tp)); void next_speed P_((struct termio *tp, struct options *op)); @@ -230,7 +230,7 @@ void termio_final P_((struct options *op, struct termio *tp, struct chardata *cp int caps_lock P_((char *s)); int bcode P_((char *s)); void usage P_((void)); -void error P_((int va_alist)); +void error P_((const char *, ...)); #undef P_ /* The following is used for understandable diagnostics. */ @@ -499,7 +499,6 @@ parse_speeds(op, arg) struct options *op; char *arg; { - char *strtok(); char *cp; debug(_("entered parse_speeds\n")); @@ -522,8 +521,6 @@ update_utmp(line) struct utmp ut; time_t t; int mypid = getpid(); - long time(); - long lseek(); struct utmp *utp; /* @@ -1178,13 +1175,9 @@ usage() #define str2cpy(b,s1,s2) strcat(strcpy(b,s1),s2) -/* VARARGS */ void -error(va_alist) - va_dcl -{ +error(const char *fmt, ...) { va_list ap; - char *fmt; #ifndef USE_SYSLOG int fd; #endif @@ -1214,15 +1207,14 @@ error(va_alist) * vsprintf() like interface. */ - va_start(ap); - fmt = va_arg(ap, char *); + va_start(ap, fmt); while (*fmt) { if (strncmp(fmt, "%s", 2) == 0) { (void) strcpy(bp, va_arg(ap, char *)); bp += strlen(bp); fmt += 2; } else if (strncmp(fmt, "%m", 2) == 0) { - (void) strcpy(bp, sys_errlist[errno]); + (void) strcpy(bp, strerror(errno)); bp += strlen(bp); fmt += 2; } else { diff --git a/login-utils/chfn.c b/login-utils/chfn.c index 93e801e0..73a9b891 100644 --- a/login-utils/chfn.c +++ b/login-utils/chfn.c @@ -86,16 +86,12 @@ extern int setpwnam P((struct passwd *pwd)); /* we do not accept gecos field sizes longer than MAX_FIELD_SIZE */ #define MAX_FIELD_SIZE 256 -int main (argc, argv) - int argc; - char *argv[]; -{ +int main (int argc, char **argv) { char *cp; uid_t uid; struct finfo oldf, newf; boolean interactive; int status; - extern int errno; #if REQUIRE_PASSWORD && USE_PAM pam_handle_t *pamh = NULL; int retcode; @@ -316,13 +312,15 @@ static void parse_passwd (pw, pinfo) struct passwd *pw; struct finfo *pinfo; { + char *gecos; char *cp; if (pw) { pinfo->pw = pw; pinfo->username = pw->pw_name; - /* use pw_gecos */ - cp = pw->pw_gecos; + /* use pw_gecos - we take a copy since PAM destroys the original */ + gecos = strdup(pw->pw_gecos); + cp = (gecos ? gecos : ""); pinfo->full_name = cp; cp = strchr (cp, ','); if (cp) { *cp = 0, cp++; } else return; diff --git a/login-utils/chsh.c b/login-utils/chsh.c index d1d14d0f..f17b176f 100644 --- a/login-utils/chsh.c +++ b/login-utils/chsh.c @@ -88,7 +88,6 @@ int main (argc, argv) uid_t uid; struct sinfo info; struct passwd *pw; - extern int errno; #if REQUIRE_PASSWORD && USE_PAM pam_handle_t *pamh = NULL; int retcode; diff --git a/login-utils/login.c b/login-utils/login.c index 399b4aee..eaaf1a52 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -30,7 +30,7 @@ 'Lastlog' feature. - - A lot of nitty gritty details has been adjusted in favour of + - A lot of nitty gritty details have been adjusted in favour of HP-UX, e.g. /etc/securetty, default paths and the environment variables assigned by 'login'. @@ -304,7 +304,7 @@ consoletty(int fd) int main(int argc, char **argv) { - extern int errno, optind; + extern int optind; extern char *optarg, **environ; struct group *gr; register int ch; @@ -414,7 +414,7 @@ main(int argc, char **argv) *p++ = ' '; } else ask = 1; - + #ifndef __linux__ ioctlval = 0; ioctl(0, TIOCLSET, &ioctlval); @@ -479,12 +479,12 @@ main(int argc, char **argv) opentty(ttyn); tcsetattr(0,TCSAFLUSH,&tt); } - - if ((tty = rindex(ttyn, '/'))) - ++tty; + + if (strncmp(ttyn, "/dev/", 5) == 0) + tty = ttyn+5; else - tty = ttyn; - + tty = ttyn; + openlog("login", LOG_ODELAY, LOG_AUTHPRIV); #if 0 @@ -494,10 +494,11 @@ main(int argc, char **argv) #endif #ifdef USE_PAM - /* username is initialized to NULL - and if specified on the command line it is set. - Therefore, we are safe not setting it to anything - */ + /* + * username is initialized to NULL + * and if specified on the command line it is set. + * Therefore, we are safe not setting it to anything + */ retcode = pam_start("login",username, &conv, &pamh); if(retcode != PAM_SUCCESS) { @@ -513,14 +514,18 @@ main(int argc, char **argv) retcode = pam_set_item(pamh, PAM_TTY, tty); PAM_FAIL_CHECK; - /* Andrew.Taylor@cal.montage.ca: Provide a user prompt to PAM - so that the "login: " prompt gets localized. Unfortunately, - PAM doesn't have an interface to specify the "Password: " string (yet). */ + /* + * Andrew.Taylor@cal.montage.ca: Provide a user prompt to PAM + * so that the "login: " prompt gets localized. Unfortunately, + * PAM doesn't have an interface to specify the "Password: " string + * (yet). + */ retcode = pam_set_item(pamh, PAM_USER_PROMPT, _("login: ")); PAM_FAIL_CHECK; #if 0 - /* other than iso-8859-1 + /* + * other than iso-8859-1 * one more time due to reset tty by PAM */ printf("\033(K"); @@ -602,12 +607,12 @@ main(int argc, char **argv) ioctlval = 0; ioctl(0, TIOCSETD, &ioctlval); # endif - + if (ask) { fflag = 0; getloginname(); } - + /* Dirty patch to fix a gigantic security hole when using yellow pages. This problem should be solved by the libraries, and not by programs, but this must be fixed @@ -672,7 +677,7 @@ main(int argc, char **argv) pwd->pw_name, tty); continue; } - + /* * If no pre-authentication and a password exists * for this user, prompt for one and verify it. @@ -717,6 +722,7 @@ main(int argc, char **argv) } # endif /* KERBEROS */ memset(pp, 0, strlen(pp)); + if (pwd && !strcmp(p, pwd->pw_passwd)) break; @@ -852,7 +858,6 @@ main(int argc, char **argv) /* for linux, write entries in utmp and wtmp */ { struct utmp ut; - int wtmp; struct utmp *utp; pid_t mypid = getpid(); @@ -924,15 +929,19 @@ Michael Riepe #if 0 /* The O_APPEND open() flag should be enough to guarantee atomic writes at end of file. */ - if((wtmp = open(_PATH_WTMP, O_APPEND|O_WRONLY)) >= 0) { + { + int wtmp; + + if((wtmp = open(_PATH_WTMP, O_APPEND|O_WRONLY)) >= 0) { write(wtmp, (char *)&ut, sizeof(ut)); close(wtmp); + } } #else /* Probably all this locking below is just nonsense, and the short version is OK as well. */ { - int lf; + int lf, wtmp; if ((lf = open(_PATH_WTMPLOCK, O_CREAT|O_WRONLY, 0660)) >= 0) { flock(lf, LOCK_EX); if ((wtmp = open(_PATH_WTMP, O_APPEND|O_WRONLY)) >= 0) { diff --git a/login-utils/need.8 b/login-utils/need.8 new file mode 100644 index 00000000..cc3712d7 --- /dev/null +++ b/login-utils/need.8 @@ -0,0 +1,85 @@ +.\" Copyright (C) 2000 Richard Gooch +.\" +.\" This program is free software; you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation; either version 2 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program; if not, write to the Free Software +.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +.\" +.\" Richard Gooch may be reached by email at rgooch@atnf.csiro.au +.\" The postal address is: +.\" Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. +.\" +.\" need.8 Richard Gooch 28-FEB-2000 +.\" +.TH NEED 8 "28 Feb 2000" "Util-Linux Package" +.SH NAME +need \- utility to tell simpleinit(8) to start a service +.SH SYNOPSIS +.nf +\fBneed\fP [\fB-r\fP] [\fBservice\fP] +.BR display-services +.fi +.SH DESCRIPTION +The \fBneed\fP programme is a utility that tells \fBsimpleinit\fP(8) +to start a \fIservice\fP (usually a script in \fI/sbin/init.d\fP) and +will wait for the service to become available. If the service is +already available, it will not be started again. + +When invoked as \fBdisplay-services\fP it will write the list of +currently available services and the list of failed services to the +standard output. + +The \fB-r\fP option is used to tell \fBsimpleinit\fP(8) to "roll back" +(stop) services up to (but not including) \fIservice\fP. If +\fIservice\fP is not specified, all services are stopped. The \fB-r\fP +option thus allows the system to be partially or wholly shut down in +an orderly fashion. The \fBshutdown\fP(8) programme still needs to be +run. + +The \fBneed\fP programme is designed to help improve the robustness, +scalability and readability of system boot scripts. It is now possible +to write a modularised set of boot scripts without the complex and +fragile numbered symlink scheme used in SysV-style boot scripts. Each +script can simply declare, using \fBneed\fP(8), what must run before +them. +.SH EXIT CODE +The exit code from \fBneed\fP is 0 if the service was successfully +started, 1 if the service failed badly, and 2 if the service is +unavailable (i.e. disabled in configuration files). These exit codes +reflect the exit codes from the service startup scripts. + +The exit code from \fBneed -r\fP is 0 if the service was successfully +stopped, 1 if the service could not be stopped, and 2 if the service +was not available to start with. The service shutdown scripts may only +return 0 (for success) or 1 (for failure). +.SH SIGNALS +\fBneed\fP(8) uses \fBSIGUSR1\fP, \fBSIGUSR2\fP and \fBSIGPOLL\fP for +communication with \fBsimpleinit\fP(8). Don't send these signals to +it. +.SH FILES +.PD 0 +.TP 20 +.BI /dev/initctl +This is the control FIFO, created by \fBsimpleinit\fP(8), which +\fBneed\fP(8) writes commands to. +.SH SEE ALSO +.BR simpleinit (8), +.BR init (8) +.PP +A more complete discussion of the new boot script system, based on +\fBneed\fP(8), is available from: +http://www.atnf.csiro.au/~rgooch/linux/boot-scripts/ +.SH AUTHOR +Richard Gooch (rgooch@atnf.csiro.au) +.SH AVAILABILITY +The Util-Linux package is available from: +ftp://ftp.??.kernel.org/pub/linux/utils/util-linux/ diff --git a/login-utils/need.c b/login-utils/need.c new file mode 100644 index 00000000..97690c46 --- /dev/null +++ b/login-utils/need.c @@ -0,0 +1,160 @@ +/* need.c + + Source file for need (init(8) dependency tool). + + Copyright (C) 2000 Richard Gooch + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + Richard Gooch may be reached by email at rgooch@atnf.csiro.au + The postal address is: + Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. +*/ + +/* + This tool will request init(8) to start a service and will wait for that + service to be available. If the service is already available, init(8) will + not start it again. + This tool may also be used to inspect the list of currently available + services. + + + Written by Richard Gooch 28-FEB-2000 + + Last updated by Richard Gooch 28-FEB-2000 + + +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include "simpleinit.h" + + +static void signal_handler (int sig); + + +static int caught_signal = 0; + + +int main (int argc, char **argv) +{ + int fd, nbytes; + struct sigaction sa; + sigset_t ss; + char *ptr; + long buffer[COMMAND_SIZE / sizeof (long)]; + struct command_struct *command = (struct command_struct *) buffer; + + sigemptyset (&ss); + sigaddset (&ss, SIG_PRESENT); + sigaddset (&ss, SIG_NOT_PRESENT); + sigaddset (&ss, SIG_FAILED); + sigprocmask (SIG_BLOCK, &ss, NULL); + sigemptyset (&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = signal_handler; + sigaction (SIG_PRESENT, &sa, NULL); + sigaction (SIG_NOT_PRESENT, &sa, NULL); + sigaction (SIG_FAILED, &sa, NULL); + command->pid = getpid (); + if ( ( ptr = strrchr (argv[0], '/') ) == NULL ) ptr = argv[0]; + else ++ptr; + if (strcmp (ptr, "display-services") == 0) + { + command->command = COMMAND_DUMP_LIST; + if (tmpnam (command->name) == NULL) + { + fprintf (stderr, "Unable to create a unique filename\t%s\n", + ERRSTRING); + exit (1); + } + if (mkfifo (command->name, S_IRUSR) != 0) + { + fprintf (stderr, "Unable to create FIFO: \"%s\"\t%s\n", + command->name, ERRSTRING); + exit (1); + } + } + else + { + if ( (argc > 1) && (strcmp (argv[1], "-r") == 0) ) + { + command->command = COMMAND_ROLLBACK; + --argc; + ++argv; + } + else command->command = COMMAND_NEED; + if (argc == 2) strcpy (command->name, argv[1]); + else + { + if (command->command == COMMAND_ROLLBACK) command->name[0] = '\0'; + else + { + fprintf (stderr, "Usage:\tneed programme\n"); + exit (1); + } + } + } + if ( ( fd = open ("/dev/initctl", O_WRONLY, 0) ) < 0 ) + { + fprintf (stderr, "Error opening\t%s\n", ERRSTRING); + exit (1); + } + if (write (fd, buffer, COMMAND_SIZE) < COMMAND_SIZE) + { + fprintf (stderr, "Error writing\t%s\n", ERRSTRING); + exit (1); + } + close (fd); + if (command->command != COMMAND_DUMP_LIST) + { + sigemptyset (&ss); + while (caught_signal == 0) sigsuspend (&ss); + switch (caught_signal) + { + case SIG_PRESENT: + return 0; + case SIG_NOT_PRESENT: + return 2; + case SIG_FAILED: + return 1; + } + return 3; + } + /* Read back the data and display it */ + if ( ( fd = open (command->name, O_RDONLY, 0) ) < 0 ) + { + fprintf (stderr, "Error opening:\"%s\"\t%s\n", + command->name, ERRSTRING); + exit (1); + } + unlink (command->name); + fflush (stdout); + while ( ( nbytes = read (fd, buffer, COMMAND_SIZE) ) > 0 ) + write (1, buffer, nbytes); + close (fd); + return (0); +} /* End Function main */ + +static void signal_handler (int sig) +{ + caught_signal = sig; +} /* End Function signal_handler */ diff --git a/login-utils/shutdown.8 b/login-utils/shutdown.8 index 961579bd..492084a2 100644 --- a/login-utils/shutdown.8 +++ b/login-utils/shutdown.8 @@ -2,7 +2,7 @@ .\" May be distributed under the GNU General Public License .\" .\" -.TH SHUTDOWN 8 "24 July 1998" "Linux 2.0" "Linux Programmer's Manual" +.TH SHUTDOWN 8 "2 March 2000" "Linux 2.0" "Linux Programmer's Manual" .SH NAME shutdown \- close down the system .SH SYNOPSIS @@ -66,6 +66,12 @@ unmounts all the disks, .BR sync (2)'s again, waits for a second, and then either terminates or reboots the system. + +Prior to unmounting all discs, the \fBSIGQUIT\fP signal is sent to the +\fBinit\fP process, which will in turn exec \fBshutdown\fP(8). This +allows for clean unmounting, even if the old inode for the \fBinit\fP +process was unlinked. If the current process ID (PID) equals 1, then +\fBshutdown\fP(8) will pause forever. .SH OPTIONS .TP .B \-h diff --git a/login-utils/shutdown.c b/login-utils/shutdown.c index 7ccb748a..e3ec93c1 100644 --- a/login-utils/shutdown.c +++ b/login-utils/shutdown.c @@ -31,6 +31,8 @@ * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * + * 2000-03-02 Richard Gooch + * - pause forever if (pid == 1) and send SIGQUIT to pid = 1 */ #include @@ -75,7 +77,7 @@ char halt_action[256]; /* to find out what to do upon halt */ #define WR(s) write(fd, s, strlen(s)) #define WRCRLF write(fd, "\r\n", 2) -#define ERRSTRING sys_errlist[errno] +#define ERRSTRING strerror(errno) void @@ -115,7 +117,11 @@ main(int argc, char *argv[]) int c,i; int fd; char *ptr; - + + if (getpid () == 1) { + for (i = 0; i < getdtablesize (); i++) close (i); + while (1) pause (); + } setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); @@ -361,6 +367,10 @@ main(int argc, char *argv[]) Let us see whether people complain. */ unlink(_PATH_NOLOGIN); + /* Tell init(8) to exec so that the old inode may be freed cleanly if + required. Need to sleep before remounting root read-only */ + kill (1, SIGQUIT); + sync(); sleep(2); diff --git a/login-utils/simpleinit.8 b/login-utils/simpleinit.8 index ad942d3b..2a2f666e 100644 --- a/login-utils/simpleinit.8 +++ b/login-utils/simpleinit.8 @@ -5,7 +5,7 @@ .SH NAME simpleinit \- process control initialization .SH SYNOPSIS -.B "init [ single ]" +.B "init [ single ] [ script ]" .SH DESCRIPTION .B init is invoked as the last step in the Linux boot sequence. If the @@ -35,43 +35,6 @@ file is executed, and the information in .I /etc/inittab will be used to start processes. -While -.B init -is running, several signals are trapped, with special action taken. Since -.B init -has PID 1, sending signals to the -.B init -process is easy with the -.BR kill (1) -command. - -If -.B init -catches a SIGHUP (hangup) signal, the -.I /etc/inittab -will be read again. - -If -.B init -catches a SIGTSTP (terminal stop) signal, no more processes will be -spawned. This is a toggle, which is reset is -.B init -catches another SIGTSTP signal. - -If -.B init -catches a SIGINT (interrupt) signal, -.B init -will sync a few times, and try to start -.IR reboot . -Failing this, -.B init -will execute the system -.BR reboot (2) -call. Under Linux, it is possible to configure the Ctrl-Alt-Del sequence -to send a signal to -.B init -instead of rebooting the system. .SH "THE INITTAB FILE" Because of the number of init programs which are appearing in the Linux community, the documentation for the @@ -83,6 +46,12 @@ man page, is presented here: The format is .RS +.B bootprog=file + +.B fileprefix=string + +.B PATH=search path + .B "ttyline:termcap-entry:getty-command" .RE @@ -90,6 +59,10 @@ An example is as follows: .nf .RS +bootprog = rc +fileprefix = /sbin/ +PATH = /sbin:/bin + tty1:linux:/sbin/getty 9600 tty1 tty2:linux:/sbin/getty 9600 tty2 tty3:linux:/sbin/getty 9600 tty3 @@ -106,6 +79,29 @@ character are treated as comments. Please see documentation for the .B getty (8) command that you are using, since there are several of these in the Linux community at this time. +.SH SIGNALS +\fBsimpleinit\fP(8) responds to signals in a variety of ways: +.TP +.B SIGHUP +The \fI/etc/inittab\fP configuration file will be read again. +.TP +.B SIGTSTP +This flips a toggle, which controls whether more processes will be +spawned. +.TP +.B SIGINT +\fBsimpleinit\fP(8) will sync a few times, and try to start +\fBreboot\fP(8). Failing this, it will execute the system +\fBreboot\fP(2) call. Under Linux, it is possible to configure the +Ctrl-Alt-Del sequence to send a signal to the \fBinit\fP process +instead of rebooting the system (\fBsimpleinit\fP(8) does this by +default). +.TP +.B SIGQUIT +The \fBreboot\fP(8) programme is executed in place of the +\fBsimpleinit\fP(8) programme. This allows \fBreboot\fP(8) to cleanly +remount (read-only) the root filesystem, even if the old inode for the +\fBinit\fP process was unlinked. .SH FILES .I /etc/inittab .br diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c index 1e496ad5..1baf50cd 100644 --- a/login-utils/simpleinit.c +++ b/login-utils/simpleinit.c @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -18,7 +18,13 @@ #include #include #include +#include +#include +#include +#include #include +#include +#include #ifdef SHADOW_PWD # include #endif @@ -26,12 +32,15 @@ #include "pathnames.h" #include "linux_reboot.h" #include "nls.h" +#include "simpleinit.h" -#define CMDSIZ 150 /* max size of a line in inittab */ -#define NUMCMD 30 /* max number of lines in inittab */ -#define NUMTOK 20 /* max number of tokens in inittab command */ +#define CMDSIZ 150 /* max size of a line in inittab */ +#define NUMCMD 30 /* max number of lines in inittab */ +#define NUMTOK 20 /* max number of tokens in inittab command */ +#define PATH_SIZE (CMDSIZ+CMDSIZ+1) + +#define MAX_RESPAWN_RATE 5 /* number of respawns per 100 seconds */ -#define RUN_RC #define TZFILE "/etc/TZ" char tzone[CMDSIZ]; /* #define DEBUGGING */ @@ -43,21 +52,42 @@ char tzone[CMDSIZ]; #define ever (;;) struct initline { - pid_t pid; - char tty[10]; - char termcap[30]; - char *toks[NUMTOK]; - char line[CMDSIZ]; + pid_t pid; + char tty[10]; + char termcap[30]; + char *toks[NUMTOK]; + char line[CMDSIZ]; + struct timeval last_start; + signed long rate; }; struct initline inittab[NUMCMD]; int numcmd; int stopped = 0; /* are we stopped */ - -int do_rc(); +static char boot_script[PATH_SIZE] = _PATH_RC; +static char script_prefix[PATH_SIZE] = "\0"; +static int caught_sigint = 0; +static const char *initctl_name = "/dev/initctl"; +static int initctl_fd = -1; +static volatile int do_longjmp = 0; +static sigjmp_buf jmp_env; + + +static void do_single (); +static int do_rc_tty (const char *path); +static int process_path ( const char *path, int (*func) (const char *path) ); +static int preload_file (const char *path); +static int run_file (const char *path); void spawn(), hup_handler(), read_inittab(); -void tstp_handler(), int_handler(), set_tz(), write_wtmp(); -int boot_single(); +void tstp_handler (); +void int_handler (); +static void sigchild_handler (int sig); +static void sigquit_handler (int sig); +void set_tz(), write_wtmp(); +static pid_t mywaitpid (pid_t pid, int *status, int *rc_status); +static int run_command (const char *path, const char *name, pid_t pid); +static void forget_those_not_present (); + void err(char *s) { @@ -82,7 +112,7 @@ enter_single() execl(_PATH_BSHELL, _PATH_BSHELL, NULL); err(_("exec of single user shell failed\n")); } else if(pid > 0) { - while(wait(&i) != pid) /* nothing */; + while (waitpid (pid, &i, 0) != pid) /* Nothing */; } else if(pid < 0) { err(_("fork of single user shell failed\n")); } @@ -91,43 +121,63 @@ enter_single() int main(int argc, char *argv[]) { - int vec,i; - pid_t pid; + int vec,i; + int want_single = 0; + pid_t pid; + struct sigaction sa; + #ifdef SET_TZ set_tz(); #endif - signal(SIGTSTP, tstp_handler); - signal(SIGINT, int_handler); + sigemptyset (&sa.sa_mask); + sa.sa_flags = 0; + signal (SIGTSTP, tstp_handler); + signal (SIGINT, int_handler); + sa.sa_handler = sigchild_handler; + sigaction (SIGCHLD, &sa, NULL); + sa.sa_handler = sigquit_handler; + sigaction (SIGQUIT, &sa, NULL); setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + my_reboot (LINUX_REBOOT_CMD_CAD_OFF); + /* Find script to run. Command-line overrides config file overrides + built-in default */ + for (i = 0; i < NUMCMD; i++) inittab[i].pid = -1; + read_inittab (); + for (i = 1; i < argc; i++) { + if (strcmp (argv[i], "single") == 0) want_single = 1; + else { + char path[PATH_SIZE]; + + strcpy (path, script_prefix); + strcat (path, argv[i]); + if (access (path, R_OK | X_OK) == 0) + strcpy (boot_script, path); + } + } + + if ( ( initctl_fd = open (initctl_name, O_RDWR, 0) ) < 0 ) { + mkfifo (initctl_name, S_IRUSR | S_IWUSR); + if ( ( initctl_fd = open (initctl_name, O_RDWR, 0) ) < 0 ) + err ( _("error opening fifo\n") ); + } - /* - * start up in single user mode if /etc/singleboot exists or if - * argv[1] is "single". - */ - if(boot_single(0, argc, argv)) enter_single(); + if ( want_single || (access (_PATH_SINGLE, R_OK) == 0) ) do_single (); -#ifdef RUN_RC /*If we get a SIGTSTP before multi-user mode, do nothing*/ while(stopped) pause(); - if(do_rc() != 0 && boot_single(1, argc, argv) && !stopped) - enter_single(); + + if ( do_rc_tty (boot_script) ) do_single (); + while(stopped) /*Also if /etc/rc fails & we get SIGTSTP*/ pause(); -#endif write_wtmp(); /* write boottime record */ - - for(i = 0; i < NUMCMD; i++) - inittab[i].pid = -1; - - read_inittab(); - #ifdef DEBUGGING for(i = 0; i < numcmd; i++) { char **p; @@ -140,13 +190,15 @@ int main(int argc, char *argv[]) #endif signal(SIGHUP, hup_handler); - for(i = 0; i < getdtablesize(); i++) close(i); + for (i = 0; i < getdtablesize (); i++) + if (i != initctl_fd) close (i); for(i = 0; i < numcmd; i++) spawn(i); for ever { - pid = wait(&vec); + pid = mywaitpid (-1, &vec, NULL); + if (pid == 0) continue; /* clear utmp entry, and append to wtmp if possible */ { @@ -194,80 +246,170 @@ int main(int argc, char *argv[]) #define MAXTRIES 3 /* number of tries allowed when giving the password */ /* - * return true if we should boot up in singleuser mode. If argv[i] is - * "single" or the file /etc/singleboot exists, then singleuser mode should - * be entered. If /etc/securesingle exists ask for root password first. + * return true if singleuser mode is allowed. + * If /etc/securesingle exists ask for root password, otherwise always OK. */ -int boot_single(int singlearg, int argc, char *argv[]) +static int check_single_ok () { - char *pass, *rootpass = NULL; - struct passwd *pwd; - int i; + char *pass, *rootpass = NULL; + struct passwd *pwd; + int i; - for(i = 1; i < argc; i++) { - if(argv[i] && !strcmp(argv[i], "single")) singlearg = 1; - } + if (access (_PATH_SECURE, R_OK) != 0) return 1; + if ( ( pwd = getpwnam ("root") ) || ( pwd = getpwuid (0) ) ) + rootpass = pwd->pw_passwd; + else + return 1; /* a bad /etc/passwd should not lock out */ - if(access(_PATH_SINGLE, 04) == 0 || singlearg) { - if(access(_PATH_SECURE, 04) == 0) { - if((pwd = getpwnam("root")) || (pwd = getpwuid(0))) - rootpass = pwd->pw_passwd; - else - return 1; /* a bad /etc/passwd should not lock out */ - - for(i = 0; i < MAXTRIES; i++) { - pass = getpass(_("Password: ")); - if(pass == NULL) continue; - - if(!strcmp(crypt(pass, rootpass), rootpass)) { - return 1; - } + for (i = 0; i < MAXTRIES; i++) + { + pass = getpass (_ ("Password: ") ); + if (pass == NULL) continue; + + if ( !strcmp (crypt (pass, rootpass), rootpass) ) return 1; - puts(_("\nWrong password.\n")); - } - } else return 1; - } - return 0; + puts (_ ("\nWrong password.\n") ); + } + return 0; } +static void do_single () +{ + char path[PATH_SIZE]; + + if (caught_sigint) return; + strcpy (path, script_prefix); + strcat (path, "single"); + if (access (path, R_OK | X_OK) == 0) + if (do_rc_tty (path) == 0) return; + if ( check_single_ok () ) enter_single (); +} /* End Function do_single */ + /* - * run /etc/rc. The environment is passed to the script, so the RC environment - * variable can be used to decide what to do. RC may be set from LILO. + * run boot script(s). The environment is passed to the script(s), so the RC + * environment variable can be used to decide what to do. + * RC may be set from LILO. + * [RETURNS] 0 on success (exit status convention), otherwise error. */ -int do_rc() +static int do_rc_tty (const char *path) { - pid_t pid; - int stat; - - if((pid = fork()) == 0) { - /* the child */ - char *argv[2]; - - argv[0] = _PATH_BSHELL; - argv[1] = (char *)0; - - close(0); - if(open(_PATH_RC, O_RDONLY, 0) == 0) { - execv(_PATH_BSHELL, argv); - err(_("exec rc failed\n")); - _exit(2); - } - err(_("open of rc file failed\n")); - _exit(1); - } else if(pid > 0) { - /* parent, wait till rc process dies before spawning */ - while(wait(&stat) != pid) /* nothing */; - } else if(pid < 0) { - err(_("fork of rc shell failed\n")); - } - return WEXITSTATUS(stat); -} + int status, rc_status = 0; + pid_t pid; + sigset_t ss; + + if (caught_sigint) return 0; + process_path (path, preload_file); + /* Launch off a subprocess to start a new session (required for frobbing + the TTY) and capture control-C */ + switch ( pid = fork () ) + { + case 0: /* Child */ + for (status = 1; status < NSIG; status++) signal (status, SIG_DFL); + sigfillset (&ss); + sigprocmask (SIG_UNBLOCK, &ss, NULL); + sigdelset (&ss, SIGINT); + sigdelset (&ss, SIGQUIT); + setsid (); + ioctl (0, TIOCSCTTY, 0); /* I want my control-C */ + sigsuspend (&ss); /* Should never return, should just be killed */ + break; /* No-one is controlled by this TTY now */ + case -1: /* Error */ + return (1); + /*break;*/ + default: /* Parent */ + break; + } + /* Parent */ + process_path (path, run_file); + while (rc_status == 0) + if (mywaitpid (-1, &status, &rc_status) == pid) + return (WTERMSIG (status) == SIGINT) ? 0 : 1; + forget_those_not_present (); + kill (pid, SIGKILL); + while (waitpid (pid, NULL, 0) != pid) /* Nothing */; + return (rc_status < 0) ? 1 : 0; +} /* End Function do_rc_tty */ + +static int process_path ( const char *path, int (*func) (const char *path) ) +{ + struct stat statbuf; + DIR *dp; + struct dirent *de; + + if (stat (path, &statbuf) != 0) + { + err (_ ("stat of path failed\n") ); + return 1; + } + if ( !( statbuf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH) ) ) return 0; + if ( !S_ISDIR (statbuf.st_mode) ) return (*func) (path); + if ( ( dp = opendir (path) ) == NULL ) + { + err (_ ("open of directory failed\n") ); + return 1; + } + while ( ( de = readdir (dp) ) != NULL ) + { + int retval; + char newpath[PATH_SIZE]; + + if (de->d_name[0] == '.') continue; + retval = sprintf (newpath, "%s/%s", path, de->d_name); + if (newpath[retval - 1] == '~') continue; /* Common mistake */ + if ( ( retval = process_path (newpath, func) ) ) return retval; + } + closedir (dp); + return 0; +} /* End Function process_path */ + +static int preload_file (const char *path) +{ + int fd; + char ch; + + if ( ( fd = open (path, O_RDONLY, 0) ) < 0) return 0; + while (read (fd, &ch, 1) == 1) lseek (fd, 1023, SEEK_CUR); + close (fd); + return 0; +} /* End Function preload_file */ + +static int run_file (const char *path) +{ + const char *ptr; + + if ( ( ptr = strrchr ( (char *) path, '/' ) ) == NULL ) ptr = path; + else ++ptr; + return (run_command (path, ptr, 0) == SIG_FAILED) ? 1 : 0; +} /* End Function preload_file */ void spawn(int i) { pid_t pid; int j; - + signed long ds_taken; + struct timeval ct; + + if (inittab[i].toks[0] == NULL) return; + /* Check if respawning too fast */ + gettimeofday (&ct, NULL); + ds_taken = ct.tv_sec - inittab[i].last_start.tv_sec; + ds_taken *= 10; + ds_taken += (ct.tv_usec - inittab[i].last_start.tv_usec) / 100000; + if (ds_taken < 1) + ds_taken = 1; + inittab[i].rate = (9 * inittab[i].rate + 1000 / ds_taken) / 10; + if (inittab[i].rate > MAX_RESPAWN_RATE) { + char txt[256]; + + inittab[i].toks[0] = NULL; + inittab[i].pid = -1; + inittab[i].rate = 0; + sprintf (txt,"respawning: \"%s\" too fast: quenching entry\n", + inittab[i].tty); + err (_(txt)); + return; + } + if((pid = fork()) < 0) { inittab[i].pid = -1; err(_("fork failed\n")); @@ -276,6 +418,7 @@ void spawn(int i) if(pid) { /* this is the parent */ inittab[i].pid = pid; + inittab[i].last_start = ct; return; } else { /* this is the child */ @@ -310,7 +453,9 @@ void read_inittab() FILE *f; char buf[CMDSIZ]; int i,j,k; + int has_prog = 0; char *ptr, *getty; + char prog[PATH_SIZE]; #ifdef SPECIAL_CONSOLE_TERM char tty[50]; struct stat stb; @@ -322,21 +467,43 @@ void read_inittab() if(!(f = fopen(_PATH_INITTAB, "r"))) { err(_("cannot open inittab\n")); - _exit(1); + return; } + prog[0] = '\0'; i = 0; while(!feof(f) && i < NUMCMD - 2) { if(fgets(buf, CMDSIZ - 1, f) == 0) break; buf[CMDSIZ-1] = 0; for(k = 0; k < CMDSIZ && buf[k]; k++) { - if(buf[k] == '#') { + if ((buf[k] == '#') || (buf[k] == '\n')) { buf[k] = 0; break; } } if(buf[0] == 0 || buf[0] == '\n') continue; + ptr = strchr (buf, '='); + if (ptr) { + ptr++; + if ( !strncmp (buf, "bootprog", 8) ) { + while ( isspace (*ptr) ) ++ptr; + strcpy (prog, ptr); + has_prog = 1; + continue; + } + if ( !strncmp (buf, "fileprefix", 10) ) { + while ( isspace (*ptr) ) ++ptr; + strcpy (script_prefix, ptr); + continue; + } + if ( !strncmp (buf, "PATH", 4) ) { + while ( isspace (*ptr) ) ++ptr; + setenv ("PATH", ptr, 1); + continue; + } + } + (void) strcpy(inittab[i].line, buf); @@ -373,6 +540,17 @@ void read_inittab() } fclose(f); numcmd = i; + if (has_prog) { + int len; + char path[PATH_SIZE]; + + strcpy (path, script_prefix); + strcat (path, prog); + len = strlen (path); + if (path[len - 1] == '/') path[len - 1] = '\0'; + if (access (path, R_OK | X_OK) == 0) + strcpy (boot_script, path); + } } void hup_handler() @@ -413,13 +591,9 @@ void tstp_handler() void int_handler() { - /* - * After Linux 0.96b PL1, we get a SIGINT when - * the user presses Ctrl-Alt-Del... - */ - - int pid; + pid_t pid; + caught_sigint = 1; sync(); sync(); pid = fork(); @@ -432,6 +606,17 @@ void int_handler() my_reboot(LINUX_REBOOT_CMD_RESTART); } +static void sigchild_handler (int sig) +{ + if (!do_longjmp) return; + siglongjmp (jmp_env, 1); +} + +static void sigquit_handler (int sig) +{ + execl (_PATH_REBOOT, _PATH_REBOOT, NULL); /* It knows pid=1 must sleep */ +} + void set_tz() { FILE *f; @@ -466,3 +651,285 @@ void write_wtmp() close(lf); } } + + +struct waiter_struct +{ + struct waiter_struct *next; + pid_t pid; +}; + +struct script_struct +{ + pid_t pid; + struct script_struct *prev, *next; + struct waiter_struct *first_waiter; + char name[1]; +}; + +struct list_head +{ + struct script_struct *first, *last; +}; + + +static struct list_head available_list = {NULL, NULL}; +static struct list_head starting_list = {NULL, NULL}; +static struct list_head failed_list = {NULL, NULL}; +static struct list_head unavailable_list = {NULL, NULL}; + + +static void process_pidstat (pid_t pid, int status, int *rc_status); +static struct script_struct *find_script (const char *name, + struct list_head *head); +static void insert_entry (struct list_head *head, struct script_struct *entry); +static void remove_entry (struct list_head *head, struct script_struct *entry); +static void signal_waiters (struct script_struct *script, int sig); + + +static pid_t mywaitpid (pid_t pid, int *status, int *rc_status) +{ + int ival; + struct script_struct *script; + sigset_t ss_new, ss_old; + long buffer[COMMAND_SIZE / sizeof (long)]; + struct command_struct *command = (struct command_struct *) buffer; + + if (initctl_fd < 0) return waitpid (pid, status, 0); + if (status == NULL) status = &ival; + if ( ( pid = waitpid (pid, status, WNOHANG) ) > 0 ) + { + process_pidstat (pid, *status, rc_status); + return pid; + } + /* Some magic to avoid races */ + command->command = -1; + sigemptyset (&ss_new); + sigaddset (&ss_new, SIGCHLD); + sigprocmask (SIG_BLOCK, &ss_new, &ss_old); + ival = sigsetjmp (jmp_env, 0); + sigprocmask (SIG_SETMASK, &ss_old, NULL); + if (ival == 0) do_longjmp = 1; + else + { + do_longjmp = 0; + if (command->command < 0) return 0; + } + if (command->command < 0) read (initctl_fd, buffer, COMMAND_SIZE); + do_longjmp = 0; + switch (command->command) + { + case COMMAND_TEST: + kill (command->pid, + (find_script (command->name, &available_list) == NULL) ? + SIG_NOT_PRESENT : SIG_PRESENT); + break; + case COMMAND_NEED: + ival = run_command (command->name, command->name, command->pid); + if (ival != 0) kill (command->pid, ival); + break; + case COMMAND_ROLLBACK: + if (command->name[0] == '\0') script = NULL; + else + { + if ( ( script = find_script (command->name, &available_list) ) + == NULL ) + { + kill (command->pid, SIG_NOT_PRESENT); + break; + } + } + while (script != available_list.first) + { + struct script_struct *victim = available_list.first; + + if ( ( pid = fork () ) == 0 ) /* Child */ + { + for (ival = 1; ival < NSIG; ival++) signal (ival, SIG_DFL); + open ("/dev/console", O_RDONLY, 0); + open ("/dev/console", O_RDWR, 0); + dup2 (1, 2); + execlp (victim->name, victim->name, "stop", NULL); + err ( _("error running programme\n") ); + _exit (SIG_NOT_STOPPED); + } + else if (pid == -1) break; /* Error */ + else /* Parent */ + { + while (waitpid (pid, &ival, 0) != pid) /* Nothing */; + if ( WIFEXITED (ival) && (WEXITSTATUS (ival) == 0) ) + { + remove_entry (&available_list, victim); + free (victim); + } + else break; + } + } + kill (command->pid, + (script ==available_list.first) ? SIG_STOPPED : SIG_NOT_STOPPED); + break; + case COMMAND_DUMP_LIST: + if (fork () == 0) + { + FILE *fp; + + if ( ( fp = fopen (command->name, "w") ) == NULL ) _exit (1); + fputs ("AVAILABLE SERVICES:\n", fp); + for (script = available_list.first; script != NULL; + script = script->next) fprintf (fp, "%s\n", script->name); + fputs ("FAILED SERVICES:\n", fp); + for (script = failed_list.first; script != NULL; + script = script->next) fprintf (fp, "%s\n", script->name); + fclose (fp); + _exit (0); + } + break; + case -1: + default: + break; + } + return 0; +} /* End Function mywaitpid */ + +static void process_pidstat (pid_t pid, int status, int *rc_status) +{ + struct script_struct *script; + + if (initctl_fd < 0) return; + if (pid < 1) return; + for (script = starting_list.first; script != NULL; script = script->next) + if (script->pid == pid) break; + if (script == NULL) return; + remove_entry (&starting_list, script); + if ( WIFEXITED (status) && (WEXITSTATUS (status) == 0) ) + { + signal_waiters (script, SIG_PRESENT); + insert_entry (&available_list, script); + } + else if ( WIFEXITED (status) && (WEXITSTATUS (status) == 2) ) + { + signal_waiters (script, SIG_NOT_PRESENT); + insert_entry (&unavailable_list, script); + } + else + { + signal_waiters (script, SIG_FAILED); + insert_entry (&failed_list, script); + } + if ( (rc_status == NULL) || (starting_list.first != NULL) ) return; + *rc_status = (failed_list.first == NULL) ? 1 : -1; +} /* End Function process_pidstat */ + +static int run_command (const char *path, const char *name, pid_t pid) +{ + struct script_struct *script; + struct waiter_struct *waiter = NULL; + + if (find_script (name, &available_list) != NULL) return SIG_PRESENT; + if (find_script (name, &failed_list) != NULL) return SIG_FAILED; + if (find_script (name, &unavailable_list) != NULL) return SIG_NOT_PRESENT; + if (pid != 0) + { + waiter = calloc (1, sizeof *waiter); + if (waiter == NULL) return SIG_FAILED; + waiter->pid = pid; + } + script = find_script (name, &starting_list); + if (script == NULL) + { + int i; + + script = calloc (1, strlen (name) + sizeof *script); + if (script == NULL) + { + if (waiter != NULL) free (waiter); + return SIG_FAILED; + } + strcpy (script->name, name); + switch ( script->pid = fork () ) + { + case 0: /* Child */ + for (i = 1; i < NSIG; i++) signal (i, SIG_DFL); + execlp (path, script->name, "start", NULL); + err ( _("error running programme\n") ); + _exit (SIG_FAILED); + break; + case -1: /* Error */ + free (script); + if (waiter != NULL) free (waiter); + return SIG_FAILED; + /*break;*/ + default: /* Parent */ + insert_entry (&starting_list, script); + sched_yield (); + break; + } + } + if (waiter == NULL) return 0; + waiter->next = script->first_waiter; + script->first_waiter = waiter; + return 0; +} /* End Function run_command */ + +static struct script_struct *find_script (const char *name, + struct list_head *head) +{ + struct script_struct *entry; + + for (entry = head->first; entry != NULL; entry = entry->next) + { + if (strcmp (entry->name, name) == 0) return (entry); + } + return NULL; +} /* End Function find_script */ + +static void insert_entry (struct list_head *head, struct script_struct *entry) +{ + if (entry == NULL) return; + entry->prev = NULL; + entry->next = head->first; + if (head->first != NULL) head->first->prev = entry; + head->first = entry; + if (head->last == NULL) head->last = entry; +} /* End Function insert_entry */ + +static void remove_entry (struct list_head *head, struct script_struct *entry) +{ + if (entry->prev == NULL) head->first = entry->next; + else entry->prev->next = entry->next; + if (entry->next == NULL) head->last = entry->prev; + else entry->next->prev = entry->prev; +} /* End Function remove_entry */ + +static void signal_waiters (struct script_struct *script, int sig) +{ + struct waiter_struct *waiter, *next_waiter; + + for (waiter = script->first_waiter; waiter != NULL; waiter = next_waiter) + { + kill (waiter->pid, sig); + next_waiter = waiter->next; + free (waiter); + } + script->first_waiter = NULL; +} /* End Function signal_waiters */ + +static void forget_those_not_present () +{ + struct script_struct *curr, *next; + + for (curr = failed_list.first; curr != NULL; curr = next) + { + next = curr->next; + free (curr); + } + failed_list.first = NULL; + failed_list.last = NULL; + for (curr = unavailable_list.first; curr != NULL; curr = next) + { + next = curr->next; + free (curr); + } + unavailable_list.first = NULL; + unavailable_list.last = NULL; +} /* End Function forget_those_not_present */ diff --git a/login-utils/simpleinit.h b/login-utils/simpleinit.h new file mode 100644 index 00000000..ff26480f --- /dev/null +++ b/login-utils/simpleinit.h @@ -0,0 +1,25 @@ +#include +#include + + +#define ERRSTRING strerror (errno) +#define COMMAND_SIZE (PIPE_BUF - 4) + + +#define COMMAND_TEST 0 /* No wait, signal */ +#define COMMAND_NEED 1 /* Wait, signal */ +#define COMMAND_ROLLBACK 2 /* Wait, signal */ +#define COMMAND_DUMP_LIST 3 /* No wait, no signal */ + +#define SIG_PRESENT SIGUSR1 /* Service is available */ +#define SIG_STOPPED SIGUSR1 /* Service was stopped OK */ +#define SIG_NOT_PRESENT SIGUSR2 /* Not present, but that's OK */ +#define SIG_FAILED SIGPOLL /* Startup failed */ +#define SIG_NOT_STOPPED SIGPOLL /* Failed to stop */ + +struct command_struct /* Must always be COMMAND_SIZE */ +{ + signed int command; + pid_t pid; + char name[1]; +}; diff --git a/misc-utils/cal.c b/misc-utils/cal.c index fe35e185..bc0c1eff 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -63,7 +63,7 @@ #define THURSDAY 4 /* for reformation */ #define SATURDAY 6 /* 1 Jan 1 was a Saturday */ -#define FIRST_MISSING_DAY 639787 /* 3 Sep 1752 */ +#define FIRST_MISSING_DAY 639799 /* 3 Sep 1752 */ #define NUMBER_MISSING_DAYS 11 /* 11 day correction */ #define MAXDAYS 43 /* max slots in a month array */ @@ -141,10 +141,7 @@ void headers_init(void); extern char *__progname; int -main(argc, argv) - int argc; - char **argv; -{ +main(int argc, char **argv) { struct tm *local_time; time_t now; int ch, month, year, yflag; diff --git a/misc-utils/ddate.c b/misc-utils/ddate.c index f00a8fd0..304c31c6 100644 --- a/misc-utils/ddate.c +++ b/misc-utils/ddate.c @@ -29,6 +29,8 @@ 1999-02-22 Arkadiusz Mi¶kiewicz - added Native Language Support + 2000-03-17 Burt Holzman + - added range checks for dates */ #include "../defines.h" /* for util-linux-version */ @@ -129,13 +131,21 @@ default_fmt #define DY(y) (y+1166) -inline char *ending(int i) { return (i%10==1)?"st":(i%10==2?"nd":(i%10==3?"rd":"th"));}; -inline int leapp(int i) { return (!(DY(i)%4))&&((DY(i)%100)||(!(DY(i)%400)));}; +static inline char *ending(int i) { + return (i%10==1)?"st":(i%10==2?"nd":(i%10==3?"rd":"th")); +} + +static inline int leapp(int i) { + return (!(DY(i)%4))&&((DY(i)%100)||(!(DY(i)%400))); +} + +/* select a random string */ +static inline char *sel(char **strings, int num) { + return(strings[random()%num]); +} void print(struct disc_time,char **); /* old */ void format(char *buf, const char* fmt, struct disc_time dt); -/* select a random string */ -inline char *sel(char **strings, int num) {return(strings[random()%num]); }; /* read a fortune file */ int load_fortunes(char *fn, char *delim, char** result); @@ -186,6 +196,10 @@ main (int argc, char *argv[]) larry,moe, #endif curly); + if (hastur.season == -1) { + printf("Invalid date -- out of range\n"); + return -1; + } fnord=fnord?fnord:default_fmt; } else if (argc!=pi) { usage: @@ -201,6 +215,7 @@ main (int argc, char *argv[]) } format(schwa, fnord, hastur); printf("%s\n", schwa); + return 0; } @@ -282,6 +297,19 @@ struct disc_time makeday(int imonth,int iday,int iyear) /*i for input */ int cal[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 }; int dayspast=0; + + /* basic range checks */ + if (imonth < 1 || imonth > 12) { + funkychickens.season = -1; + return funkychickens; + } + if (iday < 1 || iday > cal[imonth-1]) { + if (!(imonth == 2 && iday == 29 && iyear%4 == 0 && + (iyear%100 != 0 || iyear%400 == 0))) { + funkychickens.season = -1; + return funkychickens; + } + } imonth--; funkychickens.year= iyear+1166; diff --git a/misc-utils/kill.c b/misc-utils/kill.c index 5372f521..ea4e4682 100644 --- a/misc-utils/kill.c +++ b/misc-utils/kill.c @@ -48,6 +48,7 @@ #include #include #include +#include "kill.h" #include "nls.h" #define SIZE(a) (sizeof(a)/sizeof(a[0])) diff --git a/misc-utils/kill.h b/misc-utils/kill.h new file mode 100644 index 00000000..27a12a80 --- /dev/null +++ b/misc-utils/kill.h @@ -0,0 +1 @@ +extern int *get_pids (char *process_name, int get_all); diff --git a/misc-utils/logger.c b/misc-utils/logger.c index 9d848a66..372fe1ec 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -54,12 +54,10 @@ int decode __P((char *, CODE *)); int pencode __P((char *)); void usage __P((void)); -int -myopenlog(sock) - const char *sock; -{ +static int +myopenlog(const char *sock) { int fd; - static struct sockaddr s_addr; /* AF_UNIX address of local logger */ + static struct sockaddr s_addr; /* AF_UNIX address of local logger */ s_addr.sa_family = AF_UNIX; (void)strncpy(s_addr.sa_data, sock, sizeof(s_addr.sa_data)); @@ -76,14 +74,8 @@ myopenlog(sock) return fd; } -void -mysyslog(fd, logflags, pri, tag, msg) - int fd; - int logflags; - int pri; - char *tag; - char *msg; -{ +static void +mysyslog(int fd, int logflags, int pri, char *tag, char *msg) { char buf[1000], pid[30], *cp, *tp; time_t now; @@ -120,10 +112,7 @@ mysyslog(fd, logflags, pri, tag, msg) * log. */ int -main(argc, argv) - int argc; - char *argv[]; -{ +main(int argc, char **argv) { int ch, logflags, pri; char *tag, buf[1024]; char *usock = NULL; diff --git a/misc-utils/md5.h b/misc-utils/md5.h index e264f686..b211ed24 100644 --- a/misc-utils/md5.h +++ b/misc-utils/md5.h @@ -1,7 +1,7 @@ #ifndef MD5_H #define MD5_H -#ifdef __alpha +#if defined (__alpha__) || defined (__ia64__) typedef unsigned int uint32; #else typedef unsigned long uint32; diff --git a/misc-utils/namei.c b/misc-utils/namei.c index 2541d03b..65faad4f 100644 --- a/misc-utils/namei.c +++ b/misc-utils/namei.c @@ -47,17 +47,13 @@ chdir to /, or if it encounters an unknown file type. #include #include #include +#include #include #include #include #include "nls.h" -#ifndef __GNU_LIBRARY__ -extern char *sys_errlist[]; -#endif - -extern int errno; -#define ERR sys_errlist[errno],errno +#define ERR strerror(errno),errno int symcount; int mflag = 0; @@ -67,17 +63,14 @@ int xflag = 0; #define MAXSYMLINKS 256 #endif -static char *pperm(); +static char *pperm(unsigned short); +static void namei(char *, int); +static void usage(void); int -main(argc, argv) -int argc; -char *argv[]; -{ - void namei(), usage(); - int getopt(); +main(int argc, char **argv) { extern int optind; - register int c; + int c; char curdir[MAXPATHLEN]; setlocale(LC_ALL, ""); @@ -122,9 +115,8 @@ char *argv[]; return 0; } -void -usage() -{ +static void +usage(void) { (void)fprintf(stderr,_("usage: namei [-mx] pathname [pathname ...]\n")); exit(1); } @@ -133,16 +125,12 @@ usage() #define NODEV (dev_t)(-1) #endif -void -namei(file, lev) - -register char *file; -register int lev; -{ - register char *cp; +static void +namei(char *file, int lev) { + char *cp; char buf[BUFSIZ], sym[BUFSIZ]; struct stat stb; - register int i; + int i; dev_t lastdev = NODEV; /* @@ -305,9 +293,7 @@ register int lev; * For example 0755 produces "rwxr-xr-x" */ static char * -pperm(mode) -unsigned short mode; -{ +pperm(unsigned short mode) { unsigned short m; static char buf[16]; char *bp; diff --git a/misc-utils/procs.c b/misc-utils/procs.c index fd0e5add..715d9fb0 100644 --- a/misc-utils/procs.c +++ b/misc-utils/procs.c @@ -14,20 +14,21 @@ #define _POSIX_SOURCE 1 -#include -#include #include #include #include #include #include #include +#include +#include +#include "kill.h" extern char *mybasename (char *); static char *parse_parens (char *buf); -int *get_pids (char *process_name, int get_all) -{ +int * +get_pids (char *process_name, int get_all) { DIR *dir; struct dirent *ent; int status; diff --git a/misc-utils/rename.c b/misc-utils/rename.c index af5ba44c..05f8f19b 100644 --- a/misc-utils/rename.c +++ b/misc-utils/rename.c @@ -21,7 +21,7 @@ for i in $@; do N=`echo "$i" | sed "s/$FROM/$TO/g"`; mv "$i" "$N"; done static char *progname; -int +static int do_rename(char *from, char *to, char *s) { char *newname, *where, *p, *q; int flen, tlen, slen; @@ -49,7 +49,7 @@ do_rename(char *from, char *to, char *s) { p = where+flen; while (*p) *q++ = *p++; - *p = 0; + *q = 0; if (rename(s, newname) != 0) { int errsv = errno; diff --git a/misc-utils/script.c b/misc-utils/script.c index 283bc8fc..cb7ae1a9 100644 --- a/misc-utils/script.c +++ b/misc-utils/script.c @@ -38,6 +38,10 @@ /* * script */ +#include +#include +#include +#include #include #include #include @@ -45,8 +49,6 @@ #include #include #include -#include -#include #include "nls.h" #ifdef __linux__ @@ -59,6 +61,7 @@ #include #endif +void finish(int); void done(void); void fail(void); void fixtty(void); @@ -86,14 +89,9 @@ char line[] = "/dev/ptyXX"; int aflg; int -main(argc, argv) - int argc; - char *argv[]; -{ +main(int argc, char **argv) { extern int optind; int ch; - void finish(); - char *getenv(); setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); @@ -152,8 +150,7 @@ main(argc, argv) } void -doinput() -{ +doinput() { register int cc; char ibuf[BUFSIZ]; @@ -169,8 +166,7 @@ doinput() #include void -finish() -{ +finish(int dummy) { union wait status; register int pid; register int die = 0; @@ -184,11 +180,10 @@ finish() } void -dooutput() -{ +dooutput() { register int cc; - time_t tvec, time(); - char obuf[BUFSIZ], *ctime(); + time_t tvec; + char obuf[BUFSIZ]; (void) close(0); #ifdef HAVE_openpty @@ -207,8 +202,7 @@ dooutput() } void -doshell() -{ +doshell() { /*** int t; @@ -235,8 +229,7 @@ doshell() } void -fixtty() -{ +fixtty() { struct termios rtt; rtt = tt; @@ -246,18 +239,15 @@ fixtty() } void -fail() -{ +fail() { (void) kill(0, SIGTERM); done(); } void -done() -{ - time_t tvec, time(); - char *ctime(); +done() { + time_t tvec; if (subchild) { tvec = time((time_t *)NULL); @@ -272,8 +262,7 @@ done() } void -getmaster() -{ +getmaster() { #ifdef HAVE_openpty (void) tcgetattr(0, &tt); (void) ioctl(0, TIOCGWINSZ, (char *)&win); @@ -318,8 +307,7 @@ getmaster() } void -getslave() -{ +getslave() { #ifndef HAVE_openpty line[strlen("/dev/")] = 't'; slave = open(line, O_RDWR); diff --git a/misc-utils/setterm.1 b/misc-utils/setterm.1 index 0dbbdf42..6fffa219 100644 --- a/misc-utils/setterm.1 +++ b/misc-utils/setterm.1 @@ -1,81 +1,192 @@ .\" Copyright 1990 Gordon Irlam (gordoni@cs.ua.oz.au) .\" Copyright 1992 Rickard E. Faith (faith@cs.unc.edu) -.\" Most of this was copied from the source code. Do not restrict distribution. +.\" Most of this was copied from the source code. +.\" Do not restrict distribution. .\" May be distributed under the GNU General Public License -.TH SETTERM 1 "2 July 1996" "Util-Linux 2.6" "Linux Programmer's Manual" +.\" +.\" Most options documented by Colin Watson (cjw44@cam.ac.uk) +.\" Undocumented: -snow, -softscroll, -standout; these are +.\" commented out in the source +.\" +.TH SETTERM 1 "7 January 2000" "Util-Linux 2.10" "Linux Programmer's Manual" .SH NAME setterm \- set terminal attributes .SH SYNOPSIS .nf -.BR "setterm [ \-term " terminal_name " ]" -.B "setterm [ \-reset ]" -.B "setterm [ \-initialize ]" -.B "setterm [ \-cursor [on|off] ]" -.B "setterm [ \-repeat [on|off] ]" -.B "setterm [ \-appcursorkeys [on|off] ]" -.B "setterm [ \-linewrap [on|off] ]" -.B "setterm [ \-snow [on|off] ]" -.B "setterm [ \-softscroll [on|off] ]" -.B "setterm [ \-defaults ]" -.B "setterm [ \-foreground black|red|green|yellow|blue|magenta|cyan|white|default ]" -.B "setterm [ \-background black|red|green|yellow|blue|magenta|cyan|white|default ]" -.B "setterm [ \-ulcolor black|grey|red|green|yellow|blue|magenta|cyan|white ]" -.B "setterm [ \-ulcolor bright red|green|yellow|blue|magenta|cyan|white ]" -.B "setterm [ \-hbcolor black|grey|red|green|yellow|blue|magenta|cyan|white ]" -.B "setterm [ \-hbcolor bright red|green|yellow|blue|magenta|cyan|white ]" -.B "setterm [ \-inversescreen [on|off] ]" -.B "setterm [ \-bold [on|off] ]" -.B "setterm [ \-half-bright [on|off] ]" -.B "setterm [ \-blink [on|off] ]" -.B "setterm [ \-reverse [on|off] ]" -.B "setterm [ \-underline [on|off] ]" -.B "setterm [ \-store ]" -.B "setterm [ \-clear [ all|rest ] ]" -.BR "setterm [ \-tabs [tab1 tab2 tab3 ... ] ]" " where (tabn = 1-160)" -.BR "setterm [ \-clrtabs [ tab1 tab2 tab3 ... ]" " where (tabn = 1-160)" -.BR "setterm [ \-regtabs [" " 1-160 " "] ]" -.BR "setterm [ \-blank [" " 0-60 " "] ]" -.BR "setterm [ \-powersave [ on|vsync|hsync|powerdown|off ] ]" -.BR "setterm [ \-powerdown [" " 0-60 " "] ]" -.BR "setterm [ \-dump [" " 1-NR_CONS " "] ]" -.BR "setterm [ \-append [" " 1-NR_CONS " "] ]" -.BR "setterm [ \-file" " dumpfilename " ] -.BR "setterm [ \-standout [" " attr " "] ]" -.BR "setterm [ \-blength [" " 0-2000 " "] ]" -.B "setterm [ \-bfreq freqnumber ]" +.BR "setterm " [ options ] .fi .SH DESCRIPTION .B setterm -writes to standard output a character string that will invoke the specified -terminal capabilities. Where possibile +writes to standard output a character string that will invoke the +specified terminal capabilities. Where possible .I terminfo -is consulted to find the string to use. Some options however do not -correspond to a +is consulted to find the string to use. Some options however (marked +"virtual consoles only" below) do not correspond to a .BR terminfo (5) -capability. In this case, if the terminal type is "con", or -"linux" the string that invokes the specified capabilities on the PC -Minix virtual console driver is output. Options that are not implemented -by the terminal are ignored. +capability. In this case, if the terminal type is "con" or "linux" the +string that invokes the specified capabilities on the PC Minix virtual +console driver is output. Options that are not implemented by the terminal +are ignored. .SH OPTIONS -Most options are self explanatory. The less obvious options are as -follows: +For boolean options (\fBon\fP or \fBoff\fP), the default is \fBon\fP. +.P +For conciseness, an \fI8-color\fP below is \fBblack\fP, \fBred\fP, +\fBgreen\fP, \fByellow\fP, \fBblue\fP, \fBmagenta\fP, \fBcyan\fP, or +\fBwhite\fP. +.P +A \fI16-color\fP is an \fI8-color\fP, \fBgrey\fP, or \fBbright\fP followed +by \fBred\fP, \fBgreen\fP, \fByellow\fP, \fBblue\fP, \fBmagenta\fP, +\fBcyan\fP, or \fBwhite\fP. +.P +The various color options may be set independently, at least at virtual +consoles, though the results of setting multiple modes (for example, +.BR \-underline " and " \-half-bright ) +are hardware-dependent. .TP -.B \-term -can be used to override the TERM environment variable. +.BR \-term " terminal_name" +Overrides the TERM environment variable. .TP .B \-reset -displays the terminal reset string, which typically resets the terminal to +Displays the terminal reset string, which typically resets the terminal to its power on state. .TP .B \-initialize -displays the terminal initialization string, which typically sets the +Displays the terminal initialization string, which typically sets the terminal's rendering options, and other attributes to the default values. .TP +.BR \-cursor " [" on | off ] +Turns the terminal's cursor on or off. +.TP +.BR \-repeat " [" on | off "] (virtual consoles only)" +Turns keyboard repeat on or off. +.TP +.BR \-appcursorkeys " [" on | off "] (virtual consoles only)" +Sets Cursor Key Application Mode on or off. When on, ESC O A, ESC O B, etc. +will be sent for the cursor keys instead of ESC [ A, ESC [ B, etc. See the +"vi and Cursor-Keys" section of the Text-Terminal-HOWTO for how this can +cause problems for vi users. +.TP +.BR \-linewrap " [" on | off "] (virtual consoles only)" +Turns automatic line-wrapping on or off. +.TP .B \-default -sets the terminal's rendering options to the default values. +Sets the terminal's rendering options to the default values. +.TP +\fB\-foreground\fP \fI8-color\fP|\fBdefault\fP (virtual consoles only) +Sets the foreground text color. +.TP +\fB\-background\fP \fI8-color\fP|\fBdefault\fP (virtual consoles only) +Sets the background text color. +.TP +\fB\-ulcolor\fP \fI16-color\fP (virtual consoles only) +Sets the color for underlined characters. +.TP +\fB\-hbcolor\fP \fI16-color\fP (virtual consoles only) +Sets the color for half-bright characters. +.TP +.BR \-inversescreen " [" on | off "] (virtual consoles only)" +Inverts the screen colors. Foreground and background are swapped, as are +underline and half-brightness. +.TP +.BR \-bold " [" on | off ] +Turns bold (extra bright) mode on or off. Except at a virtual console, +\fB\-bold off\fP turns off all attributes (bold, half-brightness, blink, +reverse). +.TP +.BR \-half-bright " [" on | off ] +Turns dim (half-brightness) mode on or off (see \fB\-hbcolor\fP). Except at +a virtual console, \fB\-half-bright off\fP turns off all attributes (bold, +half-brightness, blink, reverse). +.TP +.BR \-blink " [" on | off ] +Turns blink mode on or off. Except at a virtual console, \fB\-blink off\fP +turns off all attributes (bold, half-brightness, blink, reverse). +.TP +.BR \-reverse " [" on | off ] +Turns reverse video mode on or off. Except at a virtual console, +\fB\-reverse off\fP turns off all attributes (bold, half-brightness, blink, +reverse). +.TP +.BR \-underline " [" on | off ] +Turns underline mode on or off (see \fB\-ulcolor\fP). +.TP +.BR \-store " (virtual consoles only)" +Stores the terminal's current rendering options as the default values. +.TP +.BR \-clear " [" all ] +Clears the screen and "homes" the cursor, as +.BR clear (1). +.TP +.B \-clear rest +Clears from the current cursor position to the end of the screen. +.TP +.BR \-tabs " [tab1 tab2 tab3 ...] (virtual consoles only)" +Sets tab stops at the given horizontal cursor positions, in the range 1-160. +Without arguments, shows the current tab stop settings. +.TP +.BR \-clrtabs " [tab1 tab2 tab3 ...] (virtual consoles only)" +Clears tab stops from the given horizontal cursor positions, in the range +1-160. Without arguments, clears all tab stops. +.TP +.BR \-regtabs " [1-160] (virtual consoles only)" +Clears all tab stops, then sets a regular tab stop pattern, with one tab +every specified number of positions. Without an argument, defaults to 8. +.TP +.BR \-blank " [0-60] (virtual consoles only)" +Sets the interval of inactivity, in minutes, after which the screen will be +automatically blanked (using APM if available). Without an argument, +defaults to 0 (disable console blanking). +.TP +.BR \-dump " [1-NR_CONS]" +Writes a snapshot of the given virtual console (with attributes) to the file +specified in the \fB\-file\fP option, overwriting its contents; the default +is screen.dump. Without an argument, dumps the current virtual console. +Overrides \fB\-append\fP. +.TP +.BR \-append " [1-NR_CONS]" +Like \fB\-dump\fP, but appends to the snapshot file instead of overwriting +it. Only works if no \fB\-dump\fP options are given. +.TP +.BR \-file " dumpfilename" +Sets the snapshot file name for any \fB\-dump\fP or \fB\-append\fP options +on the same command line. If this option is not present, the default is +screen.dump in the current directory. +.TP +.BR \-msg " [" on | off "] (virtual consoles only)" +Enables or disables the sending of kernel \fBprintk()\fP messages to the +console. +.TP +.BR \-msglevel " 1-8 (virtual consoles only)" +Sets the console logging level for kernel \fBprintk()\fP messages. All +messages strictly more important than this will be printed, so a logging +level of 0 has the same effect as \fB\-msg on\fP and a logging level of 8 +will print all kernel messages. +.BR klogd (8) +may be a more convenient interface to the logging of kernel messages. +.TP +.BR "\-powersave on" | vsync +Puts the monitor into VESA vsync suspend mode. +.TP +.B \-powersave hsync +Puts the monitor into VESA hsync suspend mode. +.TP +.B \-powersave powerdown +Puts the monitor into VESA powerdown mode. +.TP +.BR \-powersave " [" off "]" +Turns off monitor VESA powersaving features. +.TP +.BR \-powerdown " [0-60]" +Sets the VESA powerdown interval in minutes. Without an argument, defaults +to 0 (disable powerdown). If the console is blanked or the monitor is in +suspend mode, then the monitor will go into vsync suspend mode or powerdown +mode respectively after this period of time has elapsed. +.TP +.BR \-blength " [0-2000]" +Sets the bell duration in milliseconds. Without an argument, defaults to 0. .TP -.B \-store -stores the terminal's current rendering options as the default values. +.BR \-bfreq " [freqnumber]" +Sets the bell frequency in Hz. Without an argument, defaults to 0. .SH "SEE ALSO" .BR tput (1), .BR stty (1), @@ -83,11 +194,3 @@ stores the terminal's current rendering options as the default values. .BR tty (4) .SH BUGS Differences between the Minix and Linux versions are not documented. -.SH AUTHORS -Gordon Irlam (gordoni@cs.ua.oz.au) -.br -Adaption to Linux by Peter MacDonald -.br -Enhancements by Mika Liljeberg (liljeber@cs.Helsinki.FI) -.br -Beep patch by Christophe Jolif (cjolif@storm.gatelink.fr.net) diff --git a/misc-utils/setterm.c b/misc-utils/setterm.c index 36d3be19..92161d01 100644 --- a/misc-utils/setterm.c +++ b/misc-utils/setterm.c @@ -90,8 +90,8 @@ * -store stores the terminal's current rendering options as the default * values. */ -#include #include +#include #include #include #include @@ -193,892 +193,921 @@ int opt_ps_mode, opt_pd_min; /* powersave mode/powerdown time */ char opt_sn_name[200] = "screen.dump"; -void screendump(int vcnum, FILE *F); +static void screendump(int vcnum, FILE *F); /* Command line parsing routines. * * Note that it is an error for a given option to be invoked more than once. */ -void parse_term(argc, argv, option, opt_term, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Term flag to set. */ -char **opt_term; /* Terminal name to set. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_term(int argc, char **argv, int *option, char **opt_term, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Term flag to set. */ + /* opt_term: Terminal name to set. */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a -term specification. */ - if (argc != 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - *opt_term = argv[0]; - } + if (argc != 1 || *option) + *bad_arg = TRUE; + *option = TRUE; + if (argc == 1) + *opt_term = argv[0]; } -void parse_none(argc, argv, option, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Option flag to set. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_none(int argc, char **argv, int *option, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Term flag to set. */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a parameterless specification. */ - if (argc != 0 || *option) *bad_arg = TRUE; - *option = TRUE; + if (argc != 0 || *option) + *bad_arg = TRUE; + *option = TRUE; } -void parse_switch(argc, argv, option, opt_on, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Option flag to set. */ -int *opt_on; /* Boolean option switch to set or reset. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_switch(int argc, char **argv, int *option, int *opt_on, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Option flag to set. */ + /* opt_on: Boolean option switch to set or reset. */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a boolean (on/off) specification. */ - if (argc > 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - if (strcmp(argv[0], "on") == 0) - *opt_on = TRUE; - else if (strcmp(argv[0], "off") == 0) - *opt_on = FALSE; - else + if (argc > 1 || *option) *bad_arg = TRUE; - } else { - *opt_on = TRUE; - } + *option = TRUE; + if (argc == 1) { + if (strcmp(argv[0], "on") == 0) + *opt_on = TRUE; + else if (strcmp(argv[0], "off") == 0) + *opt_on = FALSE; + else + *bad_arg = TRUE; + } else { + *opt_on = TRUE; + } } -void par_color(argc, argv, option, opt_color, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Color flag to set. */ -int *opt_color; /* Color to set. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +par_color(int argc, char **argv, int *option, int *opt_color, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Color flag to set. */ + /* opt_color: Color to set. */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a -foreground or -background specification. */ - if (argc != 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - if (strcmp(argv[0], "black") == 0) - *opt_color = BLACK; - else if (strcmp(argv[0], "red") == 0) - *opt_color = RED; - else if (strcmp(argv[0], "green") == 0) - *opt_color = GREEN; - else if (strcmp(argv[0], "yellow") == 0) - *opt_color = YELLOW; - else if (strcmp(argv[0], "blue") == 0) - *opt_color = BLUE; - else if (strcmp(argv[0], "magenta") == 0) - *opt_color = MAGENTA; - else if (strcmp(argv[0], "cyan") == 0) - *opt_color = CYAN; - else if (strcmp(argv[0], "white") == 0) - *opt_color = WHITE; - else if (strcmp(argv[0], "default") == 0) - *opt_color = DEFAULT; - else if (isdigit(argv[0][0])) - *opt_color = atoi(argv[0]); - else - *bad_arg = TRUE; + if (argc != 1 || *option) + *bad_arg = TRUE; + *option = TRUE; + if (argc == 1) { + if (strcmp(argv[0], "black") == 0) + *opt_color = BLACK; + else if (strcmp(argv[0], "red") == 0) + *opt_color = RED; + else if (strcmp(argv[0], "green") == 0) + *opt_color = GREEN; + else if (strcmp(argv[0], "yellow") == 0) + *opt_color = YELLOW; + else if (strcmp(argv[0], "blue") == 0) + *opt_color = BLUE; + else if (strcmp(argv[0], "magenta") == 0) + *opt_color = MAGENTA; + else if (strcmp(argv[0], "cyan") == 0) + *opt_color = CYAN; + else if (strcmp(argv[0], "white") == 0) + *opt_color = WHITE; + else if (strcmp(argv[0], "default") == 0) + *opt_color = DEFAULT; + else if (isdigit(argv[0][0])) + *opt_color = atoi(argv[0]); + else + *bad_arg = TRUE; - if(*opt_color < 0 || *opt_color > 7) - *bad_arg = TRUE; - } + if(*opt_color < 0 || *opt_color > 7) + *bad_arg = TRUE; + } } -void par_color2(argc, argv, option, opt_color, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Color flag to set. */ -int *opt_color; /* Color to set. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +par_color2(int argc, char **argv, int *option, int *opt_color, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Color flag to set. */ + /* opt_color: Color to set. */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a -ulcolor or -hbcolor specification. */ - if (!argc || argc > 2 || *option) *bad_arg = TRUE; - *option = TRUE; - *opt_color = 0; - if (argc == 2) { - if (strcmp(argv[0], "bright") == 0) - *opt_color = 8; - else { + if (!argc || argc > 2 || *option) *bad_arg = TRUE; - return; + *option = TRUE; + *opt_color = 0; + if (argc == 2) { + if (strcmp(argv[0], "bright") == 0) + *opt_color = 8; + else { + *bad_arg = TRUE; + return; + } } - } - if (argc) { - if (strcmp(argv[argc-1], "black") == 0) { - if(*opt_color) + if (argc) { + if (strcmp(argv[argc-1], "black") == 0) { + if(*opt_color) + *bad_arg = TRUE; + else + *opt_color = BLACK; + } else if (strcmp(argv[argc-1], "grey") == 0) { + if(*opt_color) + *bad_arg = TRUE; + else + *opt_color = GREY; + } else if (strcmp(argv[argc-1], "red") == 0) + *opt_color |= RED; + else if (strcmp(argv[argc-1], "green") == 0) + *opt_color |= GREEN; + else if (strcmp(argv[argc-1], "yellow") == 0) + *opt_color |= YELLOW; + else if (strcmp(argv[argc-1], "blue") == 0) + *opt_color |= BLUE; + else if (strcmp(argv[argc-1], "magenta") == 0) + *opt_color |= MAGENTA; + else if (strcmp(argv[argc-1], "cyan") == 0) + *opt_color |= CYAN; + else if (strcmp(argv[argc-1], "white") == 0) + *opt_color |= WHITE; + else if (isdigit(argv[argc-1][0])) + *opt_color = atoi(argv[argc-1]); + else *bad_arg = TRUE; - else - *opt_color = BLACK; - } else if (strcmp(argv[argc-1], "grey") == 0) { - if(*opt_color) + if(*opt_color < 0 || *opt_color > 15) *bad_arg = TRUE; - else - *opt_color = GREY; - } else if (strcmp(argv[argc-1], "red") == 0) - *opt_color |= RED; - else if (strcmp(argv[argc-1], "green") == 0) - *opt_color |= GREEN; - else if (strcmp(argv[argc-1], "yellow") == 0) - *opt_color |= YELLOW; - else if (strcmp(argv[argc-1], "blue") == 0) - *opt_color |= BLUE; - else if (strcmp(argv[argc-1], "magenta") == 0) - *opt_color |= MAGENTA; - else if (strcmp(argv[argc-1], "cyan") == 0) - *opt_color |= CYAN; - else if (strcmp(argv[argc-1], "white") == 0) - *opt_color |= WHITE; - else if (isdigit(argv[argc-1][0])) - *opt_color = atoi(argv[argc-1]); - else - *bad_arg = TRUE; - if(*opt_color < 0 || *opt_color > 15) - *bad_arg = TRUE; - } + } } -void parse_clear(argc, argv, option, opt_all, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Clear flag to set. */ -int *opt_all; /* Clear all switch to set or reset. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_clear(int argc, char **argv, int *option, int *opt_all, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Clear flag to set. */ + /* opt_all: Clear all switch to set or reset. */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a -clear specification. */ - if (argc > 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - if (strcmp(argv[0], "all") == 0) - *opt_all = TRUE; - else if (strcmp(argv[0], "rest") == 0) - *opt_all = FALSE; - else + if (argc > 1 || *option) *bad_arg = TRUE; - } else { - *opt_all = TRUE; - } + *option = TRUE; + if (argc == 1) { + if (strcmp(argv[0], "all") == 0) + *opt_all = TRUE; + else if (strcmp(argv[0], "rest") == 0) + *opt_all = FALSE; + else + *bad_arg = TRUE; + } else { + *opt_all = TRUE; + } } -void parse_blank(argc, argv, option, opt_all, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Clear flag to set. */ -int *opt_all; /* Clear all switch to set or reset. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_blank(int argc, char **argv, int *option, int *opt_all, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Clear flag to set. */ + /* opt_all: Clear all switch to set or reset. */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a -blank specification. */ - if (argc > 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - *opt_all = atoi(argv[0]); - if ((*opt_all > 60) || (*opt_all < 0)) + if (argc > 1 || *option) *bad_arg = TRUE; - } else { - *opt_all = 0; - } + *option = TRUE; + if (argc == 1) { + *opt_all = atoi(argv[0]); + if ((*opt_all > 60) || (*opt_all < 0)) + *bad_arg = TRUE; + } else { + *opt_all = 0; + } } -void parse_powersave(argc, argv, option, opt_mode, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* powersave flag to set. */ -int *opt_mode; /* Powersaving mode, defined in vesa_blank.c */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_powersave(int argc, char **argv, int *option, int *opt_mode, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: powersave flag to set. */ + /* opt_mode: Powersaving mode, defined in vesa_blank.c */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a -powersave mode specification. */ - if (argc > 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - if (strcmp(argv[0], "on") == 0) - *opt_mode = 1; - else if (strcmp(argv[0], "vsync") == 0) - *opt_mode = 1; - else if (strcmp(argv[0], "hsync") == 0) - *opt_mode = 2; - else if (strcmp(argv[0], "powerdown") == 0) - *opt_mode = 3; - else if (strcmp(argv[0], "off") == 0) - *opt_mode = 0; - else + if (argc > 1 || *option) *bad_arg = TRUE; - } else { - *opt_mode = 0; - } + *option = TRUE; + if (argc == 1) { + if (strcmp(argv[0], "on") == 0) + *opt_mode = 1; + else if (strcmp(argv[0], "vsync") == 0) + *opt_mode = 1; + else if (strcmp(argv[0], "hsync") == 0) + *opt_mode = 2; + else if (strcmp(argv[0], "powerdown") == 0) + *opt_mode = 3; + else if (strcmp(argv[0], "off") == 0) + *opt_mode = 0; + else + *bad_arg = TRUE; + } else { + *opt_mode = 0; + } } #if 0 -void parse_standout(argc, argv, option, opt_all, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Clear flag to set. */ -int *opt_all; /* Clear all switch to set or reset. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_standout(int argc, char *argv, int *option, int *opt_all, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Clear flag to set. */ + /* opt_all: Clear all switch to set or reset. */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a -standout specification. */ - if (argc > 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - *opt_all = atoi(argv[0]); - } else { - *opt_all = -1; - } + if (argc > 1 || *option) + *bad_arg = TRUE; + *option = TRUE; + if (argc == 1) + *opt_all = atoi(argv[0]); + else + *opt_all = -1; } #endif -void parse_msglevel(argc, argv, option, opt_all, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Clear flag to set. */ -int *opt_all; /* Clear all switch to set or reset. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ - - if (argc > 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - *opt_all = atoi(argv[0]); - if (*opt_all < 0 || *opt_all > 8) +static void +parse_msglevel(int argc, char **argv, int *option, int *opt_all, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Clear flag to set. */ + /* opt_all: Clear all switch to set or reset. */ + /* bad_arg: Set to true if an error is detected. */ + + if (argc > 1 || *option) *bad_arg = TRUE; - } else { - *opt_all = -1; - } + *option = TRUE; + if (argc == 1) { + *opt_all = atoi(argv[0]); + if (*opt_all < 0 || *opt_all > 8) + *bad_arg = TRUE; + } else { + *opt_all = -1; + } } -void parse_snap(argc, argv, option, opt_all, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Clear flag to set. */ -int *opt_all; /* Clear all switch to set or reset. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_snap(int argc, char **argv, int *option, int *opt_all, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Clear flag to set. */ + /* opt_all: Clear all switch to set or reset. */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a -dump or -append specification. */ - if (argc > 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - *opt_all = atoi(argv[0]); - if ((*opt_all <= 0)) + if (argc > 1 || *option) *bad_arg = TRUE; - } else { - *opt_all = 0; - } + *option = TRUE; + if (argc == 1) { + *opt_all = atoi(argv[0]); + if ((*opt_all <= 0)) + *bad_arg = TRUE; + } else { + *opt_all = 0; + } } -void parse_snapfile(argc, argv, option, opt_all, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Clear flag to set. */ -int *opt_all; /* Clear all switch to set or reset. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_snapfile(int argc, char **argv, int *option, int *opt_all, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Clear flag to set. */ + /* opt_all: Clear all switch to set or reset. */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a -file specification. */ - if (argc != 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - strcpy((char *)opt_all, argv[0]); - } + if (argc != 1 || *option) + *bad_arg = TRUE; + *option = TRUE; + if (argc == 1) + strcpy((char *)opt_all, argv[0]); } -void parse_tabs(argc, argv, option, tab_array, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Clear flag to set. */ -int *tab_array; /* Array of tabs */ -int *bad_arg; /* Set to true if an error is detected. */ -{ - if (*option || argc > 160) *bad_arg = TRUE; - *option = TRUE; - tab_array[argc] = -1; - while(argc--) { - tab_array[argc] = atoi(argv[argc]); - if(tab_array[argc] < 1 || tab_array[argc] > 160) { - *bad_arg = TRUE; - return; - } - } +static void +parse_tabs(int argc, char **argv, int *option, int *tab_array, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Clear flag to set. */ + /* tab_array: Array of tabs */ + /* bad_arg: Set to true if an error is detected. */ + + if (*option || argc > 160) + *bad_arg = TRUE; + *option = TRUE; + tab_array[argc] = -1; + while(argc--) { + tab_array[argc] = atoi(argv[argc]); + if(tab_array[argc] < 1 || tab_array[argc] > 160) { + *bad_arg = TRUE; + return; + } + } } -void parse_clrtabs(argc, argv, option, tab_array, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Clear flag to set. */ -int *tab_array; /* Array of tabs */ -int *bad_arg; /* Set to true if an error is detected. */ -{ - if (*option || argc > 160) *bad_arg = TRUE; - *option = TRUE; - if(argc == 0) { - tab_array[0] = -1; - return; - } - tab_array[argc] = -1; - while(argc--) { - tab_array[argc] = atoi(argv[argc]); - if(tab_array[argc] < 1 || tab_array[argc] > 160) { - *bad_arg = TRUE; - return; - } - } +static void +parse_clrtabs(int argc, char **argv, int *option, int *tab_array, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Clear flag to set. */ + /* tab_array: Array of tabs */ + /* bad_arg: Set to true if an error is detected. */ + + if (*option || argc > 160) + *bad_arg = TRUE; + *option = TRUE; + if(argc == 0) { + tab_array[0] = -1; + return; + } + tab_array[argc] = -1; + while(argc--) { + tab_array[argc] = atoi(argv[argc]); + if(tab_array[argc] < 1 || tab_array[argc] > 160) { + *bad_arg = TRUE; + return; + } + } } -void parse_regtabs(argc, argv, option, opt_len, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Clear flag to set. */ -int *opt_len; /* Regular tab length. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ - if (*option || argc > 1) *bad_arg = TRUE; - *option = TRUE; - if(argc == 0) { - *opt_len = 8; - return; - } - *opt_len = atoi(argv[0]); - if(*opt_len < 1 || *opt_len > 160) { - *bad_arg = TRUE; - return; - } +static void +parse_regtabs(int argc, char **argv, int *option, int *opt_len, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Clear flag to set. */ + /* opt_len: Regular tab length. */ + /* bad_arg: Set to true if an error is detected. */ + + if (*option || argc > 1) + *bad_arg = TRUE; + *option = TRUE; + if(argc == 0) { + *opt_len = 8; + return; + } + *opt_len = atoi(argv[0]); + if(*opt_len < 1 || *opt_len > 160) { + *bad_arg = TRUE; + return; + } } -void parse_blength(argc, argv, option, opt_all, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Clear flag to set. */ -int *opt_all; -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_blength(int argc, char **argv, int *option, int *opt_all, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Clear flag to set. */ + /* opt_all */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse -blength specification. */ - if (argc > 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - *opt_all = atoi(argv[0]); - if (*opt_all > 2000) + if (argc > 1 || *option) *bad_arg = TRUE; - } else { - *opt_all = 0; - } + *option = TRUE; + if (argc == 1) { + *opt_all = atoi(argv[0]); + if (*opt_all > 2000) + *bad_arg = TRUE; + } else { + *opt_all = 0; + } } -void parse_bfreq(argc, argv, option, opt_all, bad_arg) -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *option; /* Clear flag to set. */ -int *opt_all; -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_bfreq(int argc, char **argv, int *option, int *opt_all, int *bad_arg) { + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* option: Clear flag to set. */ + /* opt_all */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse -bfreq specification. */ - if (argc > 1 || *option) *bad_arg = TRUE; - *option = TRUE; - if (argc == 1) { - *opt_all = atoi(argv[0]); - } else { - *opt_all = 0; - } + if (argc > 1 || *option) + *bad_arg = TRUE; + *option = TRUE; + if (argc == 1) { + *opt_all = atoi(argv[0]); + } else { + *opt_all = 0; + } } -void show_tabs() -{ - int i, co = tigetnum("cols"); - - if(co > 0) { - printf("\r "); - for(i = 10; i < co-2; i+=10) - printf("%-10d", i); - putchar('\n'); - for(i = 1; i <= co; i++) - putchar(i%10+'0'); - putchar('\n'); - for(i = 1; i < co; i++) - printf("\tT\b"); - putchar('\n'); - } +static void +show_tabs(void) { + int i, co = tigetnum("cols"); + + if(co > 0) { + printf("\r "); + for(i = 10; i < co-2; i+=10) + printf("%-10d", i); + putchar('\n'); + for(i = 1; i <= co; i++) + putchar(i%10+'0'); + putchar('\n'); + for(i = 1; i < co; i++) + printf("\tT\b"); + putchar('\n'); + } } #define STRCMP(str1,str2) strncmp(str1,str2,strlen(str1)) -void parse_option(option, argc, argv, bad_arg) -char *option; /* Option with leading '-' removed. */ -int argc; /* Number of arguments for this option. */ -char *argv[]; /* Arguments for this option. */ -int *bad_arg; /* Set to true if an error is detected. */ -{ +static void +parse_option(char *option, int argc, char **argv, int *bad_arg) { + /* option: Option with leading '-' removed. */ + /* argc: Number of arguments for this option. */ + /* argv: Arguments for this option. */ + /* bad_arg: Set to true if an error is detected. */ + /* Parse a single specification. */ - if (STRCMP(option, "term") == 0) - parse_term(argc, argv, &opt_term, &opt_te_terminal_name, bad_arg); - else if (STRCMP(option, "reset") == 0) - parse_none(argc, argv, &opt_reset, bad_arg); - else if (STRCMP(option, "initialize") == 0) - parse_none(argc, argv, &opt_initialize, bad_arg); - else if (STRCMP(option, "cursor") == 0) - parse_switch(argc, argv, &opt_cursor, &opt_cu_on, bad_arg); - else if (STRCMP(option, "repeat") == 0) - parse_switch(argc, argv, &opt_repeat, &opt_rep_on, bad_arg); - else if (STRCMP(option, "appcursorkeys") == 0) - parse_switch(argc, argv, &opt_appcursorkeys, &opt_appck_on, bad_arg); - else if (STRCMP(option, "linewrap") == 0) - parse_switch(argc, argv, &opt_linewrap, &opt_li_on, bad_arg); + if (STRCMP(option, "term") == 0) + parse_term(argc, argv, &opt_term, &opt_te_terminal_name, bad_arg); + else if (STRCMP(option, "reset") == 0) + parse_none(argc, argv, &opt_reset, bad_arg); + else if (STRCMP(option, "initialize") == 0) + parse_none(argc, argv, &opt_initialize, bad_arg); + else if (STRCMP(option, "cursor") == 0) + parse_switch(argc, argv, &opt_cursor, &opt_cu_on, bad_arg); + else if (STRCMP(option, "repeat") == 0) + parse_switch(argc, argv, &opt_repeat, &opt_rep_on, bad_arg); + else if (STRCMP(option, "appcursorkeys") == 0) + parse_switch(argc, argv, &opt_appcursorkeys, &opt_appck_on, bad_arg); + else if (STRCMP(option, "linewrap") == 0) + parse_switch(argc, argv, &opt_linewrap, &opt_li_on, bad_arg); #if 0 - else if (STRCMP(option, "snow") == 0) - parse_switch(argc, argv, &opt_snow, &opt_sn_on, bad_arg); - else if (STRCMP(option, "softscroll") == 0) - parse_switch(argc, argv, &opt_softscroll, &opt_so_on, bad_arg); + else if (STRCMP(option, "snow") == 0) + parse_switch(argc, argv, &opt_snow, &opt_sn_on, bad_arg); + else if (STRCMP(option, "softscroll") == 0) + parse_switch(argc, argv, &opt_softscroll, &opt_so_on, bad_arg); #endif - else if (STRCMP(option, "default") == 0) - parse_none(argc, argv, &opt_default, bad_arg); - else if (STRCMP(option, "foreground") == 0) - par_color(argc, argv, &opt_foreground, &opt_fo_color, bad_arg); - else if (STRCMP(option, "background") == 0) - par_color(argc, argv, &opt_background, &opt_ba_color, bad_arg); - else if (STRCMP(option, "ulcolor") == 0) - par_color2(argc, argv, &opt_ulcolor, &opt_ul_color, bad_arg); - else if (STRCMP(option, "hbcolor") == 0) - par_color2(argc, argv, &opt_hbcolor, &opt_hb_color, bad_arg); - else if (STRCMP(option, "inversescreen") == 0) - parse_switch(argc, argv, &opt_inversescreen, &opt_invsc_on, bad_arg); - else if (STRCMP(option, "bold") == 0) - parse_switch(argc, argv, &opt_bold, &opt_bo_on, bad_arg); - else if (STRCMP(option, "half-bright") == 0) - parse_switch(argc, argv, &opt_halfbright, &opt_hb_on, bad_arg); - else if (STRCMP(option, "blink") == 0) - parse_switch(argc, argv, &opt_blink, &opt_bl_on, bad_arg); - else if (STRCMP(option, "reverse") == 0) - parse_switch(argc, argv, &opt_reverse, &opt_re_on, bad_arg); - else if (STRCMP(option, "underline") == 0) - parse_switch(argc, argv, &opt_underline, &opt_un_on, bad_arg); - else if (STRCMP(option, "store") == 0) - parse_none(argc, argv, &opt_store, bad_arg); - else if (STRCMP(option, "clear") == 0) - parse_clear(argc, argv, &opt_clear, &opt_cl_all, bad_arg); - else if (STRCMP(option, "tabs") == 0) - parse_tabs(argc, argv, &opt_tabs, opt_tb_array, bad_arg); - else if (STRCMP(option, "clrtabs") == 0) - parse_clrtabs(argc, argv, &opt_clrtabs, opt_tb_array, bad_arg); - else if (STRCMP(option, "regtabs") == 0) - parse_regtabs(argc, argv, &opt_regtabs, &opt_rt_len, bad_arg); - else if (STRCMP(option, "blank") == 0) - parse_blank(argc, argv, &opt_blank, &opt_bl_min, bad_arg); - else if (STRCMP(option, "dump") == 0) - parse_snap(argc, argv, &opt_snap, &opt_sn_num, bad_arg); - else if (STRCMP(option, "append") == 0) - parse_snap(argc, argv, &opt_append, &opt_sn_num, bad_arg); - else if (STRCMP(option, "file") == 0) - parse_snapfile(argc, argv, &opt_snapfile, (int *)opt_sn_name, bad_arg); - else if (STRCMP(option, "msg") == 0) - parse_switch(argc, argv, &opt_msg, &opt_msg_on, bad_arg); - else if (STRCMP(option, "msglevel") == 0) - parse_msglevel(argc, argv, &opt_msglevel, &opt_msglevel_num, bad_arg); - else if (STRCMP(option, "powersave") == 0) - parse_powersave(argc, argv, &opt_powersave, &opt_ps_mode, bad_arg); - else if (STRCMP(option, "powerdown") == 0) - parse_blank(argc, argv, &opt_powerdown, &opt_pd_min, bad_arg); - else if (STRCMP(option, "blength") == 0) - parse_blength(argc, argv, &opt_blength, &opt_blength_l, bad_arg); - else if (STRCMP(option, "bfreq") == 0) - parse_bfreq(argc, argv, &opt_bfreq, &opt_bfreq_f, bad_arg); + else if (STRCMP(option, "default") == 0) + parse_none(argc, argv, &opt_default, bad_arg); + else if (STRCMP(option, "foreground") == 0) + par_color(argc, argv, &opt_foreground, &opt_fo_color, bad_arg); + else if (STRCMP(option, "background") == 0) + par_color(argc, argv, &opt_background, &opt_ba_color, bad_arg); + else if (STRCMP(option, "ulcolor") == 0) + par_color2(argc, argv, &opt_ulcolor, &opt_ul_color, bad_arg); + else if (STRCMP(option, "hbcolor") == 0) + par_color2(argc, argv, &opt_hbcolor, &opt_hb_color, bad_arg); + else if (STRCMP(option, "inversescreen") == 0) + parse_switch(argc, argv, &opt_inversescreen, &opt_invsc_on, bad_arg); + else if (STRCMP(option, "bold") == 0) + parse_switch(argc, argv, &opt_bold, &opt_bo_on, bad_arg); + else if (STRCMP(option, "half-bright") == 0) + parse_switch(argc, argv, &opt_halfbright, &opt_hb_on, bad_arg); + else if (STRCMP(option, "blink") == 0) + parse_switch(argc, argv, &opt_blink, &opt_bl_on, bad_arg); + else if (STRCMP(option, "reverse") == 0) + parse_switch(argc, argv, &opt_reverse, &opt_re_on, bad_arg); + else if (STRCMP(option, "underline") == 0) + parse_switch(argc, argv, &opt_underline, &opt_un_on, bad_arg); + else if (STRCMP(option, "store") == 0) + parse_none(argc, argv, &opt_store, bad_arg); + else if (STRCMP(option, "clear") == 0) + parse_clear(argc, argv, &opt_clear, &opt_cl_all, bad_arg); + else if (STRCMP(option, "tabs") == 0) + parse_tabs(argc, argv, &opt_tabs, opt_tb_array, bad_arg); + else if (STRCMP(option, "clrtabs") == 0) + parse_clrtabs(argc, argv, &opt_clrtabs, opt_tb_array, bad_arg); + else if (STRCMP(option, "regtabs") == 0) + parse_regtabs(argc, argv, &opt_regtabs, &opt_rt_len, bad_arg); + else if (STRCMP(option, "blank") == 0) + parse_blank(argc, argv, &opt_blank, &opt_bl_min, bad_arg); + else if (STRCMP(option, "dump") == 0) + parse_snap(argc, argv, &opt_snap, &opt_sn_num, bad_arg); + else if (STRCMP(option, "append") == 0) + parse_snap(argc, argv, &opt_append, &opt_sn_num, bad_arg); + else if (STRCMP(option, "file") == 0) + parse_snapfile(argc, argv, &opt_snapfile, (int *)opt_sn_name, bad_arg); + else if (STRCMP(option, "msg") == 0) + parse_switch(argc, argv, &opt_msg, &opt_msg_on, bad_arg); + else if (STRCMP(option, "msglevel") == 0) + parse_msglevel(argc, argv, &opt_msglevel, &opt_msglevel_num, bad_arg); + else if (STRCMP(option, "powersave") == 0) + parse_powersave(argc, argv, &opt_powersave, &opt_ps_mode, bad_arg); + else if (STRCMP(option, "powerdown") == 0) + parse_blank(argc, argv, &opt_powerdown, &opt_pd_min, bad_arg); + else if (STRCMP(option, "blength") == 0) + parse_blength(argc, argv, &opt_blength, &opt_blength_l, bad_arg); + else if (STRCMP(option, "bfreq") == 0) + parse_bfreq(argc, argv, &opt_bfreq, &opt_bfreq_f, bad_arg); #if 0 - else if (STRCMP(option, "standout") == 0) - parse_standout(argc, argv, &opt_standout, &opt_st_attr, bad_arg); + else if (STRCMP(option, "standout") == 0) + parse_standout(argc, argv, &opt_standout, &opt_st_attr, bad_arg); #endif - else - *bad_arg = TRUE; + else + *bad_arg = TRUE; } /* End of command line parsing routines. */ -void usage(prog_name) -char *prog_name; /* Name of this program. */ -{ +static void +usage(char *prog_name) { /* Print error message about arguments, and the command's syntax. */ - fprintf(stderr, _("%s: Argument error, usage\n"), prog_name); - fprintf(stderr, "\n"); - fprintf(stderr, "%s\n", prog_name); - fprintf(stderr, _(" [ -term terminal_name ]\n")); - fprintf(stderr, _(" [ -reset ]\n")); - fprintf(stderr, _(" [ -initialize ]\n")); - fprintf(stderr, _(" [ -cursor [on|off] ]\n")); + fprintf(stderr, _("%s: Argument error, usage\n"), prog_name); + fprintf(stderr, "\n"); + fprintf(stderr, "%s\n", prog_name); + fprintf(stderr, _(" [ -term terminal_name ]\n")); + fprintf(stderr, _(" [ -reset ]\n")); + fprintf(stderr, _(" [ -initialize ]\n")); + fprintf(stderr, _(" [ -cursor [on|off] ]\n")); #if 0 - fprintf(stderr, _(" [ -snow [on|off] ]\n")); - fprintf(stderr, _(" [ -softscroll [on|off] ]\n")); + fprintf(stderr, _(" [ -snow [on|off] ]\n")); + fprintf(stderr, _(" [ -softscroll [on|off] ]\n")); #endif - fprintf(stderr, _(" [ -repeat [on|off] ]\n")); - fprintf(stderr, _(" [ -appcursorkeys [on|off] ]\n")); - fprintf(stderr, _(" [ -linewrap [on|off] ]\n")); - fprintf(stderr, _(" [ -default ]\n")); - fprintf(stderr, _(" [ -foreground black|blue|green|cyan")); - fprintf(stderr, _("|red|magenta|yellow|white|default ]\n")); - fprintf(stderr, _(" [ -background black|blue|green|cyan")); - fprintf(stderr, _("|red|magenta|yellow|white|default ]\n")); - fprintf(stderr, _(" [ -ulcolor black|grey|blue|green|cyan")); - fprintf(stderr, _("|red|magenta|yellow|white ]\n")); - fprintf(stderr, _(" [ -ulcolor bright blue|green|cyan")); - fprintf(stderr, _("|red|magenta|yellow|white ]\n")); - fprintf(stderr, _(" [ -hbcolor black|grey|blue|green|cyan")); - fprintf(stderr, _("|red|magenta|yellow|white ]\n")); - fprintf(stderr, _(" [ -hbcolor bright blue|green|cyan")); - fprintf(stderr, _("|red|magenta|yellow|white ]\n")); + fprintf(stderr, _(" [ -repeat [on|off] ]\n")); + fprintf(stderr, _(" [ -appcursorkeys [on|off] ]\n")); + fprintf(stderr, _(" [ -linewrap [on|off] ]\n")); + fprintf(stderr, _(" [ -default ]\n")); + fprintf(stderr, _(" [ -foreground black|blue|green|cyan")); + fprintf(stderr, _("|red|magenta|yellow|white|default ]\n")); + fprintf(stderr, _(" [ -background black|blue|green|cyan")); + fprintf(stderr, _("|red|magenta|yellow|white|default ]\n")); + fprintf(stderr, _(" [ -ulcolor black|grey|blue|green|cyan")); + fprintf(stderr, _("|red|magenta|yellow|white ]\n")); + fprintf(stderr, _(" [ -ulcolor bright blue|green|cyan")); + fprintf(stderr, _("|red|magenta|yellow|white ]\n")); + fprintf(stderr, _(" [ -hbcolor black|grey|blue|green|cyan")); + fprintf(stderr, _("|red|magenta|yellow|white ]\n")); + fprintf(stderr, _(" [ -hbcolor bright blue|green|cyan")); + fprintf(stderr, _("|red|magenta|yellow|white ]\n")); #if 0 - fprintf(stderr, _(" [ -standout [ attr ] ]\n")); + fprintf(stderr, _(" [ -standout [ attr ] ]\n")); #endif - fprintf(stderr, _(" [ -inversescreen [on|off] ]\n")); - fprintf(stderr, _(" [ -bold [on|off] ]\n")); - fprintf(stderr, _(" [ -half-bright [on|off] ]\n")); - fprintf(stderr, _(" [ -blink [on|off] ]\n")); - fprintf(stderr, _(" [ -reverse [on|off] ]\n")); - fprintf(stderr, _(" [ -underline [on|off] ]\n")); - fprintf(stderr, _(" [ -store ]\n")); - fprintf(stderr, _(" [ -clear [all|rest] ]\n")); - fprintf(stderr, _(" [ -tabs [ tab1 tab2 tab3 ... ] ] (tabn = 1-160)\n")); - fprintf(stderr, _(" [ -clrtabs [ tab1 tab2 tab3 ... ] ] (tabn = 1-160)\n")); - fprintf(stderr, _(" [ -regtabs [1-160] ]\n")); - fprintf(stderr, _(" [ -blank [0-60] ]\n")); - fprintf(stderr, _(" [ -dump [1-NR_CONSOLES] ]\n")); - fprintf(stderr, _(" [ -append [1-NR_CONSOLES] ]\n")); - fprintf(stderr, _(" [ -file dumpfilename ]\n")); - fprintf(stderr, _(" [ -msg [on|off] ]\n")); - fprintf(stderr, _(" [ -msglevel [0-8] ]\n")); - fprintf(stderr, _(" [ -powersave [on|vsync|hsync|powerdown|off] ]\n")); - fprintf(stderr, _(" [ -powerdown [0-60] ]\n")); - fprintf(stderr, _(" [ -blength [0-2000] ]\n")); - fprintf(stderr, _(" [ -bfreq freqnumber ]\n")); + fprintf(stderr, _(" [ -inversescreen [on|off] ]\n")); + fprintf(stderr, _(" [ -bold [on|off] ]\n")); + fprintf(stderr, _(" [ -half-bright [on|off] ]\n")); + fprintf(stderr, _(" [ -blink [on|off] ]\n")); + fprintf(stderr, _(" [ -reverse [on|off] ]\n")); + fprintf(stderr, _(" [ -underline [on|off] ]\n")); + fprintf(stderr, _(" [ -store ]\n")); + fprintf(stderr, _(" [ -clear [all|rest] ]\n")); + fprintf(stderr, _(" [ -tabs [ tab1 tab2 tab3 ... ] ] (tabn = 1-160)\n")); + fprintf(stderr, _(" [ -clrtabs [ tab1 tab2 tab3 ... ] ] (tabn = 1-160)\n")); + fprintf(stderr, _(" [ -regtabs [1-160] ]\n")); + fprintf(stderr, _(" [ -blank [0-60] ]\n")); + fprintf(stderr, _(" [ -dump [1-NR_CONSOLES] ]\n")); + fprintf(stderr, _(" [ -append [1-NR_CONSOLES] ]\n")); + fprintf(stderr, _(" [ -file dumpfilename ]\n")); + fprintf(stderr, _(" [ -msg [on|off] ]\n")); + fprintf(stderr, _(" [ -msglevel [0-8] ]\n")); + fprintf(stderr, _(" [ -powersave [on|vsync|hsync|powerdown|off] ]\n")); + fprintf(stderr, _(" [ -powerdown [0-60] ]\n")); + fprintf(stderr, _(" [ -blength [0-2000] ]\n")); + fprintf(stderr, _(" [ -bfreq freqnumber ]\n")); } -char *ti_entry(name) -const char *name; /* Terminfo capability string to lookup. */ -{ +static char *ti_entry(const char *name) { + /* name: Terminfo capability string to lookup. */ + /* Return the specified terminfo string, or an empty string if no such terminfo * capability exists. */ - char *buf_ptr; + char *buf_ptr; - if ((buf_ptr = tigetstr(name)) == (char *)-1) buf_ptr = NULL; - return buf_ptr; + if ((buf_ptr = tigetstr(name)) == (char *)-1) buf_ptr = NULL; + return buf_ptr; } -void perform_sequence(vcterm) -int vcterm; /* Set if terminal is a virtual console. */ -{ - int result; +static void +perform_sequence(int vcterm) { + /* vcterm: Set if terminal is a virtual console. */ + + int result; /* Perform the selected options. */ - /* -reset. */ - if (opt_reset) { - putp(ti_entry("rs1")); - } + /* -reset. */ + if (opt_reset) { + putp(ti_entry("rs1")); + } - /* -initialize. */ - if (opt_initialize) { - putp(ti_entry("is2")); - } + /* -initialize. */ + if (opt_initialize) { + putp(ti_entry("is2")); + } - /* -cursor [on|off]. */ - if (opt_cursor) { - if (opt_cu_on) - putp(ti_entry("cnorm")); - else - putp(ti_entry("civis")); - } + /* -cursor [on|off]. */ + if (opt_cursor) { + if (opt_cu_on) + putp(ti_entry("cnorm")); + else + putp(ti_entry("civis")); + } - /* -linewrap [on|off]. Vc only (vt102) */ - if (opt_linewrap && vcterm) { - if (opt_li_on) - printf("\033[?7h"); - else - printf("\033[?7l"); - } + /* -linewrap [on|off]. Vc only (vt102) */ + if (opt_linewrap && vcterm) { + if (opt_li_on) + printf("\033[?7h"); + else + printf("\033[?7l"); + } - /* -repeat [on|off]. Vc only (vt102) */ - if (opt_repeat && vcterm) { - if (opt_rep_on) - printf("\033[?8h"); - else - printf("\033[?8l"); - } + /* -repeat [on|off]. Vc only (vt102) */ + if (opt_repeat && vcterm) { + if (opt_rep_on) + printf("\033[?8h"); + else + printf("\033[?8l"); + } - /* -appcursorkeys [on|off]. Vc only (vt102) */ - if (opt_appcursorkeys && vcterm) { - if (opt_appck_on) - printf("\033[?1h"); - else - printf("\033[?1l"); - } + /* -appcursorkeys [on|off]. Vc only (vt102) */ + if (opt_appcursorkeys && vcterm) { + if (opt_appck_on) + printf("\033[?1h"); + else + printf("\033[?1l"); + } #if 0 - /* -snow [on|off]. Vc only. */ - if (opt_snow && vcterm) { - if (opt_sn_on) - printf("%s%s%s", DCS, _("snow.on"), ST); - else - printf("%s%s%s", DCS, _("snow.off"), ST); - } - - /* -softscroll [on|off]. Vc only. */ - if (opt_softscroll && vcterm) { - if (opt_so_on) - printf("%s%s%s", DCS, _("softscroll.on"), ST); - else - printf("%s%s%s", DCS, _("softscroll.off"), ST); - } -#endif + /* -snow [on|off]. Vc only. */ + if (opt_snow && vcterm) { + if (opt_sn_on) + printf("%s%s%s", DCS, _("snow.on"), ST); + else + printf("%s%s%s", DCS, _("snow.off"), ST); + } - /* -default. Vc sets default rendition, otherwise clears all - * attributes. - */ - if (opt_default) { - if (vcterm) - printf("\033[0m"); - else - putp(ti_entry("sgr0")); - } - - /* -foreground black|red|green|yellow|blue|magenta|cyan|white|default. - * Vc only (ANSI). - */ - if (opt_foreground && vcterm) { - printf("%s%s%c%s", ESC, "[3", '0' + opt_fo_color, "m"); - } - - /* -background black|red|green|yellow|blue|magenta|cyan|white|default. - * Vc only (ANSI). - */ - if (opt_background && vcterm) { - printf("%s%s%c%s", ESC, "[4", '0' + opt_ba_color, "m"); - } - - /* -ulcolor black|red|green|yellow|blue|magenta|cyan|white|default. - * Vc only. - */ - if (opt_ulcolor && vcterm) { - printf("\033[1;%d]", opt_ul_color); - } - - /* -hbcolor black|red|green|yellow|blue|magenta|cyan|white|default. - * Vc only. - */ - if (opt_hbcolor && vcterm) { - printf("\033[2;%d]", opt_hb_color); - } - - /* -inversescreen [on|off]. Vc only (vt102). - */ - if (opt_inversescreen) { - if (vcterm) { - if (opt_invsc_on) - printf("\033[?5h"); + /* -softscroll [on|off]. Vc only. */ + if (opt_softscroll && vcterm) { + if (opt_so_on) + printf("%s%s%s", DCS, _("softscroll.on"), ST); else - printf("\033[?5l"); + printf("%s%s%s", DCS, _("softscroll.off"), ST); } - } - - /* -bold [on|off]. Vc behaves as expected, otherwise off turns off - * all attributes. - */ - if (opt_bold) { - if (opt_bo_on) - putp(ti_entry("bold")); - else { +#endif + + /* -default. Vc sets default rendition, otherwise clears all + * attributes. + */ + if (opt_default) { if (vcterm) - printf("%s%s", ESC, "[22m"); + printf("\033[0m"); else putp(ti_entry("sgr0")); } - } - - /* -half-bright [on|off]. Vc behaves as expected, otherwise off turns off - * all attributes. - */ - if (opt_halfbright) { - if (opt_hb_on) - putp(ti_entry("dim")); - else { - if (vcterm) - printf("%s%s", ESC, "[22m"); + + /* -foreground black|red|green|yellow|blue|magenta|cyan|white|default. + * Vc only (ANSI). + */ + if (opt_foreground && vcterm) { + printf("%s%s%c%s", ESC, "[3", '0' + opt_fo_color, "m"); + } + + /* -background black|red|green|yellow|blue|magenta|cyan|white|default. + * Vc only (ANSI). + */ + if (opt_background && vcterm) { + printf("%s%s%c%s", ESC, "[4", '0' + opt_ba_color, "m"); + } + + /* -ulcolor black|red|green|yellow|blue|magenta|cyan|white|default. + * Vc only. + */ + if (opt_ulcolor && vcterm) { + printf("\033[1;%d]", opt_ul_color); + } + + /* -hbcolor black|red|green|yellow|blue|magenta|cyan|white|default. + * Vc only. + */ + if (opt_hbcolor && vcterm) { + printf("\033[2;%d]", opt_hb_color); + } + + /* -inversescreen [on|off]. Vc only (vt102). + */ + if (opt_inversescreen) { + if (vcterm) { + if (opt_invsc_on) + printf("\033[?5h"); + else + printf("\033[?5l"); + } + } + + /* -bold [on|off]. Vc behaves as expected, otherwise off turns off + * all attributes. + */ + if (opt_bold) { + if (opt_bo_on) + putp(ti_entry("bold")); + else { + if (vcterm) + printf("%s%s", ESC, "[22m"); + else + putp(ti_entry("sgr0")); + } + } + + /* -half-bright [on|off]. Vc behaves as expected, otherwise off turns off + * all attributes. + */ + if (opt_halfbright) { + if (opt_hb_on) + putp(ti_entry("dim")); + else { + if (vcterm) + printf("%s%s", ESC, "[22m"); + else + putp(ti_entry("sgr0")); + } + } + + /* -blink [on|off]. Vc behaves as expected, otherwise off turns off + * all attributes. + */ + if (opt_blink) { + if (opt_bl_on) + putp(ti_entry("blink")); + else { + if (vcterm) + printf("%s%s", ESC, "[25m"); + else + putp(ti_entry("sgr0")); + } + } + + /* -reverse [on|off]. Vc behaves as expected, otherwise off turns + * off all attributes. + */ + if (opt_reverse) { + if (opt_re_on) + putp(ti_entry("rev")); + else { + if (vcterm) + printf("%s%s", ESC, "[27m"); + else + putp(ti_entry("sgr0")); + } + } + + /* -underline [on|off]. */ + if (opt_underline) { + if (opt_un_on) + putp(ti_entry("smul")); else - putp(ti_entry("sgr0")); + putp(ti_entry("rmul")); } - } - - /* -blink [on|off]. Vc behaves as expected, otherwise off turns off - * all attributes. - */ - if (opt_blink) { - if (opt_bl_on) - putp(ti_entry("blink")); - else { - if (vcterm) - printf("%s%s", ESC, "[25m"); + + /* -store. Vc only. */ + if (opt_store && vcterm) { + printf("\033[8]"); + } + + /* -clear [all|rest]. */ + if (opt_clear) { + if (opt_cl_all) + putp(ti_entry("clear")); else - putp(ti_entry("sgr0")); + putp(ti_entry("ed")); } - } - - /* -reverse [on|off]. Vc behaves as expected, otherwise off turns - * off all attributes. - */ - if (opt_reverse) { - if (opt_re_on) - putp(ti_entry("rev")); - else { - if (vcterm) - printf("%s%s", ESC, "[27m"); + + /* -tabs Vc only. */ + if (opt_tabs && vcterm) { + int i; + + if (opt_tb_array[0] == -1) + show_tabs(); + else { + for(i=0; opt_tb_array[i] > 0; i++) + printf("\033[%dG\033H", opt_tb_array[i]); + putchar('\r'); + } + } + + /* -clrtabs Vc only. */ + if (opt_clrtabs && vcterm) { + int i; + + if (opt_tb_array[0] == -1) + printf("\033[3g"); else - putp(ti_entry("sgr0")); + for(i=0; opt_tb_array[i] > 0; i++) + printf("\033[%dG\033[g", opt_tb_array[i]); + putchar('\r'); } - } - /* -underline [on|off]. */ - if (opt_underline) { - if (opt_un_on) - putp(ti_entry("smul")); - else - putp(ti_entry("rmul")); - } - - /* -store. Vc only. */ - if (opt_store && vcterm) { - printf("\033[8]"); - } - - /* -clear [all|rest]. */ - if (opt_clear) { - if (opt_cl_all) - putp(ti_entry("clear")); - else - putp(ti_entry("ed")); - } - - /* -tabs Vc only. */ - if (opt_tabs && vcterm) { - int i; - - if (opt_tb_array[0] == -1) - show_tabs(); - else { - for(i=0; opt_tb_array[i] > 0; i++) - printf("\033[%dG\033H", opt_tb_array[i]); - putchar('\r'); - } - } - - /* -clrtabs Vc only. */ - if (opt_clrtabs && vcterm) { - int i; - - if (opt_tb_array[0] == -1) - printf("\033[3g"); - else - for(i=0; opt_tb_array[i] > 0; i++) - printf("\033[%dG\033[g", opt_tb_array[i]); - putchar('\r'); - } - - /* -regtabs Vc only. */ - if (opt_regtabs && vcterm) { - int i; - - printf("\033[3g\r"); - for(i=opt_rt_len+1; i<=160; i+=opt_rt_len) - printf("\033[%dC\033H",opt_rt_len); - putchar('\r'); - } - - /* -blank [0-60]. */ - if (opt_blank && vcterm) - printf("\033[9;%d]", opt_bl_min); + /* -regtabs Vc only. */ + if (opt_regtabs && vcterm) { + int i; + + printf("\033[3g\r"); + for(i=opt_rt_len+1; i<=160; i+=opt_rt_len) + printf("\033[%dC\033H",opt_rt_len); + putchar('\r'); + } + + /* -blank [0-60]. */ + if (opt_blank && vcterm) + printf("\033[9;%d]", opt_bl_min); - /* -powersave [on|vsync|hsync|powerdown|off] (console) */ - if (opt_powersave) { - char ioctlarg[2]; - ioctlarg[0] = 10; /* powersave */ - ioctlarg[1] = opt_ps_mode; - if (ioctl(0,TIOCLINUX,ioctlarg)) - fprintf(stderr,_("cannot (un)set powersave mode\n")); - } - - /* -powerdown [0-60]. */ - if (opt_powerdown) { - printf("\033[14;%d]", opt_pd_min); - } + /* -powersave [on|vsync|hsync|powerdown|off] (console) */ + if (opt_powersave) { + char ioctlarg[2]; + ioctlarg[0] = 10; /* powersave */ + ioctlarg[1] = opt_ps_mode; + if (ioctl(0,TIOCLINUX,ioctlarg)) + fprintf(stderr,_("cannot (un)set powersave mode\n")); + } + + /* -powerdown [0-60]. */ + if (opt_powerdown) { + printf("\033[14;%d]", opt_pd_min); + } #if 0 - /* -standout [num]. */ - if (opt_standout) - /* nothing */; + /* -standout [num]. */ + if (opt_standout) + /* nothing */; #endif - /* -snap [1-NR_CONS]. */ - if (opt_snap || opt_append) { - FILE *F; - - F = fopen(opt_sn_name, opt_snap ? "w" : "a"); - if (!F) { - perror(opt_sn_name); - fprintf(stderr,("setterm: can not open dump file %s for output\n"), - opt_sn_name); - exit(-1); - } - screendump(opt_sn_num, F); - fclose(F); - } - - /* -msg [on|off]. */ - if (opt_msg && vcterm) { - if (opt_msg_on) - /* 7 -- Enable printk's to console */ - result = klogctl(7, NULL, 0); - else - /* 6 -- Disable printk's to console */ - result = klogctl(6, NULL, 0); - - if (result != 0) - printf(_("klogctl error: %s\n"), strerror(result)); - } - - /* -msglevel [0-8] */ - if (opt_msglevel && vcterm) { - /* 8 -- Set level of messages printed to console */ - result = klogctl(8, NULL, opt_msglevel_num); - if (result != 0) - printf(_("klogctl error: %s\n"), strerror(result)); - } - - /* -blength [0-2000] */ - if (opt_blength && vcterm) { - printf("\033[11;%d]", opt_blength_l); - } + /* -snap [1-NR_CONS]. */ + if (opt_snap || opt_append) { + FILE *F; + + F = fopen(opt_sn_name, opt_snap ? "w" : "a"); + if (!F) { + perror(opt_sn_name); + fprintf(stderr,("setterm: can not open dump file %s for output\n"), + opt_sn_name); + exit(-1); + } + screendump(opt_sn_num, F); + fclose(F); + } + + /* -msg [on|off]. */ + if (opt_msg && vcterm) { + if (opt_msg_on) + /* 7 -- Enable printk's to console */ + result = klogctl(7, NULL, 0); + else + /* 6 -- Disable printk's to console */ + result = klogctl(6, NULL, 0); + + if (result != 0) + printf(_("klogctl error: %s\n"), strerror(result)); + } + + /* -msglevel [0-8] */ + if (opt_msglevel && vcterm) { + /* 8 -- Set level of messages printed to console */ + result = klogctl(8, NULL, opt_msglevel_num); + if (result != 0) + printf(_("klogctl error: %s\n"), strerror(result)); + } + + /* -blength [0-2000] */ + if (opt_blength && vcterm) { + printf("\033[11;%d]", opt_blength_l); + } - /* -bfreq freqnumber */ - if (opt_bfreq && vcterm) { - printf("\033[10;%d]", opt_bfreq_f); - } + /* -bfreq freqnumber */ + if (opt_bfreq && vcterm) { + printf("\033[10;%d]", opt_bfreq_f); + } } -extern char *malloc(); - -void -screendump(int vcnum, FILE *F){ +static void +screendump(int vcnum, FILE *F) { #include char infile[MAXPATHLEN]; unsigned char header[4]; @@ -1148,69 +1177,70 @@ try_ioctl: } } -int main(int argc, char **argv) -{ - int bad_arg = FALSE; /* Set if error in arguments. */ - int arg, modifier; - char *term; /* Terminal type. */ - int vcterm; /* Set if terminal is a virtual console. */ +int +main(int argc, char **argv) { + int bad_arg = FALSE; /* Set if error in arguments. */ + int arg, modifier; + char *term; /* Terminal type. */ + int vcterm; /* Set if terminal is a virtual console. */ - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); - if (argc < 2) bad_arg = TRUE; + if (argc < 2) + bad_arg = TRUE; - /* Parse arguments. */ + /* Parse arguments. */ - for (arg = 1; arg < argc;) { - if (*argv[arg] == '-') { + for (arg = 1; arg < argc;) { + if (*argv[arg] == '-') { - /* Parse a single option. */ + /* Parse a single option. */ - for (modifier = arg + 1; modifier < argc; modifier++) { - if (*argv[modifier] == '-') break; + for (modifier = arg + 1; modifier < argc; modifier++) { + if (*argv[modifier] == '-') break; + } + parse_option(argv[arg] + 1, modifier - arg - 1, + &argv[arg + 1], &bad_arg); + arg = modifier; + } else { + bad_arg = TRUE; + arg++; } - parse_option(argv[arg] + 1, modifier - arg - 1, - &argv[arg + 1], &bad_arg); - arg = modifier; - } else { - - bad_arg = TRUE; - arg++; } - } - /* Display syntax message if error in arguments. */ + /* Display syntax message if error in arguments. */ - if (bad_arg) { - usage(argv[0]); - exit(1); - } + if (bad_arg) { + usage(argv[0]); + exit(1); + } - /* Find out terminal name. */ + /* Find out terminal name. */ - if (opt_term) { - term = opt_te_terminal_name; - } else { - term = getenv("TERM"); - if (term == NULL) { - fprintf(stderr, _("%s: $TERM is not defined.\n"), argv[0]); - exit(1); + if (opt_term) { + term = opt_te_terminal_name; + } else { + term = getenv("TERM"); + if (term == NULL) { + fprintf(stderr, _("%s: $TERM is not defined.\n"), + argv[0]); + exit(1); + } } - } - /* Find terminfo entry. */ + /* Find terminfo entry. */ - setupterm(term, 1, (int *)0); + setupterm(term, 1, (int *)0); - /* See if the terminal is a virtual console terminal. */ + /* See if the terminal is a virtual console terminal. */ - vcterm = (!strncmp(term, "con", 3) || !strncmp(term, "linux", 5)); + vcterm = (!strncmp(term, "con", 3) || !strncmp(term, "linux", 5)); - /* Perform the selected options. */ + /* Perform the selected options. */ - perform_sequence(vcterm); + perform_sequence(vcterm); - return 0; + return 0; } diff --git a/misc-utils/tsort.c b/misc-utils/tsort.c index a1fab2a9..b97b1a03 100644 --- a/misc-utils/tsort.c +++ b/misc-utils/tsort.c @@ -86,24 +86,21 @@ typedef struct _buf { int b_bsize; } BUF; -NODE *add_node(), *find_node(); -void add_arc(), no_memory(), remove_node(), tsort(); -char *grow_buf(); +NODE *add_node(char *), *find_node(char *); +void add_arc(char *, char *), no_memory(void); +void remove_node(NODE *), tsort(void); +char *grow_buf(char *, int); int find_cycle(NODE *, NODE *, int, int); -extern int errno; NODE *graph; NODE *hashtable[HASHSIZE]; NODE **cycle_buf; NODE **longest_cycle; int -main(argc, argv) - int argc; - char **argv; -{ - register BUF *b; - register int c, n; +main(int argc, char **argv) { + BUF *b; + int c, n; FILE *fp; int bsize, nused; BUF bufs[2]; @@ -165,10 +162,7 @@ main(argc, argv) /* double the size of oldbuf and return a pointer to the new buffer. */ char * -grow_buf(bp, size) - char *bp; - int size; -{ +grow_buf(char *bp, int size) { if (!(bp = realloc(bp, (u_int)size))) no_memory(); return(bp); @@ -179,10 +173,8 @@ grow_buf(bp, size) * the graph, then add them. */ void -add_arc(s1, s2) - char *s1, *s2; -{ - register NODE *n1; +add_arc(char *s1, char *s2) { + NODE *n1; NODE *n2; int bsize; @@ -213,11 +205,9 @@ add_arc(s1, s2) ++n2->n_refcnt; } -int -hash_string(s) - char *s; -{ - register int hash, i; +static int +hash_string(char *s) { + int hash, i; for (hash = 0, i = 1; *s; s++, i++) hash += *s * i; @@ -229,10 +219,8 @@ hash_string(s) * found. */ NODE * -find_node(name) - char *name; -{ - register NODE *n; +find_node(char *name) { + NODE *n; for (n = hashtable[hash_string(name)]; n; n = n->n_hash) if (!strcmp(n->n_name, name)) @@ -242,10 +230,8 @@ find_node(name) /* Add a node to the graph and return a pointer to it. */ NODE * -add_node(name) - char *name; -{ - register NODE *n; +add_node(char *name) { + NODE *n; int hash; if (!(n = (NODE *)malloc(sizeof(NODE))) || !(n->n_name = strdup(name))) @@ -272,10 +258,9 @@ add_node(name) /* do topological sort on graph */ void -tsort() -{ - register NODE *n, *next; - register int cnt; +tsort(void) { + NODE *n, *next; + int cnt; while (graph) { /* @@ -314,7 +299,7 @@ tsort() for (n = graph; n; n = n->n_next) if (!(n->n_flags & NF_ACYCLIC)) { if ((cnt = find_cycle(n, n, 0, 0)) != 0) { - register int i; + int i; (void)fprintf(stderr, _("tsort: cycle in data.\n")); @@ -338,11 +323,9 @@ tsort() /* print node and remove from graph (does not actually free node) */ void -remove_node(n) - register NODE *n; -{ - register NODE **np; - register int i; +remove_node(NODE *n) { + NODE **np; + int i; (void)printf("%s\n", n->n_name); for (np = n->n_arcs, i = n->n_narcs; --i >= 0; np++) @@ -355,12 +338,9 @@ remove_node(n) /* look for the longest cycle from node from to node to. */ int -find_cycle(from, to, longest_len, depth) - NODE *from, *to; - int depth, longest_len; -{ - register NODE **np; - register int i, len; +find_cycle(NODE *from, NODE *to, int longest_len, int depth) { + NODE **np; + int i, len; /* * avoid infinite loops and ignore portions of the graph known @@ -390,8 +370,7 @@ find_cycle(from, to, longest_len, depth) } void -no_memory() -{ +no_memory(void) { (void)fprintf(stderr, "tsort: %s.\n", strerror(ENOMEM)); exit(1); } diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c index cb07bc68..bc505c54 100644 --- a/misc-utils/whereis.c +++ b/misc-utils/whereis.c @@ -143,10 +143,7 @@ char uflag; * look for source, documentation and binaries */ int -main(argc, argv) - int argc; - char *argv[]; -{ +main(int argc, char **argv) { setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); diff --git a/misc-utils/write.c b/misc-utils/write.c index cac26239..1cf99c7f 100644 --- a/misc-utils/write.c +++ b/misc-utils/write.c @@ -45,13 +45,16 @@ * */ +#include #include #include +#include #include +#include #include -#include #include #include +#include #include #include #include @@ -66,19 +69,17 @@ void search_utmp(char *, char *, char *, uid_t); void do_write(char *, char *, uid_t); void wr_fputs(char *); +static void done(int); int term_chk(char *, int *, time_t *, int); int utmp_chk(char *, char *); -extern int errno; int -main(int argc, char **argv) -{ +main(int argc, char **argv) { time_t atime; uid_t myuid; int msgsok, myttyfd; - char tty[MAXPATHLEN], *mytty, *ttyname(); - void done(); + char tty[MAXPATHLEN], *mytty; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); @@ -146,7 +147,7 @@ main(int argc, char **argv) (void)fprintf(stderr, _("usage: write user [tty]\n")); exit(1); } - done(); + done(0); /* NOTREACHED */ return 0; } @@ -287,14 +288,11 @@ int term_chk(char *tty, int *msgsokP, time_t *atimeP, int showerror) /* * do_write - actually make the connection */ -void do_write(char *tty, char *mytty, uid_t myuid) - -{ +void do_write(char *tty, char *mytty, uid_t myuid) { register char *login, *nows; register struct passwd *pwd; - time_t now, time(); - char *getlogin(), path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512]; - void done(); + time_t now; + char path[MAXPATHLEN], host[MAXHOSTNAMELEN], line[512]; /* Determine our login name before the we reopen() stdout */ if ((login = getlogin()) == NULL) { @@ -333,8 +331,8 @@ void do_write(char *tty, char *mytty, uid_t myuid) /* * done - cleanup and exit */ -void done(void) -{ +static void +done(int dummy) { (void)printf("EOF\r\n"); exit(0); } diff --git a/mount/Makefile b/mount/Makefile index 443e8f78..6f72413d 100644 --- a/mount/Makefile +++ b/mount/Makefile @@ -14,14 +14,20 @@ LINK = $(CC) $(LDFLAGS) SUID_PROGS = mount umount NOSUID_PROGS = swapon losetup -PROGS = $(SUID_PROGS) $(NOSUID_PROGS) MAN5 = fstab.5 nfs.5 MAN8 = mount.8 swapoff.8 swapon.8 umount.8 losetup.8 +ifeq "$(HAVE_PIVOT_ROOT)" "yes" +NOSUID_PROGS := $(NOSUID_PROGS) pivot_root +MAN8 := $(MAN8) pivot_root.8 +endif + +PROGS = $(SUID_PROGS) $(NOSUID_PROGS) + # comment these out if you are not compiling in NFS support NFS_OBJS = nfsmount.o nfsmount_xdr.o nfsmount_clnt.o # uncomment this if you don't have libc-4.2 but do have the rpclib -GEN_FILES = nfsmount.x nfsmount.h nfsmount_xdr.c nfsmount_clnt.c +GEN_FILES = nfsmount.h nfsmount_xdr.c nfsmount_clnt.c # comment these out if you are not compiling in loop support LO_OBJS=lomount.o @@ -30,8 +36,8 @@ all: $(PROGS) install: $(PROGS) $(INSTALLDIR) $(BINDIR) $(SBINDIR) - $(INSTALLSUID) -s $(SUID_PROGS) $(BINDIR) - $(INSTALLBIN) -s $(NOSUID_PROGS) $(SBINDIR) + $(INSTALLSUID) $(SUID_PROGS) $(BINDIR) + $(INSTALLBIN) $(NOSUID_PROGS) $(SBINDIR) (cd $(SBINDIR); ln -sf swapon swapoff) $(INSTALLDIR) $(MAN5DIR) $(MAN8DIR) $(INSTALLMAN) $(MAN5) $(MAN5DIR) @@ -52,6 +58,10 @@ umount: umount.o fstab.o sundries.o realpath.o mntent.o getusername.o \ swapon: swapon.o version.o $(LINK) $^ -o $@ +losetup.o: lomount.c + $(COMPILE) -DMAIN lomount.c + mv lomount.o losetup.o + losetup: losetup.o $(LINK) $^ -o $@ @@ -85,28 +95,20 @@ nfsmount_clnt.o: nfsmount_clnt.c nfsmount_xdr.o: nfsmount_xdr.c $(COMPILE) $(RPC_CFLAGS) nfsmount_xdr.c -# rpcgen generates files that do not compile - use the pregenerated ones -# nfsmount.h nfsmount_xdr.c nfsmount_clnt.c: nfsmount.x -# rm -f nfsmount.h nfsmount_xdr.c nfsmount_clnt.c -# $(RPCGEN) -h -o nfsmount.h nfsmount.x -# $(RPCGEN) -c -o nfsmount_xdr.c nfsmount.x -# $(RPCGEN) -l -o nfsmount_clnt.c nfsmount.x - -nfsmount.x: - cp $(RPCSVCDIR)/nfsmount.x . - -nfsmount.o: nfs_mountversion.h nfs_mount3.h - -NFSMOUNTH=/usr/include/linux/nfs_mount.h - -nfs_mountversion.h: - rm -f nfs_mountversion.h - if [ -f $(NFSMOUNTH) ]; then \ - grep NFS_MOUNT_VERSION $(NFSMOUNTH) \ - | sed -e 's/NFS/KERNEL_NFS/'; \ - else \ - echo '#define KERNEL_NFS_MOUNT_VERSION 0'; \ - fi > nfs_mountversion.h +ifeq "$(HAVE_GOOD_RPC)" "yes" +nfsmount.h nfsmount_xdr.c nfsmount_clnt.c: nfsmount.x + rm -f nfsmount.h nfsmount_xdr.c nfsmount_clnt.c + $(RPCGEN) -h -o nfsmount.h nfsmount.x + $(RPCGEN) -c -o nfsmount_xdr.c nfsmount.x + $(RPCGEN) -l -o nfsmount_clnt.c nfsmount.x +else +nfsmount.h nfsmount_xdr.c nfsmount_clnt.c: + cp $(RPCSVCDIR)/nfsmount.h . + cp $(RPCSVCDIR)/nfsmount_xdr.c . + cp $(RPCSVCDIR)/nfsmount_clnt.c . +endif + +nfsmount.o: nfs_mount4.h swapargs.h: sh swap.configure @@ -119,4 +121,4 @@ clean: rm -f loop.h nfs_mountversion.h clobber distclean realclean: clean -# rm -f $(GEN_FILES) + rm -f $(GEN_FILES) diff --git a/mount/lomount.c b/mount/lomount.c index d9907858..52157a14 100644 --- a/mount/lomount.c +++ b/mount/lomount.c @@ -23,268 +23,393 @@ #include #include #include +#include #include "loop.h" #include "lomount.h" #include "nls.h" -char *xstrdup (const char *s); /* not: #include "sundries.h" */ -void error (const char *fmt, ...); /* idem */ +extern int verbose; +extern char *xstrdup (const char *s); /* not: #include "sundries.h" */ +extern void error (const char *fmt, ...); /* idem */ #ifdef LOOP_SET_FD struct crypt_type_struct { - int id; - char *name; + int id; + char *name; } crypt_type_tbl[] = { - { LO_CRYPT_NONE, "no" }, - { LO_CRYPT_NONE, "none" }, - { LO_CRYPT_XOR, "xor" }, - { LO_CRYPT_DES, "DES" }, - { -1, NULL } + { LO_CRYPT_NONE, "no" }, + { LO_CRYPT_NONE, "none" }, + { LO_CRYPT_XOR, "xor" }, + { LO_CRYPT_DES, "DES" }, + { -1, NULL } }; static int -crypt_type (const char *name) -{ - int i; - - if (name) - for (i = 0; crypt_type_tbl[i].id != -1; i++) - if (!strcasecmp (name, crypt_type_tbl[i].name)) - return crypt_type_tbl[i].id; - return -1; +crypt_type (const char *name) { + int i; + + if (name) { + for (i = 0; crypt_type_tbl[i].id != -1; i++) + if (!strcasecmp (name, crypt_type_tbl[i].name)) + return crypt_type_tbl[i].id; + } + return -1; } -#if 0 +#ifdef MAIN static char * -crypt_name (int id) -{ - int i; - - for (i = 0; crypt_type_tbl[i].id != -1; i++) - if (id == crypt_type_tbl[i].id) - return crypt_type_tbl[i].name; - return "undefined"; +crypt_name (int id) { + int i; + + for (i = 0; crypt_type_tbl[i].id != -1; i++) + if (id == crypt_type_tbl[i].id) + return crypt_type_tbl[i].name; + return "undefined"; } static void -show_loop (char *device) -{ - struct loop_info loopinfo; - int fd; - - if ((fd = open (device, O_RDONLY)) < 0) { - int errsv = errno; - fprintf(stderr, _("loop: can't open device %s: %s\n"), - device, strerror (errsv)); - return; - } - if (ioctl (fd, LOOP_GET_STATUS, &loopinfo) < 0) { - int errsv = errno; - fprintf(stderr, _("loop: can't get info on device %s: %s\n"), - device, strerror (errsv)); - close (fd); - return; - } - printf (_("%s: [%04x]:%ld (%s) offset %d, %s encryption\n"), - device, loopinfo.lo_device, loopinfo.lo_inode, - loopinfo.lo_name, loopinfo.lo_offset, - crypt_name (loopinfo.lo_encrypt_type)); - close (fd); +show_loop (char *device) { + struct loop_info loopinfo; + int fd; + + if ((fd = open (device, O_RDONLY)) < 0) { + int errsv = errno; + fprintf(stderr, _("loop: can't open device %s: %s\n"), + device, strerror (errsv)); + return; + } + if (ioctl (fd, LOOP_GET_STATUS, &loopinfo) < 0) { + int errsv = errno; + fprintf(stderr, _("loop: can't get info on device %s: %s\n"), + device, strerror (errsv)); + close (fd); + return; + } + printf (_("%s: [%04x]:%ld (%s) offset %d, %s encryption\n"), + device, loopinfo.lo_device, loopinfo.lo_inode, + loopinfo.lo_name, loopinfo.lo_offset, + crypt_name (loopinfo.lo_encrypt_type)); + close (fd); } #endif char * -find_unused_loop_device (void) -{ - /* Just creating a device, say in /tmp, is probably a bad idea - - people might have problems with backup or so. - So, we just try /dev/loop[0-7]. */ - char dev[20]; - int i, fd, somedev = 0, someloop = 0, loop_known = 0; - struct stat statbuf; - struct loop_info loopinfo; - FILE *procdev; - - for(i = 0; i < 256; i++) { - sprintf(dev, "/dev/loop%d", i); - if (stat (dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) { - somedev++; - fd = open (dev, O_RDONLY); - if (fd >= 0) { - if(ioctl (fd, LOOP_GET_STATUS, &loopinfo) == 0) - someloop++; /* in use */ - else if (errno == ENXIO) { - close (fd); - return xstrdup(dev); /* probably free */ - } - close (fd); - } - continue; /* continue trying as long as devices exist */ - } - if (i >= 7) - break; - } - - /* Nothing found. Why not? */ - if ((procdev = fopen(PROC_DEVICES, "r")) != NULL) { - char line[100]; - while (fgets (line, sizeof(line), procdev)) - if (strstr (line, " loop\n")) { - loop_known = 1; - break; +find_unused_loop_device (void) { + /* Just creating a device, say in /tmp, is probably a bad idea - + people might have problems with backup or so. + So, we just try /dev/loop[0-7]. */ + char dev[20]; + int i, fd, somedev = 0, someloop = 0, loop_known = 0; + struct stat statbuf; + struct loop_info loopinfo; + FILE *procdev; + + for(i = 0; i < 256; i++) { + sprintf(dev, "/dev/loop%d", i); + if (stat (dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) { + somedev++; + fd = open (dev, O_RDONLY); + if (fd >= 0) { + if(ioctl (fd, LOOP_GET_STATUS, &loopinfo) == 0) + someloop++; /* in use */ + else if (errno == ENXIO) { + close (fd); + return xstrdup(dev);/* probably free */ + } + close (fd); + } + continue;/* continue trying as long as devices exist */ + } + if (i >= 7) + break; } - fclose(procdev); - if (!loop_known) - loop_known = -1; - } - - if (!somedev) - error(_("mount: could not find any device /dev/loop#")); - else if(!someloop) { - if (loop_known == 1) - error(_( -"mount: Could not find any loop device.\n" -" Maybe /dev/loop# has a wrong major number?")); - else if (loop_known == -1) - error(_( -"mount: Could not find any loop device, and, according to %s,\n" -" this kernel does not know about the loop device.\n" -" (If so, then recompile or `insmod loop.o'.)"), PROC_DEVICES); - else - error(_( -"mount: Could not find any loop device. Maybe this kernel does not know\n" -" about the loop device (then recompile or `insmod loop.o'), or\n" -" maybe /dev/loop# has the wrong major number?")); - } else - error(_("mount: could not find any free loop device")); - return 0; + + /* Nothing found. Why not? */ + if ((procdev = fopen(PROC_DEVICES, "r")) != NULL) { + char line[100]; + while (fgets (line, sizeof(line), procdev)) + if (strstr (line, " loop\n")) { + loop_known = 1; + break; + } + fclose(procdev); + if (!loop_known) + loop_known = -1; + } + + if (!somedev) + error(_("mount: could not find any device /dev/loop#")); + else if(!someloop) { + if (loop_known == 1) + error(_( + "mount: Could not find any loop device.\n" + " Maybe /dev/loop# has a wrong major number?")); + else if (loop_known == -1) + error(_( + "mount: Could not find any loop device, and, according to %s,\n" + " this kernel does not know about the loop device.\n" + " (If so, then recompile or `insmod loop.o'.)"), + PROC_DEVICES); + else + error(_( + "mount: Could not find any loop device. Maybe this kernel does not know\n" + " about the loop device (then recompile or `insmod loop.o'), or\n" + " maybe /dev/loop# has the wrong major number?")); + } else + error(_("mount: could not find any free loop device")); + return 0; } int set_loop (const char *device, const char *file, int offset, - const char *encryption, int *loopro) -{ - struct loop_info loopinfo; - int fd, ffd, mode, i; - char *pass; - - mode = (*loopro ? O_RDONLY : O_RDWR); - if ((ffd = open (file, mode)) < 0) { - if (!*loopro && errno == EROFS) - ffd = open (file, mode = O_RDONLY); - if (ffd < 0) { - perror (file); - return 1; - } - } - if ((fd = open (device, mode)) < 0) { - perror (device); - return 1; - } - *loopro = (mode == O_RDONLY); - memset (&loopinfo, 0, sizeof (loopinfo)); - strncpy (loopinfo.lo_name, file, LO_NAME_SIZE); - loopinfo.lo_name[LO_NAME_SIZE - 1] = 0; - if (encryption && (loopinfo.lo_encrypt_type = crypt_type (encryption)) - < 0) { - fprintf (stderr, _("Unsupported encryption type %s\n"), encryption); - return 1; - } - loopinfo.lo_offset = offset; - switch (loopinfo.lo_encrypt_type) { - case LO_CRYPT_NONE: - loopinfo.lo_encrypt_key_size = 0; - break; - case LO_CRYPT_XOR: - pass = getpass (_("Password: ")); - strncpy (loopinfo.lo_encrypt_key, pass, LO_KEY_SIZE); - loopinfo.lo_encrypt_key[LO_KEY_SIZE - 1] = 0; - loopinfo.lo_encrypt_key_size = strlen (loopinfo.lo_encrypt_key); - break; - case LO_CRYPT_DES: - pass = getpass (_("Password: ")); - strncpy (loopinfo.lo_encrypt_key, pass, 8); - loopinfo.lo_encrypt_key[8] = 0; - loopinfo.lo_encrypt_key_size = 8; - pass = getpass (_("Init (up to 16 hex digits): ")); - for (i = 0; i < 16 && pass[i]; i++) - if (isxdigit (pass[i])) - loopinfo.lo_init[i >> 3] |= (pass[i] > '9' ? - (islower (pass[i]) ? toupper (pass[i]) : - pass[i]) - 'A' + 10 : pass[i] - '0') << (i & 7) * 4; - else { - fprintf (stderr, _("Non-hex digit '%c'.\n"), pass[i]); - return 1; - } - break; - default: - fprintf (stderr, - _("Don't know how to get key for encryption system %d\n"), - loopinfo.lo_encrypt_type); - return 1; - } - if (ioctl (fd, LOOP_SET_FD, ffd) < 0) { - perror ("ioctl: LOOP_SET_FD"); - return 1; - } - if (ioctl (fd, LOOP_SET_STATUS, &loopinfo) < 0) { - (void) ioctl (fd, LOOP_CLR_FD, 0); - perror ("ioctl: LOOP_SET_STATUS"); - return 1; - } - close (fd); - close (ffd); - if (verbose > 1) - printf(_("set_loop(%s,%s,%d): success\n"), device, file, offset); - return 0; + const char *encryption, int *loopro) { + struct loop_info loopinfo; + int fd, ffd, mode, i; + char *pass; + + mode = (*loopro ? O_RDONLY : O_RDWR); + if ((ffd = open (file, mode)) < 0) { + if (!*loopro && errno == EROFS) + ffd = open (file, mode = O_RDONLY); + if (ffd < 0) { + perror (file); + return 1; + } + } + if ((fd = open (device, mode)) < 0) { + perror (device); + return 1; + } + *loopro = (mode == O_RDONLY); + + memset (&loopinfo, 0, sizeof (loopinfo)); + strncpy (loopinfo.lo_name, file, LO_NAME_SIZE); + loopinfo.lo_name[LO_NAME_SIZE - 1] = 0; + if (encryption && (loopinfo.lo_encrypt_type = crypt_type (encryption)) + < 0) { + fprintf (stderr, _("Unsupported encryption type %s\n"), + encryption); + return 1; + } + loopinfo.lo_offset = offset; + +#ifdef MCL_FUTURE + /* + * Oh-oh, sensitive data coming up. Better lock into memory to prevent + * passwd etc being swapped out and left somewhere on disk. + */ + + if(mlockall(MCL_CURRENT|MCL_FUTURE)) { + perror("memlock"); + fprintf(stderr, _("Couldn't lock into memory, exiting.\n")); + exit(1); + } +#endif + + switch (loopinfo.lo_encrypt_type) { + case LO_CRYPT_NONE: + loopinfo.lo_encrypt_key_size = 0; + break; + case LO_CRYPT_XOR: + pass = getpass (_("Password: ")); + strncpy (loopinfo.lo_encrypt_key, pass, LO_KEY_SIZE); + loopinfo.lo_encrypt_key[LO_KEY_SIZE - 1] = 0; + loopinfo.lo_encrypt_key_size = strlen(loopinfo.lo_encrypt_key); + break; + case LO_CRYPT_DES: + pass = getpass (_("Password: ")); + strncpy (loopinfo.lo_encrypt_key, pass, 8); + loopinfo.lo_encrypt_key[8] = 0; + loopinfo.lo_encrypt_key_size = 8; + pass = getpass (_("Init (up to 16 hex digits): ")); + for (i = 0; i < 16 && pass[i]; i++) + if (isxdigit (pass[i])) { + loopinfo.lo_init[i >> 3] |= (pass[i] > '9' ? + (islower (pass[i]) ? toupper (pass[i]) : + pass[i])-'A'+10 : pass[i]-'0') << (i&7) * 4; + } else { + fprintf (stderr, _("Non-hex digit '%c'.\n"), + pass[i]); + return 1; + } + break; + default: + fprintf (stderr, + _("Don't know how to get key for encryption system %d\n"), + loopinfo.lo_encrypt_type); + return 1; + } + if (ioctl (fd, LOOP_SET_FD, ffd) < 0) { + perror ("ioctl: LOOP_SET_FD"); + return 1; + } + if (ioctl (fd, LOOP_SET_STATUS, &loopinfo) < 0) { + (void) ioctl (fd, LOOP_CLR_FD, 0); + perror ("ioctl: LOOP_SET_STATUS"); + return 1; + } + close (fd); + close (ffd); + if (verbose > 1) + printf(_("set_loop(%s,%s,%d): success\n"), + device, file, offset); + return 0; } int -del_loop (const char *device) -{ - int fd; - - if ((fd = open (device, O_RDONLY)) < 0) { - int errsv = errno; - fprintf(stderr, _("loop: can't delete device %s: %s\n"), - device, strerror (errsv)); - return 1; - } - if (ioctl (fd, LOOP_CLR_FD, 0) < 0) { - perror ("ioctl: LOOP_CLR_FD"); - return 1; - } - close (fd); - if (verbose > 1) - printf(_("del_loop(%s): success\n"), device); - return 0; +del_loop (const char *device) { + int fd; + + if ((fd = open (device, O_RDONLY)) < 0) { + int errsv = errno; + fprintf(stderr, _("loop: can't delete device %s: %s\n"), + device, strerror (errsv)); + return 1; + } + if (ioctl (fd, LOOP_CLR_FD, 0) < 0) { + perror ("ioctl: LOOP_CLR_FD"); + return 1; + } + close (fd); + if (verbose > 1) + printf(_("del_loop(%s): success\n"), device); + return 0; } #else /* no LOOP_SET_FD defined */ static void mutter(void) { - fprintf(stderr, - _("This mount was compiled without loop support. Please recompile.\n")); + fprintf(stderr, + _("This mount was compiled without loop support. " + "Please recompile.\n")); } int set_loop (const char *device, const char *file, int offset, const char *encryption, int *loopro) { - mutter(); - return 1; + mutter(); + return 1; } int del_loop (const char *device) { - mutter(); - return 1; + mutter(); + return 1; } char * find_unused_loop_device (void) { - mutter(); - return 0; + mutter(); + return 0; } #endif + +#ifdef MAIN + +#ifdef LOOP_SET_FD + +#include +#include + +int verbose = 0; +static char *progname; + +static void +usage(void) { + fprintf(stderr, _("usage:\n\ + %s loop_device # give info\n\ + %s -d loop_device # delete\n\ + %s [ -e encryption ] [ -o offset ] loop_device file # setup\n"), + progname, progname, progname); + exit(1); +} + +char * +xstrdup (const char *s) { + char *t; + + if (s == NULL) + return NULL; + + t = strdup (s); + + if (t == NULL) { + fprintf(stderr, _("not enough memory")); + exit(1); + } + + return t; +} + +void +error (const char *fmt, ...) { + va_list args; + + va_start (args, fmt); + vfprintf (stderr, fmt, args); + va_end (args); + fprintf (stderr, "\n"); +} + +int +main(int argc, char **argv) { + char *offset, *encryption; + int delete,off,c; + int res = 0; + int ro = 0; + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + delete = off = 0; + offset = encryption = NULL; + progname = argv[0]; + while ((c = getopt(argc,argv,"de:o:v")) != EOF) { + switch (c) { + case 'd': + delete = 1; + break; + case 'e': + encryption = optarg; + break; + case 'o': + offset = optarg; + break; + case 'v': + verbose = 1; + break; + default: + usage(); + } + } + if (argc == 1) usage(); + if ((delete && (argc != optind+1 || encryption || offset)) || + (!delete && (argc < optind+1 || argc > optind+2))) + usage(); + if (argc == optind+1) { + if (delete) + res = del_loop(argv[optind]); + else + show_loop(argv[optind]); + } else { + if (offset && sscanf(offset,"%d",&off) != 1) + usage(); + res = set_loop(argv[optind],argv[optind+1],off,encryption,&ro); + } + return res; +} + +#else /* LOOP_SET_FD not defined */ + +int +main(int argc, char **argv) { + fprintf(stderr, + _("No loop support was available at compile time. " + "Please recompile.\n")); + return -1; +} +#endif +#endif diff --git a/mount/losetup.c b/mount/losetup.c deleted file mode 100644 index 9f20ee8b..00000000 --- a/mount/losetup.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * losetup.c - setup and control loop devices - */ - -/* 1999-02-22 Arkadiusz Mi¶kiewicz - * - added Native Language Support - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "loop.h" -#include "lomount.h" -#include "nls.h" - -#ifdef LOOP_SET_FD - -static char *progname; - -struct crypt_type_struct { - int id; - char *name; -} crypt_type_tbl[] = { - { LO_CRYPT_NONE,"no" }, - { LO_CRYPT_NONE,"none" }, - { LO_CRYPT_XOR, "xor" }, - { LO_CRYPT_DES, "DES" }, - { -1, NULL } -}; - - -static char *crypt_name(int id) -{ - int i; - - for (i = 0; crypt_type_tbl[i].id != -1; i++) - if (id == crypt_type_tbl[i].id) - return crypt_type_tbl[i].name; - return "undefined"; -} - - -static int crypt_type(const char *name) -{ - int i; - - for (i = 0; crypt_type_tbl[i].id != -1; i++) - if (!strcasecmp(name, crypt_type_tbl[i].name)) - return crypt_type_tbl[i].id; - return -1; -} - - -static void show_loop(const char *device) -{ - struct loop_info loopinfo; - int fd; - - if ((fd = open(device, O_RDWR)) < 0) { - perror(device); - return; - } - if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) < 0) { - perror(_("Cannot get loop info")); - close(fd); - return; - } - printf(_("%s: [%04x]:%ld (%s) offset %d, %s encryption\n"), - device, loopinfo.lo_device, loopinfo.lo_inode, - loopinfo.lo_name, loopinfo.lo_offset, - crypt_name(loopinfo.lo_encrypt_type)); - close(fd); -} - - -int set_loop(const char *device, const char *file, int offset, - const char *encryption, int *loopro) -{ - struct loop_info loopinfo; - int fd, ffd, mode, i; - char *pass; - - mode = *loopro ? O_RDONLY : O_RDWR; - if ((ffd = open (file, mode)) < 0 && !*loopro - && (errno != EROFS || (ffd = open (file, mode = O_RDONLY)) < 0)) { - perror (file); - return 1; - } - if ((fd = open (device, mode)) < 0) { - perror (device); - return 1; - } - *loopro = (mode == O_RDONLY); - - memset(&loopinfo, 0, sizeof(loopinfo)); - strncpy(loopinfo.lo_name, file, LO_NAME_SIZE); - loopinfo.lo_name[LO_NAME_SIZE-1] = 0; - if (encryption && (loopinfo.lo_encrypt_type = crypt_type(encryption)) - < 0) { - fprintf(stderr,_("Unsupported encryption type %s\n"), - encryption); - exit(1); - } - loopinfo.lo_offset = offset; - switch (loopinfo.lo_encrypt_type) { - case LO_CRYPT_NONE: - loopinfo.lo_encrypt_key_size = 0; - break; - case LO_CRYPT_XOR: - pass = getpass(_("Password: ")); - strncpy(loopinfo.lo_encrypt_key, pass, LO_KEY_SIZE); - loopinfo.lo_encrypt_key[LO_KEY_SIZE-1] = 0; - loopinfo.lo_encrypt_key_size = strlen(loopinfo.lo_encrypt_key); - break; - case LO_CRYPT_DES: - pass = getpass(_("Password: ")); - strncpy(loopinfo.lo_encrypt_key, pass, 8); - loopinfo.lo_encrypt_key[8] = 0; - loopinfo.lo_encrypt_key_size = 8; - pass = getpass(_("Init (up to 16 hex digits): ")); - for (i = 0; i < 16 && pass[i]; i++) - if (isxdigit(pass[i])) - loopinfo.lo_init[i >> 3] |= (pass[i] > '9' ? - (islower(pass[i]) ? toupper(pass[i]) : - pass[i])-'A'+10 : pass[i]-'0') << (i & 7)*4; - else { - fprintf(stderr,_("Non-hex digit '%c'.\n"), - pass[i]); - exit(1); - } - break; - default: - fprintf(stderr, - _("Don't know how to get key for encryption system %d\n"), - loopinfo.lo_encrypt_type); - exit(1); - } - if (ioctl(fd, LOOP_SET_FD, ffd) < 0) { - perror("ioctl: LOOP_SET_FD"); - exit(1); - } - if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) { - (void) ioctl(fd, LOOP_CLR_FD, 0); - perror("ioctl: LOOP_SET_STATUS"); - exit(1); - } - close(fd); - close(ffd); - return 0; -} - -int del_loop(const char *device) -{ - int fd; - - if ((fd = open(device, O_RDONLY)) < 0) { - perror(device); - exit(1); - } - if (ioctl(fd, LOOP_CLR_FD, 0) < 0) { - perror("ioctl: LOOP_CLR_FD"); - exit(1); - } - return(0); -} - - -static int usage(void) -{ - fprintf(stderr, _("usage:\n\ - %s loop_device # give info\n\ - %s -d loop_device # delete\n\ - %s [ -e encryption ] [ -o offset ] loop_device file # setup\n"), - progname, progname, progname); - exit(1); -} - -int main(int argc, char **argv) -{ - char *offset,*encryption; - int delete,off,c; - int res = 0; - int ro = 0; - - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - - delete = off = 0; - offset = encryption = NULL; - progname = argv[0]; - while ((c = getopt(argc,argv,"de:o:")) != EOF) { - switch (c) { - case 'd': - delete = 1; - break; - case 'e': - encryption = optarg; - break; - case 'o': - offset = optarg; - break; - default: - usage(); - } - } - if (argc == 1) usage(); - if ((delete && (argc != optind+1 || encryption || offset)) || - (!delete && (argc < optind+1 || argc > optind+2))) - usage(); - if (argc == optind+1) { - if (delete) - del_loop(argv[optind]); - else - show_loop(argv[optind]); - } else { - if (offset && sscanf(offset,"%d",&off) != 1) - usage(); - res = set_loop(argv[optind],argv[optind+1],off,encryption,&ro); - } - return res; -} - -#else /* LOOP_SET_FD not defined */ - -int main(int argc, char **argv) { - fprintf(stderr, - _("No loop support was available at compile time. Please recompile.\n")); - return -1; -} -#endif diff --git a/mount/mount.8 b/mount/mount.8 index 4aba358c..7016ee53 100644 --- a/mount/mount.8 +++ b/mount/mount.8 @@ -40,7 +40,7 @@ .SH NAME mount \- mount a file system .SH SYNOPSIS -.BI "mount [\-hV]" +.BI "mount [\-lhV]" .LP .BI "mount \-a [\-fFnrsvw] [\-t " vfstype ] .br @@ -91,11 +91,12 @@ prints a help message; .RE prints a version string; and just .RS -.BI "mount [-t" " type" ] +.BI "mount [-l] [-t" " type" ] .RE lists all mounted file systems (of type -.IR type ) -- see below. +.IR type ). +The option \-l adds the (ext2) labels in this listing. +See below. The .I proc @@ -270,6 +271,14 @@ flag to determine what the command is trying to do. It can also be used to add entries for devices that were mounted earlier with the -n option. .TP +.B \-l +Add the ext2 labels in the mount output. Mount must have permission to +read the disk device (e.g. be suid root) for this to work. +One can set such a label +using the +.BR e2label (8) +utility. +.TP .B \-n Mount without writing in .IR /etc/mtab . @@ -624,12 +633,15 @@ to the options given in Set checking level. When at least one of these options is set (and .B check=normal is set by default) the inodes and blocks bitmaps are checked upon mount -(which can take half a minute or so on a big disk). +(which can take half a minute or so on a big disk, and is rather useless). With strict checking, block deallocation checks that the block to free is in the data zone. .TP .BR check=none " / " nocheck -No checking is done. +No checking is done. This is fast. Recent kernels do not have a +check option anymore - checking with +.BR e2fsck (8) +is more meaningful. .TP .B debug Print debugging info upon each (re)mount. @@ -985,7 +997,10 @@ Especially useful options include .TP .B rsize=8192,wsize=8192 This will make your nfs connection much faster than with the default -buffer size of 1024. +buffer size of 1024. (NFSv2 does not work with larger values of +.B rsize +and +.BR wsize .) .TP .B hard The program accessing a file on a NFS mounted file system will hang @@ -1251,6 +1266,7 @@ temporary file .BR umount (8), .BR swapon (8), .BR nfs (5), +.BR e2label (8), .BR mountd (8), .BR nfsd (8), .BR mke2fs (8), diff --git a/mount/mount.c b/mount/mount.c index 6c1f40a2..b8ee2ebe 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -34,6 +34,8 @@ * - fixed use of nouser option * 1999-09-09 Michael K. Johnson * - added `owner' mount option + * 2000-05-11 Mark A. Peloquin + * - check_special_mountprog now returns correct status */ #include @@ -68,13 +70,13 @@ #endif /* True for fake mount (-f). */ -int fake = 0; +static int fake = 0; /* Don't write a entry in /etc/mtab (-n). */ -int nomtab = 0; +static int nomtab = 0; /* True for explicit readonly (-r). */ -int readonly = 0; +static int readonly = 0; /* Nonzero for chatty (-v). */ int verbose = 0; @@ -83,20 +85,22 @@ int verbose = 0; int sloppy = 0; /* True for explicit read/write (-w). */ -int readwrite = 0; +static int readwrite = 0; /* True for all mount (-a). */ int all = 0; /* True for fork() during all mount (-F). */ -int optfork = 0; +static int optfork = 0; + +/* Add volumelabel in a listing of mounted devices (-l). */ +static int list_with_volumelabel = 0; /* True if ruid != euid. */ -int suid = 0; +static int suid = 0; /* Map from -o and fstab option strings to the flag argument to mount(2). */ -struct opt_map -{ +struct opt_map { const char *opt; /* option name */ int skip; /* skip in mtab option string */ int inv; /* true if flag value should be inverted */ @@ -124,7 +128,7 @@ struct opt_map /* Options that we make owner-mounted devices have by default */ #define MS_OWNERSECURE (MS_NOSUID|MS_NODEV) -const struct opt_map opt_map[] = { +static const struct opt_map opt_map[] = { { "defaults", 0, 0, 0 }, /* default options */ { "ro", 1, 0, MS_RDONLY }, /* read-only */ { "rw", 1, 1, MS_RDONLY }, /* read-write */ @@ -170,9 +174,10 @@ const struct opt_map opt_map[] = { { NULL, 0, 0, 0 } }; -static char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption; +static char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption, + *opt_speed; -struct string_opt_map { +static struct string_opt_map { char *tag; int skip; char **valptr; @@ -181,6 +186,7 @@ struct string_opt_map { { "vfs=", 1, &opt_vfstype }, { "offset=", 0, &opt_offset }, { "encryption=", 0, &opt_encryption }, + { "speed=", 0, &opt_speed }, { NULL, 0, NULL } }; @@ -219,13 +225,18 @@ print_one (const struct mntentchn *mc) { printf (" type %s", mc->mnt_type); if (mc->mnt_opts != NULL) printf (" (%s)", mc->mnt_opts); + if (list_with_volumelabel) { + const char *label; + label = get_volume_label_by_spec(mc->mnt_fsname); + if (label) + printf (" [%s]", label); + } printf ("\n"); } /* Report on everything in mtab (of the specified types if any). */ static int -print_all (string_list types) -{ +print_all (string_list types) { struct mntentchn *mc; for (mc = mtab_head()->nxt; mc; mc = mc->nxt) { @@ -239,8 +250,7 @@ print_all (string_list types) /* Look for OPT in opt_map table and return mask value. If OPT isn't found, tack it onto extra_opts (which is non-NULL). */ static inline void -parse_opt (const char *opt, int *mask, char *extra_opts) -{ +parse_opt (const char *opt, int *mask, char *extra_opts) { const struct opt_map *om; for (om = opt_map; om->opt != NULL; om++) @@ -270,8 +280,7 @@ parse_opt (const char *opt, int *mask, char *extra_opts) /* Take -o options list and compute 4th and 5th args to mount(2). flags gets the standard options and extra_opts anything we don't recognize. */ static void -parse_opts (char *opts, int *flags, char **extra_opts) -{ +parse_opts (char *opts, int *flags, char **extra_opts) { char *opt; *flags = 0; @@ -387,9 +396,13 @@ create_mtab (void) { /* count successful mount system calls */ static int mountcount = 0; -/* returns 0: OK, -1: error */ +/* + * do_mount_syscall() + * Mount a single file system. Keep track of successes. + * returns: 0: OK, -1: error in errno + */ static int -mount5 (struct mountargs *args) { +do_mount_syscall (struct mountargs *args) { int ret = mount (args->spec, args->node, args->type, MS_MGC_VAL | (args->flags), args->data); if (ret == 0) @@ -397,11 +410,15 @@ mount5 (struct mountargs *args) { return ret; } -/* Mount a single file system. - Return status: 0: OK, -1: error in errno, 1: other error - don't exit on non-fatal errors. */ +/* + * guess_fstype_and_mount() + * Mount a single file system. Guess the type when unknown. + * returns: 0: OK, -1: error in errno, 1: other error + * don't exit on non-fatal errors. + */ static int -try_mount5 (char *spec, char *node, char **type, int flags, char *mount_opts) { +guess_fstype_and_mount (char *spec, char *node, char **type, + int flags, char *mount_opts) { struct mountargs args = { spec, node, NULL, flags & ~MS_NOSYS, mount_opts }; if (*type && strcasecmp (*type, "auto") == 0) @@ -418,55 +435,30 @@ try_mount5 (char *spec, char *node, char **type, int flags, char *mount_opts) { if (*type || (flags & MS_REMOUNT)) { args.type = *type; - return mount5 (&args); + return do_mount_syscall (&args); } - return procfsloop(mount5, &args, type); + return procfsloop(do_mount_syscall, &args, type); } /* - * try_mount_one() - * Try to mount one file system. When "bg" is 1, this is a retry - * in the background. One additional exit code EX_BG is used here. - * It is used to instruct the caller to retry the mount in the - * background. + * suid_check() + * Die if the user is not allowed to do this. */ -static int -try_mount_one (const char *spec0, const char *node0, char *type0, - const char *opts0, int freq, int pass, int bg, int ro) { - struct mntentchn mcn; - struct mntent mnt; - int mnt5_res = 0; /* only for gcc */ - int mnt_err; - int flags; - char *extra_opts; /* written in mtab */ - char *mount_opts; /* actually used on system call */ - int loop, looptype, offset; - const char *opts; - char *spec, *node, *type, *loopdev, *loopfile; - char *user = 0; - struct stat statbuf; - - spec = xstrdup(spec0); - node = xstrdup(node0); - type = xstrdup(type0); - opts = xstrdup(opts0); - - parse_opts (xstrdup (opts), &flags, &extra_opts); - - /* root may allow certain types of mounts by ordinary users */ +static void +suid_check(char *spec, char *node, int *flags, char **user) { if (suid) { /* RedHat patch: allow owners to mount when fstab contains the owner option. Note that this should never be used in a high security environment, but may be useful to give people at the console the possibility of mounting a floppy. */ - if (flags & MS_OWNER) { - if (!strncmp(spec0, "/dev/", 5)) { + if (*flags & MS_OWNER) { + if (!strncmp(spec, "/dev/", 5)) { struct stat sb; - if (!stat(spec0, &sb)) { + if (!stat(spec, &sb)) { if (getuid() == sb.st_uid) - flags |= MS_USER; + *flags |= MS_USER; } } } @@ -476,24 +468,24 @@ try_mount_one (const char *spec0, const char *node0, char *type0, This is even less secure. Let me skip it for the time being; there should be an explicit fstab line allowing such things. */ - if (!(flags & (MS_USER | MS_USERS))) { + if (!(*flags & (MS_USER | MS_USERS))) { if (already (spec, node)) die (EX_USAGE, _("mount failed")); else die (EX_USAGE, _("mount: only root can mount %s on %s"), spec, node); } - if (flags & MS_USER) - user = getusername(); + if (*flags & MS_USER) + *user = getusername(); } - if (flags & MS_OWNER) - flags &= ~MS_OWNER; - - /* quietly succeed for fstab entries that don't get mounted automatically */ - if (all && (flags & MS_NOAUTO)) - return 0; + if (*flags & MS_OWNER) + *flags &= ~MS_OWNER; +} - mount_opts = extra_opts; +static int +loop_check(char **spec, char **type, int *flags, + int *loop, char **loopdev, char **loopfile) { + int looptype, offset; /* * In the case of a loop mount, either type is of the form lo@/dev/loop5 @@ -503,84 +495,142 @@ try_mount_one (const char *spec0, const char *node0, char *type0, * immediately: maybe later other types of mountable objects will occur. */ - loopdev = opt_loopdev; + *loopdev = opt_loopdev; - looptype = (type && strncmp("lo@", type, 3) == 0); + looptype = (*type && strncmp("lo@", *type, 3) == 0); if (looptype) { - if (loopdev) + if (*loopdev) error(_("mount: loop device specified twice")); - loopdev = type+3; - type = opt_vfstype; - } - else if (opt_vfstype) { - if (type) + *loopdev = *type + 3; + *type = opt_vfstype; + } else if (opt_vfstype) { + if (*type) error(_("mount: type specified twice")); else - type = opt_vfstype; + *type = opt_vfstype; } - loop = ((flags & MS_LOOP) || loopdev || opt_offset || opt_encryption); - loopfile = spec; + *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_encryption); + *loopfile = *spec; - if (loop) { - flags |= MS_LOOP; + if (*loop) { + *flags |= MS_LOOP; if (fake) { if (verbose) printf(_("mount: skipping the setup of a loop device\n")); } else { - int loopro = (flags & MS_RDONLY); + int loopro = (*flags & MS_RDONLY); - if (!loopdev || !*loopdev) - loopdev = find_unused_loop_device(); - if (!loopdev) + if (!*loopdev || !**loopdev) + *loopdev = find_unused_loop_device(); + if (!*loopdev) return EX_SYSERR; /* no more loop devices */ if (verbose) - printf(_("mount: going to use the loop device %s\n"), loopdev); + printf(_("mount: going to use the loop device %s\n"), *loopdev); offset = opt_offset ? strtoul(opt_offset, NULL, 0) : 0; - if (set_loop (loopdev, loopfile, offset, opt_encryption, &loopro)) { + if (set_loop (*loopdev, *loopfile, offset, opt_encryption, &loopro)) { if (verbose) printf(_("mount: failed setting up loop device\n")); return EX_FAIL; } if (verbose > 1) printf(_("mount: setup loop device successfully\n")); - spec = loopdev; + *spec = *loopdev; if (loopro) - flags |= MS_RDONLY; + *flags |= MS_RDONLY; } } - if (!fake && type && streq (type, "nfs")) { -#ifdef HAVE_NFS - mnt_err = nfsmount (spec, node, &flags, &extra_opts, &mount_opts, bg); - if (mnt_err) - return mnt_err; -#else - die (EX_SOFTWARE, _("mount: this version was compiled " - "without support for the type `nfs'")); -#endif - } + return 0; +} - /* - * Call mount.TYPE for types that require a separate - * mount program. For the moment these types are ncp and smb. - */ - if (type) +static void +update_mtab_entry(char *spec, char *node, char *type, char *opts, + int flags, int freq, int pass) { + struct mntentchn mcn; + struct mntent mnt; + + mcn.mnt_fsname = mnt.mnt_fsname = canonicalize (spec); + mcn.mnt_dir = mnt.mnt_dir = canonicalize (node); + mcn.mnt_type = mnt.mnt_type = type; + mcn.mnt_opts = mnt.mnt_opts = opts; + mcn.nxt = 0; + mnt.mnt_freq = freq; + mnt.mnt_passno = pass; + + /* We get chatty now rather than after the update to mtab since the + mount succeeded, even if the write to /etc/mtab should fail. */ + if (verbose) + print_one (&mcn); + + if (!nomtab && mtab_is_writable()) { + if (flags & MS_REMOUNT) + update_mtab (mnt.mnt_dir, &mnt); + else { + mntFILE *mfp; + + lock_mtab(); + mfp = my_setmntent(MOUNTED, "a+"); + if (mfp == NULL || mfp->mntent_fp == NULL) { + int errsv = errno; + error(_("mount: can't open %s: %s"), MOUNTED, + strerror (errsv)); + } else { + if ((my_addmntent (mfp, &mnt)) == 1) { + int errsv = errno; + error(_("mount: error writing %s: %s"), MOUNTED, + strerror (errsv)); + } + my_endmntent(mfp); + } + unlock_mtab(); + } + } +} + +static void +cdrom_setspeed(char *spec) { +#define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */ + if (opt_speed) { + int cdrom; + int speed = atoi(opt_speed); + + if ((cdrom = open(spec, O_RDONLY | O_NONBLOCK)) < 0) + die(EX_FAIL, _("mount: cannot not open %s for setting speed"), + spec); + if (ioctl(cdrom, CDROM_SELECT_SPEED, speed) < 0) + die(EX_FAIL, _("mount: cannot set speed: %s"), + strerror(errno)); + close(cdrom); + } +} + +/* + * check_special_mountprog() + * If there is a special mount program for this type, exec it. + * returns: 0: no exec was done, 1: exec was done, status has result + */ +static int +check_special_mountprog(char *spec, char *node, char *type, int flags, + char *extra_opts, int *status) { + char mountprog[120]; + struct stat statbuf; + int res; + + if (type && #ifndef ALWAYS_STAT - if (streq (type, "smb") || streq (type, "ncp") + (streq (type, "smb") || streq (type, "ncp") /* these are incorrect but perhaps used by smbmount or so */ || streq (type, "smbfs") || streq (type, "ncpfs") ) #else - if (strlen (type) < 100) + (strlen (type) < 100) #endif - { - char mountprog[120]; - + ) { sprintf(mountprog, "/sbin/mount.%s", type); if (stat(mountprog, &statbuf) == 0) { - int res; - if ((res = fork()) == 0) { + res = fork(); + if (res == 0) { char *oo, *mountargs[10]; int i = 0; @@ -602,63 +652,103 @@ try_mount_one (const char *spec0, const char *node0, char *type0, execv(mountprog, mountargs); exit(1); /* exec failed */ } else if (res != -1) { - int status; - wait(&status); - return status; + int st; + wait(&st); + *status = (WIFEXITED(st) ? WEXITSTATUS(st) : EX_SYSERR); + return 1; } else { int errsv = errno; error(_("mount: cannot fork: %s"), strerror(errsv)); } } } + return 0; +} + +/* + * try_mount_one() + * Try to mount one file system. When "bg" is 1, this is a retry + * in the background. One additional exit code EX_BG is used here. + * It is used to instruct the caller to retry the mount in the + * background. + * returns: 0: OK, EX_SYSERR, EX_FAIL, return code from nfsmount, + * return status from wait + */ +static int +try_mount_one (const char *spec0, const char *node0, char *type0, + const char *opts0, int freq, int pass, int bg, int ro) { + int res, status; + int mnt5_res = 0; /* only for gcc */ + int mnt_err; + int flags; + char *extra_opts; /* written in mtab */ + char *mount_opts; /* actually used on system call */ + const char *opts; + char *spec, *node, *type; + char *user = 0; + int loop = 0; + char *loopdev = 0, *loopfile = 0; + struct stat statbuf; + + spec = xstrdup(spec0); + node = xstrdup(node0); + type = xstrdup(type0); + opts = xstrdup(opts0); + + parse_opts (xstrdup (opts), &flags, &extra_opts); + + suid_check (spec, node, &flags, &user); + + /* quietly succeed for fstab entries that don't get mounted automatically */ + if (all && (flags & MS_NOAUTO)) + return 0; + + mount_opts = extra_opts; + + if (opt_speed) + cdrom_setspeed(spec); + + res = loop_check (&spec, &type, &flags, &loop, &loopdev, &loopfile); + if (res) + return res; + + /* + * Call mount.TYPE for types that require a separate mount program. + * For the moment these types are ncp and smb. + */ + if (check_special_mountprog (spec, node, type, flags, extra_opts, &status)) + return status; + + if (!fake && type && streq (type, "nfs")) { +#ifdef HAVE_NFS +retry_nfs: + mnt_err = nfsmount (spec, node, &flags, &extra_opts, &mount_opts, bg); + if (mnt_err) + return mnt_err; +#else + die (EX_SOFTWARE, _("mount: this version was compiled " + "without support for the type `nfs'")); +#endif + } block_signals (SIG_BLOCK); if (!fake) - mnt5_res = try_mount5 (spec, node, &type, flags & ~MS_NOSYS, mount_opts); + mnt5_res = guess_fstype_and_mount (spec, node, &type, flags & ~MS_NOSYS, + mount_opts); if (fake || mnt5_res == 0) { - /* Mount succeeded, report this (if verbose) and write mtab entry. */ + /* Mount succeeded, report this (if verbose) and write mtab entry. */ if (loop) opt_loopdev = loopdev; - mcn.mnt_fsname = mnt.mnt_fsname = canonicalize (loop ? loopfile : spec); - mcn.mnt_dir = mnt.mnt_dir = canonicalize (node); - mcn.mnt_type = mnt.mnt_type = type ? type : "unknown"; - mcn.mnt_opts = mnt.mnt_opts = fix_opts_string (flags & ~MS_NOMTAB, - extra_opts, user); - mcn.nxt = 0; - mnt.mnt_freq = freq; - mnt.mnt_passno = pass; - - /* We get chatty now rather than after the update to mtab since the - mount succeeded, even if the write to /etc/mtab should fail. */ - if (verbose) - print_one (&mcn); - - if (!nomtab && mtab_is_writable()) { - if (flags & MS_REMOUNT) - update_mtab (mnt.mnt_dir, &mnt); - else { - mntFILE *mfp; - - lock_mtab(); - mfp = my_setmntent(MOUNTED, "a+"); - if (mfp == NULL || mfp->mntent_fp == NULL) { - int errsv = errno; - error(_("mount: can't open %s: %s"), MOUNTED, - strerror (errsv)); - } else { - if ((my_addmntent (mfp, &mnt)) == 1) { - int errsv = errno; - error(_("mount: error writing %s: %s"), MOUNTED, - strerror (errsv)); - } - my_endmntent(mfp); - } - unlock_mtab(); - } - } + update_mtab_entry(loop ? loopfile : spec, + node, + type ? type : "unknown", + fix_opts_string (flags & ~MS_NOMTAB, extra_opts, user), + flags, + freq, + pass); block_signals (SIG_UNBLOCK); return 0; @@ -671,6 +761,18 @@ try_mount_one (const char *spec0, const char *node0, char *type0, block_signals (SIG_UNBLOCK); +#ifdef HAVE_NFS + if (mnt_err && type && streq (type, "nfs")) { + extern int nfs_mount_version; + if (nfs_mount_version == 4) { + if (verbose) + printf(_("mount: failed with nfs mount version 4, trying 3..\n")); + nfs_mount_version = 3; + goto retry_nfs; + } + } +#endif + /* Mount failed, complain, but don't die. */ if (type == 0) { @@ -799,10 +901,15 @@ try_mount_one (const char *spec0, const char *node0, char *type0, error (_("mount: %s is not a valid block device"), spec); break; case EACCES: /* pre-linux 1.1.38, 1.1.41 and later */ case EROFS: /* linux 1.1.38 and later */ + { char *bd = (loop ? "" : _("block device ")); if (ro) { - error (_("mount: block device %s is not permitted on its filesystem"), - spec); + error (_("mount: %s%s is not permitted on its filesystem"), + bd, spec); break; + } else if (readwrite) { + error (_("mount: %s%s is write-protected but explicit `-w' flag given"), + bd, spec); + break; } else { if (loop) { opts = opts0; @@ -817,10 +924,11 @@ try_mount_one (const char *spec0, const char *node0, char *type0, if (type && !strcmp(type, "guess")) type = 0; error (_("mount: %s%s is write-protected, mounting read-only"), - loop ? "" : _("block device "), spec0); + bd, spec0); return try_mount_one (spec0, node0, type, opts, freq, pass, bg, 1); } break; + } default: error ("mount: %s", strerror (mnt_err)); break; } @@ -950,6 +1058,15 @@ mount_one (const char *spec, const char *node, char *type, const char *opts, static int mounted (char *spec, char *node) { struct mntentchn *mc; + char *nspec = NULL; + + if (!strncmp(spec, "UUID=", 5)) + nspec = get_spec_by_uuid(spec+5); + else if (!strncmp(spec, "LABEL=", 6)) + nspec = get_spec_by_volume_label(spec+6); + + if (nspec) + spec = nspec; spec = canonicalize (spec); node = canonicalize (node); @@ -1102,7 +1219,7 @@ static struct option longopts[] = static void usage (FILE *fp, int n) { - fprintf (fp, _("Usage: mount [-hV]\n" + fprintf (fp, _("Usage: mount [-lhV]\n" " mount -a [-nfFrsvw] [-t vfstypes]\n" " mount [-nfrsvw] [-o options] special | node\n" " mount [-nfrsvw] [-t vfstype] [-o options] special node\n" @@ -1136,7 +1253,7 @@ main (int argc, char *argv[]) { initproctitle(argc, argv); #endif - while ((c = getopt_long (argc, argv, "afFhL:no:rsU:vVwt:", longopts, NULL)) + while ((c = getopt_long (argc, argv, "afFhlL:no:rsU:vVwt:", longopts, NULL)) != EOF) switch (c) { case 'a': /* mount everything in fstab */ @@ -1151,6 +1268,9 @@ main (int argc, char *argv[]) { case 'h': /* help */ usage (stdout, 0); break; + case 'l': + list_with_volumelabel = 1; + break; case 'L': volumelabel = optarg; break; diff --git a/mount/mount_by_label.c b/mount/mount_by_label.c index be37496f..1567bfb1 100644 --- a/mount/mount_by_label.c +++ b/mount/mount_by_label.c @@ -1,5 +1,12 @@ -/* 1999-02-22 Arkadiusz Mi¶kiewicz +/* + * mount_by_label.c - aeb + * + * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support + * 2000-01-20 James Antill + * - Added error message if /proc/partitions cannot be opened + * 2000-05-09 Erik Troan + * - Added cache for UUID and disk labels */ #include @@ -15,98 +22,143 @@ #define PROC_PARTITIONS "/proc/partitions" #define DEVLABELDIR "/dev" -static FILE *procpt; - -static void -procptclose(void) { - if (procpt) - fclose (procpt); - procpt = 0; -} - -static int -procptopen(void) { - return ((procpt = fopen(PROC_PARTITIONS, "r")) != NULL); -} - -static char * -procptnext(void) { - char line[100]; - char *s; - int ma, mi, sz; - static char ptname[100]; - - while (fgets(line, sizeof(line), procpt)) { - if (sscanf (line, " %d %d %d %[^\n]\n", &ma, &mi, &sz, ptname) != 4) - continue; - - /* skip extended partitions (heuristic: size 1) */ - if (sz == 1) - continue; - - /* skip entire disk (minor 0, 64, ... on ide; 0, 16, ... on sd) */ - /* heuristic: partition name ends in a digit */ - for(s = ptname; *s; s++); - if (isdigit(s[-1])) - return ptname; - } - return 0; -} - -#define UUID 1 -#define VOL 2 +static struct uuidCache_s { + struct uuidCache_s *next; + char uuid[16]; + char *label; + char *device; +} *uuidCache = NULL; /* for now, only ext2 is supported */ static int -has_right_label(const char *device, int n, const char *label) { +get_label_uuid(const char *device, char **label, char *uuid) { /* start with a test for ext2, taken from mount_guess_fstype */ /* should merge these later */ int fd; - char *s; struct ext2_super_block e2sb; fd = open(device, O_RDONLY); if (fd < 0) - return 0; + return 1; if (lseek(fd, 1024, SEEK_SET) != 1024 || read(fd, (char *) &e2sb, sizeof(e2sb)) != sizeof(e2sb) || (ext2magic(e2sb) != EXT2_SUPER_MAGIC)) { close(fd); - return 0; + return 1; } close(fd); /* superblock is ext2 - now what is its label? */ - s = ((n == UUID) ? e2sb.s_uuid : e2sb.s_volume_name); - return (strncmp(s, label, 16) == 0); + memcpy(uuid, e2sb.s_uuid, sizeof(e2sb.s_uuid)); + *label = strdup(e2sb.s_volume_name); + + return 0; } -static char * -get_spec_by_x(int n, const char *t) { - char *pt; +static void +uuidcache_addentry(char *device, char *label, char *uuid) { + struct uuidCache_s *last; + + if (!uuidCache) { + last = uuidCache = malloc(sizeof(*uuidCache)); + } else { + for (last = uuidCache; last->next; last = last->next) ; + last->next = malloc(sizeof(*uuidCache)); + last = last->next; + } + last->next = NULL; + last->device = device; + last->label = label; + memcpy(last->uuid, uuid, sizeof(last->uuid)); +} + +static void +uuidcache_init(void) { + char line[100]; + char *s; + int ma, mi, sz; + static char ptname[100]; + FILE *procpt; + char uuid[16], *label; char device[110]; + int firstPass; + int handleOnFirst; + + if (uuidCache) + return; + + procpt = fopen(PROC_PARTITIONS, "r"); + if (!procpt) + return; + + for (firstPass = 1; firstPass >= 0; firstPass--) { + fseek(procpt, 0, SEEK_SET); + + while (fgets(line, sizeof(line), procpt)) { + if (sscanf (line, " %d %d %d %[^\n ]", + &ma, &mi, &sz, ptname) != 4) + continue; + + /* skip extended partitions (heuristic: size 1) */ + if (sz == 1) + continue; + + /* look only at md devices on first pass */ + handleOnFirst = !strncmp(ptname, "md", 2); + if (firstPass != handleOnFirst) + continue; + + /* skip entire disk (minor 0, 64, ... on ide; + 0, 16, ... on sd) */ + /* heuristic: partition name ends in a digit */ + + for(s = ptname; *s; s++); + if (isdigit(s[-1])) { + /* + * Note: this is a heuristic only - there is no reason + * why these devices should live in /dev. + * Perhaps this directory should be specifiable by option. + * One might for example have /devlabel with links to /dev + * for the devices that may be accessed in this way. + * (This is useful, if the cdrom on /dev/hdc must not + * be accessed.) + */ + sprintf(device, "%s/%s", DEVLABELDIR, ptname); + if (!get_label_uuid(device, &label, uuid)) + uuidcache_addentry(strdup(device), label, uuid); + } + } + } + + fclose(procpt); +} - if(!procptopen()) - return NULL; - while((pt = procptnext()) != NULL) { - /* Note: this is a heuristic only - there is no reason - why these devices should live in /dev. - Perhaps this directory should be specifiable by option. - One might for example have /devlabel with links to /dev - for the devices that may be accessed in this way. - (This is useful, if the cdrom on /dev/hdc must not - be accessed.) - */ - sprintf(device, "%s/%s", DEVLABELDIR, pt); - if (has_right_label(device, n, t)) { - procptclose(); - return xstrdup(device); +#define UUID 1 +#define VOL 2 + +static char * +get_spec_by_x(int n, const char *t) { + struct uuidCache_s *uc; + + uuidcache_init(); + uc = uuidCache; + + while(uc) { + switch (n) { + case UUID: + if (!memcmp(t, uc->uuid, sizeof(uc->uuid))) + return xstrdup(uc->device); + break; + case VOL: + if (!strcmp(t, uc->label)) + return xstrdup(uc->device); + break; } + uc = uc->next; } - procptclose(); return NULL; } @@ -147,3 +199,17 @@ get_spec_by_volume_label(const char *s) { return get_spec_by_x(VOL, s); } +const char * +get_volume_label_by_spec(const char *spec) { + struct uuidCache_s *uc; + + uuidcache_init(); + uc = uuidCache; + + while(uc) { + if (!strcmp(spec, uc->device)) + return uc->label; + uc = uc->next; + } + return NULL; +} diff --git a/mount/mount_by_label.h b/mount/mount_by_label.h index 21c2d844..64bbbfa7 100644 --- a/mount/mount_by_label.h +++ b/mount/mount_by_label.h @@ -1,2 +1,3 @@ char *get_spec_by_uuid(const char *uuid); char *get_spec_by_volume_label(const char *volumelabel); +const char *get_volume_label_by_spec(const char *spec); diff --git a/mount/mount_guess_fstype.c b/mount/mount_guess_fstype.c index 9e3a54a4..ec39c531 100644 --- a/mount/mount_guess_fstype.c +++ b/mount/mount_guess_fstype.c @@ -72,13 +72,14 @@ swapped(unsigned short a) { Added a very weak heuristic for vfat - aeb Added qnx4 - aeb Added swap - aeb + Added xfs - 2000-03-21 Martin K. Petersen Currently supports: minix, ext, ext2, xiafs, iso9660, romfs, - ufs, ntfs, vfat, qnx4, bfs + ufs, ntfs, vfat, qnx4, bfs, xfs */ static char *magic_known[] = { "minix", "ext", "ext2", "xiafs", "iso9660", "romfs", - "ufs", "ntfs", "qnx4", "bfs", "udf", + "ufs", "ntfs", "qnx4", "bfs", "udf", "xfs", "swap" /* last - just to warn the user */ }; @@ -130,6 +131,7 @@ fstype(const char *device) { union { struct xiafs_super_block xiasb; char romfs_magic[8]; + char xfs_magic[4]; char qnx4fs_magic[10]; /* ignore first 4 bytes */ long bfs_magic; struct ntfs_super_block ntfssb; @@ -177,6 +179,9 @@ fstype(const char *device) { type = "xiafs"; else if(!strncmp(xsb.romfs_magic, "-rom1fs-", 8)) type = "romfs"; + else if(!strncmp(xsb.xfs_magic, "XFSB", 4) || + !strncmp(xsb.xfs_magic, "BSFX", 4)) + type = "xfs"; else if(!strncmp(xsb.qnx4fs_magic+4, "QNX4FS", 6)) type = "qnx4fs"; else if(xsb.bfs_magic == 0x1badface) @@ -187,7 +192,8 @@ fstype(const char *device) { else if ((!strncmp(xsb.fatsb.s_os, "MSDOS", 5) || !strncmp(xsb.fatsb.s_os, "MSWIN", 5) || !strncmp(xsb.fatsb.s_os, "MTOOL", 5) || - !strncmp(xsb.fatsb.s_os, "mkdosfs", 7)) + !strncmp(xsb.fatsb.s_os, "mkdosfs", 7) || + !strncmp(xsb.fatsb.s_os, "kmkdosfs", 8)) && (!strncmp(xsb.fatsb.s_fs, "FAT12 ", 8) || !strncmp(xsb.fatsb.s_fs, "FAT16 ", 8) || !strncmp(xsb.fatsb.s_fs2, "FAT32 ", 8))) diff --git a/mount/nfs_mount4.h b/mount/nfs_mount4.h new file mode 100644 index 00000000..0e3b052b --- /dev/null +++ b/mount/nfs_mount4.h @@ -0,0 +1,53 @@ +/* + * We want to be able to compile mount on old kernels in such a way + * that the binary will work well on more recent kernels. + * Thus, if necessary we teach nfsmount.c the structure of new fields + * that will come later. + * + * Moreover, the new kernel includes conflict with glibc includes + * so it is easiest to ignore the kernel altogether (at compile time). + */ + +#define NFS_MOUNT_VERSION 4 + +struct nfs2_fh { + char data[32]; +}; +struct nfs3_fh { + unsigned short size; + unsigned char data[64]; +}; + +struct nfs_mount_data { + int version; /* 1 */ + int fd; /* 1 */ + struct nfs2_fh old_root; /* 1 */ + int flags; /* 1 */ + int rsize; /* 1 */ + int wsize; /* 1 */ + int timeo; /* 1 */ + int retrans; /* 1 */ + int acregmin; /* 1 */ + int acregmax; /* 1 */ + int acdirmin; /* 1 */ + int acdirmax; /* 1 */ + struct sockaddr_in addr; /* 1 */ + char hostname[256]; /* 1 */ + int namlen; /* 2 */ + unsigned int bsize; /* 3 */ + struct nfs3_fh root; /* 4 */ +}; + +/* bits in the flags field */ + +#define NFS_MOUNT_SOFT 0x0001 /* 1 */ +#define NFS_MOUNT_INTR 0x0002 /* 1 */ +#define NFS_MOUNT_SECURE 0x0004 /* 1 */ +#define NFS_MOUNT_POSIX 0x0008 /* 1 */ +#define NFS_MOUNT_NOCTO 0x0010 /* 1 */ +#define NFS_MOUNT_NOAC 0x0020 /* 1 */ +#define NFS_MOUNT_TCP 0x0040 /* 2 */ +#define NFS_MOUNT_VER3 0x0080 /* 3 */ +#define NFS_MOUNT_KERBEROS 0x0100 /* 3 */ +#define NFS_MOUNT_NONLM 0x0200 /* 3 */ + diff --git a/mount/nfs_mount3.h b/mount/nfs_mount4.h.sv similarity index 77% rename from mount/nfs_mount3.h rename to mount/nfs_mount4.h.sv index e5c2b2fe..f3111d78 100644 --- a/mount/nfs_mount3.h +++ b/mount/nfs_mount4.h.sv @@ -6,7 +6,7 @@ */ #include "nfs_mountversion.h" -#if KERNEL_NFS_MOUNT_VERSION >= 3 +#if KERNEL_NFS_MOUNT_VERSION >= 4 /* * The kernel includes are at least as good as this file. @@ -14,18 +14,31 @@ */ #include -#else /* KERNEL_NFS_MOUNT_VERSION < 3 */ +#define NFS_FHSIZE 32 +#define NFS_PORT 2049 +#define NFS_VERSION 2 + + +#else /* KERNEL_NFS_MOUNT_VERSION < 4 */ /* * We know more than the kernel. Override the kernel defines. * Check at runtime whether the running kernel can handle the new stuff. */ -#define NFS_MOUNT_VERSION 3 +#define NFS_MOUNT_VERSION 4 + +struct nfs2_fh { + char data[32]; +}; +struct nfs3_fh { + unsigned short size; + unsigned char data[64]; +}; struct nfs_mount_data { int version; /* 1 */ int fd; /* 1 */ - struct nfs_fh root; /* 1 */ + struct nfs2_fh old_root; /* 1 */ int flags; /* 1 */ int rsize; /* 1 */ int wsize; /* 1 */ @@ -39,6 +52,7 @@ struct nfs_mount_data { char hostname[256]; /* 1 */ int namlen; /* 2 */ unsigned int bsize; /* 3 */ + struct nfs3_fh root; /* 4 */ }; /* bits in the flags field */ diff --git a/mount/nfsmount.c b/mount/nfsmount.c index 9500ec29..bf4be636 100644 --- a/mount/nfsmount.c +++ b/mount/nfsmount.c @@ -24,6 +24,8 @@ * 1999-02-22 Arkadiusz Mi¶kiewicz * - added Native Language Support * + * Modified by Olaf Kirch and Trond Myklebust for new NFS code, + * plus NFSv3 stuff. */ /* @@ -50,7 +52,8 @@ #include #include "mount_constants.h" -#include "nfs_mount3.h" +#include "nfs_mount4.h" + #include "nls.h" #include "../defines.h" /* for HAVE_inet_aton */ @@ -59,6 +62,8 @@ static char *nfs_strerror(int stat); #define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r)) +#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2) + static int linux_version_code(void) { struct utsname my_utsname; @@ -74,9 +79,9 @@ linux_version_code(void) { } /* - * nfs_mount_version according to the kernel sources seen at compile time. + * nfs_mount_version according to the sources seen at compile time. */ -static int nfs_mount_version = KERNEL_NFS_MOUNT_VERSION; +int nfs_mount_version = NFS_MOUNT_VERSION; /* * Unfortunately, the kernel prints annoying console messages @@ -91,18 +96,73 @@ static int nfs_mount_version = KERNEL_NFS_MOUNT_VERSION; */ static void find_kernel_nfs_mount_version(void) { - int kernel_version = linux_version_code(); + static int kernel_version = 0; + + if (kernel_version) + return; + + kernel_version = linux_version_code(); if (kernel_version) { if (kernel_version < MAKE_VERSION(2,1,32)) nfs_mount_version = 1; - else + else if (kernel_version < MAKE_VERSION(2,3,99)) nfs_mount_version = 3; + else + nfs_mount_version = 4; /* since 2.3.99pre4 */ } if (nfs_mount_version > NFS_MOUNT_VERSION) nfs_mount_version = NFS_MOUNT_VERSION; } +static struct pmap * +get_mountport(struct sockaddr_in *server_addr, + long unsigned prog, + long unsigned version, + long unsigned proto, + long unsigned port) +{ +struct pmaplist *pmap; +static struct pmap p = {0, 0, 0, 0}; + +server_addr->sin_port = PMAPPORT; +pmap = pmap_getmaps(server_addr); + +if (version > MAX_NFSPROT) + version = MAX_NFSPROT; +if (!prog) + prog = MOUNTPROG; +p.pm_prog = prog; +p.pm_vers = version; +p.pm_prot = proto; +p.pm_port = port; + +while (pmap) { + if (pmap->pml_map.pm_prog != prog) + goto next; + if (!version && p.pm_vers > pmap->pml_map.pm_vers) + goto next; + if (version > 2 && pmap->pml_map.pm_vers != version) + goto next; + if (version && version <= 2 && pmap->pml_map.pm_vers > 2) + goto next; + if (pmap->pml_map.pm_vers > MAX_NFSPROT || + (proto && p.pm_prot && pmap->pml_map.pm_prot != proto) || + (port && pmap->pml_map.pm_port != port)) + goto next; + memcpy(&p, &pmap->pml_map, sizeof(p)); +next: + pmap = pmap->pml_next; +} +if (!p.pm_vers) + p.pm_vers = MOUNTVERS; +if (!p.pm_port) + p.pm_port = MOUNTPORT; +if (!p.pm_prot) + p.pm_prot = IPPROTO_TCP; +return &p; +} + int nfsmount(const char *spec, const char *node, int *flags, char **extra_opts, char **mount_opts, int running_bg) { @@ -114,7 +174,6 @@ int nfsmount(const char *spec, const char *node, int *flags, char *old_opts; char *mounthost=NULL; char new_opts[1024]; - fhandle root_fhandle; struct timeval total_timeout; enum clnt_stat clnt_stat; static struct nfs_mount_data data; @@ -123,13 +182,18 @@ int nfsmount(const char *spec, const char *node, int *flags, struct hostent *hp; struct sockaddr_in server_addr; struct sockaddr_in mount_server_addr; + struct pmap* pm_mnt; int msock, fsock; struct timeval retry_timeout; - struct fhstatus status; + union { + struct fhstatus nfsv2; + struct mountres3 nfsv3; + } status; struct stat statbuf; char *s; int port; int mountport; + int proto; int bg; int soft; int intr; @@ -238,11 +302,11 @@ int nfsmount(const char *spec, const char *node, int *flags, tcp = 0; mountprog = MOUNTPROG; - mountvers = MOUNTVERS; + mountvers = 0; port = 0; mountport = 0; nfsprog = NFS_PROGRAM; - nfsvers = NFS_VERSION; + nfsvers = 0; /* parse options */ @@ -352,6 +416,8 @@ int nfsmount(const char *spec, const char *node, int *flags, } } } + proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP; + data.flags = (soft ? NFS_MOUNT_SOFT : 0) | (intr ? NFS_MOUNT_INTR : 0) | (posix ? NFS_MOUNT_POSIX : 0) @@ -365,6 +431,19 @@ int nfsmount(const char *spec, const char *node, int *flags, if (nfs_mount_version >= 3) data.flags |= (nolock ? NFS_MOUNT_NONLM : 0); #endif + if (nfsvers > MAX_NFSPROT) { + fprintf(stderr, "NFSv%d not supported!\n", nfsvers); + return 0; + } + if (mountvers > MAX_NFSPROT) { + fprintf(stderr, "NFSv%d not supported!\n", nfsvers); + return 0; + } + if (nfsvers && !mountvers) + mountvers = (nfsvers < 3) ? 1 : nfsvers; + if (nfsvers && nfsvers < mountvers) { + mountvers = nfsvers; + } /* Adjust options if none specified */ if (!data.timeo) @@ -470,28 +549,60 @@ int nfsmount(const char *spec, const char *node, int *flags, if (t - prevt < 30) sleep(30); + pm_mnt = get_mountport(&mount_server_addr, + mountprog, + mountvers, + proto, + mountport); + /* contact the mount daemon via TCP */ - mount_server_addr.sin_port = htons(mountport); + mount_server_addr.sin_port = htons(pm_mnt->pm_port); msock = RPC_ANYSOCK; - mclient = clnttcp_create(&mount_server_addr, - mountprog, mountvers, - &msock, 0, 0); - /* if this fails, contact the mount daemon via UDP */ - if (!mclient) { - mount_server_addr.sin_port = htons(mountport); - msock = RPC_ANYSOCK; + switch (pm_mnt->pm_prot) { + case IPPROTO_UDP: mclient = clntudp_create(&mount_server_addr, - mountprog, mountvers, - retry_timeout, &msock); + pm_mnt->pm_prog, + pm_mnt->pm_vers, + retry_timeout, + &msock); + if (mclient) + break; + mount_server_addr.sin_port = htons(pm_mnt->pm_port); + msock = RPC_ANYSOCK; + case IPPROTO_TCP: + mclient = clnttcp_create(&mount_server_addr, + pm_mnt->pm_prog, + pm_mnt->pm_vers, + &msock, 0, 0); + break; + default: + mclient = 0; } if (mclient) { /* try to mount hostname:dirname */ mclient->cl_auth = authunix_create_default(); - clnt_stat = clnt_call(mclient, MOUNTPROC_MNT, - (xdrproc_t) xdr_dirpath, (caddr_t) &dirname, - (xdrproc_t) xdr_fhstatus, (caddr_t) &status, + + /* make pointers in xdr_mountres3 NULL so + * that xdr_array allocates memory for us + */ + memset(&status, 0, sizeof(status)); + + if (pm_mnt->pm_vers == 3) + clnt_stat = clnt_call(mclient, MOUNTPROC3_MNT, + (xdrproc_t) xdr_dirpath, + (caddr_t) &dirname, + (xdrproc_t) xdr_mountres3, + (caddr_t) &status, total_timeout); + else + clnt_stat = clnt_call(mclient, MOUNTPROC_MNT, + (xdrproc_t) xdr_dirpath, + (caddr_t) &dirname, + (xdrproc_t) xdr_fhstatus, + (caddr_t) &status, + total_timeout); + if (clnt_stat == RPC_SUCCESS) break; /* we're done */ if (errno != ECONNREFUSED) { @@ -522,15 +633,46 @@ int nfsmount(const char *spec, const char *node, int *flags, if (t >= timeout) goto fail; } - - if (status.fhs_status != 0) { - fprintf(stderr, - _("mount: %s:%s failed, reason given by server: %s\n"), - hostname, dirname, nfs_strerror(status.fhs_status)); - goto fail; + nfsvers = (pm_mnt->pm_vers < 2) ? 2 : pm_mnt->pm_vers; + + if (nfsvers == 2) { + if (status.nfsv2.fhs_status != 0) { + fprintf(stderr, + "mount: %s:%s failed, reason given by server: %s\n", + hostname, dirname, + nfs_strerror(status.nfsv2.fhs_status)); + goto fail; + } + memcpy(data.root.data, + (char *) status.nfsv2.fhstatus_u.fhs_fhandle, + NFS_FHSIZE); +#if NFS_MOUNT_VERSION >= 4 + data.root.size = NFS_FHSIZE; + memcpy(data.old_root.data, + (char *) status.nfsv2.fhstatus_u.fhs_fhandle, + NFS_FHSIZE); +#endif + } else { +#if NFS_MOUNT_VERSION >= 4 + fhandle3 *fhandle; + if (status.nfsv3.fhs_status != 0) { + fprintf(stderr, + "mount: %s:%s failed, reason given by server: %s\n", + hostname, dirname, + nfs_strerror(status.nfsv3.fhs_status)); + goto fail; + } + fhandle = &status.nfsv3.mountres3_u.mountinfo.fhandle; + memset(data.old_root.data, 0, NFS_FHSIZE); + memset(&data.root, 0, sizeof(data.root)); + data.root.size = fhandle->fhandle3_len; + memcpy(data.root.data, + (char *) fhandle->fhandle3_val, + fhandle->fhandle3_len); + + data.flags |= NFS_MOUNT_VER3; +#endif } - memcpy((char *) &root_fhandle, (char *) status.fhstatus_u.fhs_fhandle, - sizeof (root_fhandle)); /* create nfs socket for kernel */ @@ -580,8 +722,6 @@ int nfsmount(const char *spec, const char *node, int *flags, /* prepare data structure for kernel */ data.fd = fsock; - memcpy((char *) &data.root, (char *) &root_fhandle, - sizeof (root_fhandle)); memcpy((char *) &data.addr, (char *) &server_addr, sizeof(data.addr)); strncpy(data.hostname, hostname, sizeof(data.hostname)); diff --git a/mount/nfsmount.h b/mount/nfsmount.h deleted file mode 100644 index 73c71fc6..00000000 --- a/mount/nfsmount.h +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Please do not edit this file. - * It was generated using rpcgen. - */ - -#ifndef _NFSMOUNT_H_RPCGEN -#define _NFSMOUNT_H_RPCGEN - -#include - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user or with the express written consent of - * Sun Microsystems, Inc. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Copyright (c) 1985, 1990 by Sun Microsystems, Inc. - */ - -/* from @(#)mount.x 1.3 91/03/11 TIRPC 1.0 */ -#ifndef _rpcsvc_mount_h -#define _rpcsvc_mount_h -#define MNTPATHLEN 1024 -#define MNTNAMLEN 255 -#define FHSIZE 32 - -typedef char fhandle[FHSIZE]; -#ifdef __cplusplus -extern "C" bool_t xdr_fhandle(XDR *, fhandle); -#elif __STDC__ -extern bool_t xdr_fhandle(XDR *, fhandle); -#else /* Old Style C */ -bool_t xdr_fhandle(); -#endif /* Old Style C */ - - -struct fhstatus { - u_int fhs_status; - union { - fhandle fhs_fhandle; - } fhstatus_u; -}; -typedef struct fhstatus fhstatus; -#ifdef __cplusplus -extern "C" bool_t xdr_fhstatus(XDR *, fhstatus*); -#elif __STDC__ -extern bool_t xdr_fhstatus(XDR *, fhstatus*); -#else /* Old Style C */ -bool_t xdr_fhstatus(); -#endif /* Old Style C */ - - -typedef char *dirpath; -#ifdef __cplusplus -extern "C" bool_t xdr_dirpath(XDR *, dirpath*); -#elif __STDC__ -extern bool_t xdr_dirpath(XDR *, dirpath*); -#else /* Old Style C */ -bool_t xdr_dirpath(); -#endif /* Old Style C */ - - -typedef char *name; -#ifdef __cplusplus -extern "C" bool_t xdr_name(XDR *, name*); -#elif __STDC__ -extern bool_t xdr_name(XDR *, name*); -#else /* Old Style C */ -bool_t xdr_name(); -#endif /* Old Style C */ - - -typedef struct mountbody *mountlist; -#ifdef __cplusplus -extern "C" bool_t xdr_mountlist(XDR *, mountlist*); -#elif __STDC__ -extern bool_t xdr_mountlist(XDR *, mountlist*); -#else /* Old Style C */ -bool_t xdr_mountlist(); -#endif /* Old Style C */ - - -struct mountbody { - name ml_hostname; - dirpath ml_directory; - mountlist ml_next; -}; -typedef struct mountbody mountbody; -#ifdef __cplusplus -extern "C" bool_t xdr_mountbody(XDR *, mountbody*); -#elif __STDC__ -extern bool_t xdr_mountbody(XDR *, mountbody*); -#else /* Old Style C */ -bool_t xdr_mountbody(); -#endif /* Old Style C */ - - -typedef struct groupnode *groups; -#ifdef __cplusplus -extern "C" bool_t xdr_groups(XDR *, groups*); -#elif __STDC__ -extern bool_t xdr_groups(XDR *, groups*); -#else /* Old Style C */ -bool_t xdr_groups(); -#endif /* Old Style C */ - - -struct groupnode { - name gr_name; - groups gr_next; -}; -typedef struct groupnode groupnode; -#ifdef __cplusplus -extern "C" bool_t xdr_groupnode(XDR *, groupnode*); -#elif __STDC__ -extern bool_t xdr_groupnode(XDR *, groupnode*); -#else /* Old Style C */ -bool_t xdr_groupnode(); -#endif /* Old Style C */ - - -typedef struct exportnode *exports; -#ifdef __cplusplus -extern "C" bool_t xdr_exports(XDR *, exports*); -#elif __STDC__ -extern bool_t xdr_exports(XDR *, exports*); -#else /* Old Style C */ -bool_t xdr_exports(); -#endif /* Old Style C */ - - -struct exportnode { - dirpath ex_dir; - groups ex_groups; - exports ex_next; -}; -typedef struct exportnode exportnode; -#ifdef __cplusplus -extern "C" bool_t xdr_exportnode(XDR *, exportnode*); -#elif __STDC__ -extern bool_t xdr_exportnode(XDR *, exportnode*); -#else /* Old Style C */ -bool_t xdr_exportnode(); -#endif /* Old Style C */ - - -struct ppathcnf { - int pc_link_max; - short pc_max_canon; - short pc_max_input; - short pc_name_max; - short pc_path_max; - short pc_pipe_buf; - u_char pc_vdisable; - char pc_xxx; - short pc_mask[2]; -}; -typedef struct ppathcnf ppathcnf; -#ifdef __cplusplus -extern "C" bool_t xdr_ppathcnf(XDR *, ppathcnf*); -#elif __STDC__ -extern bool_t xdr_ppathcnf(XDR *, ppathcnf*); -#else /* Old Style C */ -bool_t xdr_ppathcnf(); -#endif /* Old Style C */ - -#endif /*!_rpcsvc_mount_h*/ - -#define MOUNTPROG ((u_long)100005) -#define MOUNTVERS ((u_long)1) - -#ifdef __cplusplus -#define MOUNTPROC_NULL ((u_long)0) -extern "C" void * mountproc_null_1(void *, CLIENT *); -extern "C" void * mountproc_null_1_svc(void *, struct svc_req *); -#define MOUNTPROC_MNT ((u_long)1) -extern "C" fhstatus * mountproc_mnt_1(dirpath *, CLIENT *); -extern "C" fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *); -#define MOUNTPROC_DUMP ((u_long)2) -extern "C" mountlist * mountproc_dump_1(void *, CLIENT *); -extern "C" mountlist * mountproc_dump_1_svc(void *, struct svc_req *); -#define MOUNTPROC_UMNT ((u_long)3) -extern "C" void * mountproc_umnt_1(dirpath *, CLIENT *); -extern "C" void * mountproc_umnt_1_svc(dirpath *, struct svc_req *); -#define MOUNTPROC_UMNTALL ((u_long)4) -extern "C" void * mountproc_umntall_1(void *, CLIENT *); -extern "C" void * mountproc_umntall_1_svc(void *, struct svc_req *); -#define MOUNTPROC_EXPORT ((u_long)5) -extern "C" exports * mountproc_export_1(void *, CLIENT *); -extern "C" exports * mountproc_export_1_svc(void *, struct svc_req *); -#define MOUNTPROC_EXPORTALL ((u_long)6) -extern "C" exports * mountproc_exportall_1(void *, CLIENT *); -extern "C" exports * mountproc_exportall_1_svc(void *, struct svc_req *); - -#elif __STDC__ -#define MOUNTPROC_NULL ((u_long)0) -extern void * mountproc_null_1(void *, CLIENT *); -extern void * mountproc_null_1_svc(void *, struct svc_req *); -#define MOUNTPROC_MNT ((u_long)1) -extern fhstatus * mountproc_mnt_1(dirpath *, CLIENT *); -extern fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *); -#define MOUNTPROC_DUMP ((u_long)2) -extern mountlist * mountproc_dump_1(void *, CLIENT *); -extern mountlist * mountproc_dump_1_svc(void *, struct svc_req *); -#define MOUNTPROC_UMNT ((u_long)3) -extern void * mountproc_umnt_1(dirpath *, CLIENT *); -extern void * mountproc_umnt_1_svc(dirpath *, struct svc_req *); -#define MOUNTPROC_UMNTALL ((u_long)4) -extern void * mountproc_umntall_1(void *, CLIENT *); -extern void * mountproc_umntall_1_svc(void *, struct svc_req *); -#define MOUNTPROC_EXPORT ((u_long)5) -extern exports * mountproc_export_1(void *, CLIENT *); -extern exports * mountproc_export_1_svc(void *, struct svc_req *); -#define MOUNTPROC_EXPORTALL ((u_long)6) -extern exports * mountproc_exportall_1(void *, CLIENT *); -extern exports * mountproc_exportall_1_svc(void *, struct svc_req *); - -#else /* Old Style C */ -#define MOUNTPROC_NULL ((u_long)0) -extern void * mountproc_null_1(); -extern void * mountproc_null_1_svc(); -#define MOUNTPROC_MNT ((u_long)1) -extern fhstatus * mountproc_mnt_1(); -extern fhstatus * mountproc_mnt_1_svc(); -#define MOUNTPROC_DUMP ((u_long)2) -extern mountlist * mountproc_dump_1(); -extern mountlist * mountproc_dump_1_svc(); -#define MOUNTPROC_UMNT ((u_long)3) -extern void * mountproc_umnt_1(); -extern void * mountproc_umnt_1_svc(); -#define MOUNTPROC_UMNTALL ((u_long)4) -extern void * mountproc_umntall_1(); -extern void * mountproc_umntall_1_svc(); -#define MOUNTPROC_EXPORT ((u_long)5) -extern exports * mountproc_export_1(); -extern exports * mountproc_export_1_svc(); -#define MOUNTPROC_EXPORTALL ((u_long)6) -extern exports * mountproc_exportall_1(); -extern exports * mountproc_exportall_1_svc(); -#endif /* Old Style C */ -#define MOUNTVERS_POSIX ((u_long)2) - -#ifdef __cplusplus -extern "C" void * mountproc_null_2(void *, CLIENT *); -extern "C" void * mountproc_null_2_svc(void *, struct svc_req *); -extern "C" fhstatus * mountproc_mnt_2(dirpath *, CLIENT *); -extern "C" fhstatus * mountproc_mnt_2_svc(dirpath *, struct svc_req *); -extern "C" mountlist * mountproc_dump_2(void *, CLIENT *); -extern "C" mountlist * mountproc_dump_2_svc(void *, struct svc_req *); -extern "C" void * mountproc_umnt_2(dirpath *, CLIENT *); -extern "C" void * mountproc_umnt_2_svc(dirpath *, struct svc_req *); -extern "C" void * mountproc_umntall_2(void *, CLIENT *); -extern "C" void * mountproc_umntall_2_svc(void *, struct svc_req *); -extern "C" exports * mountproc_export_2(void *, CLIENT *); -extern "C" exports * mountproc_export_2_svc(void *, struct svc_req *); -extern "C" exports * mountproc_exportall_2(void *, CLIENT *); -extern "C" exports * mountproc_exportall_2_svc(void *, struct svc_req *); -#define MOUNTPROC_PATHCONF ((u_long)7) -extern "C" ppathcnf * mountproc_pathconf_2(dirpath *, CLIENT *); -extern "C" ppathcnf * mountproc_pathconf_2_svc(dirpath *, struct svc_req *); - -#elif __STDC__ -extern void * mountproc_null_2(void *, CLIENT *); -extern void * mountproc_null_2_svc(void *, struct svc_req *); -extern fhstatus * mountproc_mnt_2(dirpath *, CLIENT *); -extern fhstatus * mountproc_mnt_2_svc(dirpath *, struct svc_req *); -extern mountlist * mountproc_dump_2(void *, CLIENT *); -extern mountlist * mountproc_dump_2_svc(void *, struct svc_req *); -extern void * mountproc_umnt_2(dirpath *, CLIENT *); -extern void * mountproc_umnt_2_svc(dirpath *, struct svc_req *); -extern void * mountproc_umntall_2(void *, CLIENT *); -extern void * mountproc_umntall_2_svc(void *, struct svc_req *); -extern exports * mountproc_export_2(void *, CLIENT *); -extern exports * mountproc_export_2_svc(void *, struct svc_req *); -extern exports * mountproc_exportall_2(void *, CLIENT *); -extern exports * mountproc_exportall_2_svc(void *, struct svc_req *); -#define MOUNTPROC_PATHCONF ((u_long)7) -extern ppathcnf * mountproc_pathconf_2(dirpath *, CLIENT *); -extern ppathcnf * mountproc_pathconf_2_svc(dirpath *, struct svc_req *); - -#else /* Old Style C */ -extern void * mountproc_null_2(); -extern void * mountproc_null_2_svc(); -extern fhstatus * mountproc_mnt_2(); -extern fhstatus * mountproc_mnt_2_svc(); -extern mountlist * mountproc_dump_2(); -extern mountlist * mountproc_dump_2_svc(); -extern void * mountproc_umnt_2(); -extern void * mountproc_umnt_2_svc(); -extern void * mountproc_umntall_2(); -extern void * mountproc_umntall_2_svc(); -extern exports * mountproc_export_2(); -extern exports * mountproc_export_2_svc(); -extern exports * mountproc_exportall_2(); -extern exports * mountproc_exportall_2_svc(); -#define MOUNTPROC_PATHCONF ((u_long)7) -extern ppathcnf * mountproc_pathconf_2(); -extern ppathcnf * mountproc_pathconf_2_svc(); -#endif /* Old Style C */ - -#endif /* !_NFSMOUNT_H_RPCGEN */ diff --git a/mount/nfsmount.x b/mount/nfsmount.x index 90590eb2..c27e74b7 100644 --- a/mount/nfsmount.x +++ b/mount/nfsmount.x @@ -46,10 +46,13 @@ #ifdef RPC_CLNT %#include /* for memset() */ #endif +%#include +const MOUNTPORT = 635; const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ const MNTNAMLEN = 255; /* maximum bytes in a name argument */ const FHSIZE = 32; /* size in bytes of a file handle */ +const FHSIZE3 = 64; /* size in bytes of a file handle */ /* * The fhandle is the file handle that the server passes to the client. @@ -58,6 +61,20 @@ const FHSIZE = 32; /* size in bytes of a file handle */ * server needs to distinguish an individual file. */ typedef opaque fhandle[FHSIZE]; +typedef opaque fhandle3; + +enum mountstat3 { + MNT_OK = 0, /* no error */ + MNT3ERR_PERM = 1, /* not owner */ + MNT3ERR_NOENT = 2, /* No such file or directory */ + MNT3ERR_IO = 5, /* I/O error */ + MNT3ERR_ACCES = 13, /* Permission denied */ + MNT3ERR_NOTDIR = 20, /* Not a directory */ + MNT3ERR_INVAL = 22, /* Invalid argument */ + MNT3ERR_NAMETOOLONG = 63, /* File name too long */ + MNT3ERR_NOTSUPP = 10004, /* Operation not supported */ + MNT3ERR_SERVERFAULT = 10006 /* A failure on the server */ +}; /* * If a status of zero is returned, the call completed successfully, and @@ -71,6 +88,18 @@ default: void; }; +struct mountres3_ok { + fhandle3 fhandle; + int auth_flavours<>; +}; + +union mountres3 switch (mountstat3 fhs_status) { +case MNT_OK: + mountres3_ok mountinfo; +default: + void; +}; + /* * The type dirpath is the pathname of a directory */ @@ -252,6 +281,55 @@ program MOUNTPROG { ppathcnf MOUNTPROC_PATHCONF(dirpath) = 7; } = 2; + version MOUNT_V3 { + /* + * Does no work. It is made available in all RPC services + * to allow server reponse testing and timing + */ + void + MOUNTPROC3_NULL(void) = 0; + + /* + * If fhs_status is 0, then fhs_fhandle contains the + * file handle for the directory. This file handle may + * be used in the NFS protocol. This procedure also adds + * a new entry to the mount list for this client mounting + * the directory. + * Unix authentication required. + */ + mountres3 + MOUNTPROC3_MNT(dirpath) = 1; + + /* + * Returns the list of remotely mounted filesystems. The + * mountlist contains one entry for each hostname and + * directory pair. + */ + mountlist + MOUNTPROC3_DUMP(void) = 2; + + /* + * Removes the mount list entry for the directory + * Unix authentication required. + */ + void + MOUNTPROC3_UMNT(dirpath) = 3; + + /* + * Removes all of the mount list entries for this client + * Unix authentication required. + */ + void + MOUNTPROC3_UMNTALL(void) = 4; + + /* + * Returns a list of all the exported filesystems, and which + * machines are allowed to import it. + */ + exports + MOUNTPROC3_EXPORT(void) = 5; + + } = 3; } = 100005; #ifdef RPC_HDR diff --git a/mount/nfsmount_clnt.c b/mount/nfsmount_clnt.c deleted file mode 100644 index ef575258..00000000 --- a/mount/nfsmount_clnt.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Please do not edit this file. - * It was generated using rpcgen. - */ - -#include "nfsmount.h" -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user or with the express written consent of - * Sun Microsystems, Inc. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Copyright (c) 1985, 1990 by Sun Microsystems, Inc. - */ - -/* from @(#)mount.x 1.3 91/03/11 TIRPC 1.0 */ - -#include /* for memset() */ - -/* Default timeout can be changed using clnt_control() */ -static struct timeval TIMEOUT = { 25, 0 }; - -void * -mountproc_null_1(argp, clnt) - void *argp; - CLIENT *clnt; -{ - static char clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_NULL, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_void, &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return ((void *)&clnt_res); -} - -fhstatus * -mountproc_mnt_1(argp, clnt) - dirpath *argp; - CLIENT *clnt; -{ - static fhstatus clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_MNT, (xdrproc_t) xdr_dirpath, - (caddr_t) argp, (xdrproc_t) xdr_fhstatus, - (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return (&clnt_res); -} - -mountlist * -mountproc_dump_1(argp, clnt) - void *argp; - CLIENT *clnt; -{ - static mountlist clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_DUMP, (xdrproc_t) xdr_void, - (caddr_t) argp, (xdrproc_t) xdr_mountlist, - (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return (&clnt_res); -} - -void * -mountproc_umnt_1(argp, clnt) - dirpath *argp; - CLIENT *clnt; -{ - static char clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_UMNT, (xdrproc_t) xdr_dirpath, - (caddr_t) argp, (xdrproc_t) xdr_void, - (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return ((void *)&clnt_res); -} - -void * -mountproc_umntall_1(argp, clnt) - void *argp; - CLIENT *clnt; -{ - static char clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_UMNTALL, (xdrproc_t) xdr_void, - (caddr_t) argp, (xdrproc_t) xdr_void, - (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return ((void *)&clnt_res); -} - -exports * -mountproc_export_1(argp, clnt) - void *argp; - CLIENT *clnt; -{ - static exports clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_EXPORT, (xdrproc_t) xdr_void, - (caddr_t) argp, (xdrproc_t) xdr_exports, - (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return (&clnt_res); -} - -exports * -mountproc_exportall_1(argp, clnt) - void *argp; - CLIENT *clnt; -{ - static exports clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_EXPORTALL, (xdrproc_t) xdr_void, - (caddr_t) argp, (xdrproc_t) xdr_exports, - (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return (&clnt_res); -} - -void * -mountproc_null_2(argp, clnt) - void *argp; - CLIENT *clnt; -{ - static char clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_NULL, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_void, &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return ((void *)&clnt_res); -} - -fhstatus * -mountproc_mnt_2(argp, clnt) - dirpath *argp; - CLIENT *clnt; -{ - static fhstatus clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_MNT, (xdrproc_t) xdr_dirpath, - (caddr_t) argp, (xdrproc_t) xdr_fhstatus, - (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return (&clnt_res); -} - -mountlist * -mountproc_dump_2(argp, clnt) - void *argp; - CLIENT *clnt; -{ - static mountlist clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_DUMP, (xdrproc_t) xdr_void, argp, - (xdrproc_t) xdr_mountlist, (caddr_t) &clnt_res, - TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return (&clnt_res); -} - -void * -mountproc_umnt_2(argp, clnt) - dirpath *argp; - CLIENT *clnt; -{ - static char clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_UMNT, (xdrproc_t) xdr_dirpath, - (caddr_t) argp, (xdrproc_t) xdr_void, - (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return ((void *)&clnt_res); -} - -void * -mountproc_umntall_2(argp, clnt) - void *argp; - CLIENT *clnt; -{ - static char clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_UMNTALL, (xdrproc_t) xdr_void, - (caddr_t) argp, (xdrproc_t) xdr_void, - (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return ((void *)&clnt_res); -} - -exports * -mountproc_export_2(argp, clnt) - void *argp; - CLIENT *clnt; -{ - static exports clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_EXPORT, (xdrproc_t) xdr_void, - argp, (xdrproc_t) xdr_exports, (caddr_t) &clnt_res, - TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return (&clnt_res); -} - -exports * -mountproc_exportall_2(argp, clnt) - void *argp; - CLIENT *clnt; -{ - static exports clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_EXPORTALL, (xdrproc_t) xdr_void, argp, - (xdrproc_t) xdr_exports, (caddr_t) &clnt_res, - TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return (&clnt_res); -} - -ppathcnf * -mountproc_pathconf_2(argp, clnt) - dirpath *argp; - CLIENT *clnt; -{ - static ppathcnf clnt_res; - - memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_PATHCONF, (xdrproc_t) xdr_dirpath, - (caddr_t) argp, (xdrproc_t) xdr_ppathcnf, - (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { - return (NULL); - } - return (&clnt_res); -} diff --git a/mount/nfsmount_xdr.c b/mount/nfsmount_xdr.c deleted file mode 100644 index 91fbeec6..00000000 --- a/mount/nfsmount_xdr.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Please do not edit this file. - * It was generated using rpcgen. - */ - -#include -#include - -#include "nfsmount.h" -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user or with the express written consent of - * Sun Microsystems, Inc. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Copyright (c) 1985, 1990 by Sun Microsystems, Inc. - */ - -/* from @(#)mount.x 1.3 91/03/11 TIRPC 1.0 */ - -bool_t -xdr_fhandle(XDR *xdrs, fhandle objp) -{ - - register long *buf; - - if (!xdr_opaque(xdrs, objp, FHSIZE)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_fhstatus(XDR *xdrs, fhstatus *objp) -{ - - register long *buf; - - if (!xdr_u_int(xdrs, &objp->fhs_status)) { - return (FALSE); - } - switch (objp->fhs_status) { - case 0: - if (!xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle)) { - return (FALSE); - } - break; - default: - break; - } - return (TRUE); -} - -bool_t -xdr_dirpath(XDR *xdrs, dirpath *objp) -{ - - register long *buf; - - if (!xdr_string(xdrs, objp, MNTPATHLEN)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_name(XDR *xdrs, name *objp) -{ - - register long *buf; - - if (!xdr_string(xdrs, objp, MNTNAMLEN)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_mountlist(XDR *xdrs, mountlist *objp) -{ - - register long *buf; - - if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct mountbody), (xdrproc_t)xdr_mountbody)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_mountbody(XDR *xdrs, mountbody *objp) -{ - - register long *buf; - - if (!xdr_name(xdrs, &objp->ml_hostname)) { - return (FALSE); - } - if (!xdr_dirpath(xdrs, &objp->ml_directory)) { - return (FALSE); - } - if (!xdr_mountlist(xdrs, &objp->ml_next)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_groups(XDR *xdrs, groups *objp) -{ - - register long *buf; - - if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct groupnode), (xdrproc_t)xdr_groupnode)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_groupnode(XDR *xdrs, groupnode *objp) -{ - - register long *buf; - - if (!xdr_name(xdrs, &objp->gr_name)) { - return (FALSE); - } - if (!xdr_groups(xdrs, &objp->gr_next)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_exports(XDR *xdrs, exports *objp) -{ - - register long *buf; - - if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct exportnode), (xdrproc_t)xdr_exportnode)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_exportnode(XDR *xdrs, exportnode *objp) -{ - - register long *buf; - - if (!xdr_dirpath(xdrs, &objp->ex_dir)) { - return (FALSE); - } - if (!xdr_groups(xdrs, &objp->ex_groups)) { - return (FALSE); - } - if (!xdr_exports(xdrs, &objp->ex_next)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_ppathcnf(XDR *xdrs, ppathcnf *objp) -{ - - register long *buf; - - int i; - - if (xdrs->x_op == XDR_ENCODE) { - buf = XDR_INLINE(xdrs,6 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_int(xdrs, &objp->pc_link_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_canon)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_input)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_name_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_path_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_pipe_buf)) { - return (FALSE); - } - - } - else { - IXDR_PUT_LONG(buf,objp->pc_link_max); - IXDR_PUT_SHORT(buf,objp->pc_max_canon); - IXDR_PUT_SHORT(buf,objp->pc_max_input); - IXDR_PUT_SHORT(buf,objp->pc_name_max); - IXDR_PUT_SHORT(buf,objp->pc_path_max); - IXDR_PUT_SHORT(buf,objp->pc_pipe_buf); - } - if (!xdr_u_char(xdrs, &objp->pc_vdisable)) { - return (FALSE); - } - if (!xdr_char(xdrs, &objp->pc_xxx)) { - return (FALSE); - } - buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_vector(xdrs, (char *)objp->pc_mask, 2, sizeof(short), (xdrproc_t)xdr_short)) { - return (FALSE); - } - - } - else { - { register short *genp; - for ( i = 0,genp=objp->pc_mask; - i < 2; i++){ - IXDR_PUT_SHORT(buf,*genp++); - } - }; - } - - return (TRUE); - } else if (xdrs->x_op == XDR_DECODE) { - buf = XDR_INLINE(xdrs,6 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_int(xdrs, &objp->pc_link_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_canon)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_input)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_name_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_path_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_pipe_buf)) { - return (FALSE); - } - - } - else { - objp->pc_link_max = IXDR_GET_LONG(buf); - objp->pc_max_canon = IXDR_GET_SHORT(buf); - objp->pc_max_input = IXDR_GET_SHORT(buf); - objp->pc_name_max = IXDR_GET_SHORT(buf); - objp->pc_path_max = IXDR_GET_SHORT(buf); - objp->pc_pipe_buf = IXDR_GET_SHORT(buf); - } - if (!xdr_u_char(xdrs, &objp->pc_vdisable)) { - return (FALSE); - } - if (!xdr_char(xdrs, &objp->pc_xxx)) { - return (FALSE); - } - buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_vector(xdrs, (char *)objp->pc_mask, 2, sizeof(short), (xdrproc_t)xdr_short)) { - return (FALSE); - } - - } - else { - { register short *genp; - for ( i = 0,genp=objp->pc_mask; - i < 2; i++){ - *genp++ = IXDR_GET_SHORT(buf); - } - }; - } - return(TRUE); - } - - if (!xdr_int(xdrs, &objp->pc_link_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_canon)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_input)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_name_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_path_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_pipe_buf)) { - return (FALSE); - } - if (!xdr_u_char(xdrs, &objp->pc_vdisable)) { - return (FALSE); - } - if (!xdr_char(xdrs, &objp->pc_xxx)) { - return (FALSE); - } - if (!xdr_vector(xdrs, (char *)objp->pc_mask, 2, sizeof(short), (xdrproc_t)xdr_short)) { - return (FALSE); - } - return (TRUE); -} diff --git a/mount/pivot_root.2 b/mount/pivot_root.2 new file mode 100644 index 00000000..1c8f168a --- /dev/null +++ b/mount/pivot_root.2 @@ -0,0 +1,97 @@ +.TH PIVOT_ROOT 2 "Feb 23, 2000" "Linux" "System Calls" +.SH NAME +pivot_root \- change the root file system +.SH SYNOPSIS +.B #include +.sp +.B _syscall2(int,pivot_root,const char *,new_root,const char *,put_old) +.sp +.BI "int pivot_root(const char *" new_root ", const char *" put_old ); +.SH DESCRIPTION +\fBpivot_root\fP moves the root file system of the current process to the +directory \fIput_old\fP and makes \fInew_root\fP the new root file system +of the current process. + +The typical use of \fBpivot_root\fP is during system startup, when the +system mounts a temporary root file system (e.g. an \fBinitrd\fP), then +mounts the real root file system, and eventually turns the latter into +the current root of all relevant processes or threads. + +\fBpivot_root\fP may or may not change the current root and the current +working directory (cwd) of any processes or threads which use the old +root directory. The caller of \fBpivot_root\fP +must ensure that processes with root or cwd at the old root operate +correctly in either case. An easy way to ensure this is to change their +root and cwd to \fInew_root\fP before invoking \fBpivot_root\fP. + +The paragraph above is intentionally vague because the implementation +of \fBpivot_root\fP may change in the future. At the time of writing, +\fBpivot_root\fP changes root and cwd of each process or +thread to \fInew_root\fP if they point to the old root directory. This +is necessary in order to prevent kernel threads from keeping the old +root directory busy with their root and cwd, even if they never access +the file system in any way. In the future, there may be a mechanism for +kernel threads to explicitly relinquish any access to the file system, +such that this fairly intrusive mechanism can be removed from +\fBpivot_root\fP. + +Note that this also applies to the current process: \fBpivot_root\fP may +or may not affect its cwd. It is therefore recommended to call +\fBchdir("/")\fP immediately after \fBpivot_root\fP. + +The following restrictions apply to \fInew_root\fP and \fIput_old\fP: +.IP \- 3 +They must be directories. +.IP \- 3 +\fInew_root\fP and \fIput_old\fP must not be on the same file system as +the current root. +.IP \- 3 +\fIput_old\fP must be underneath \fInew_root\fP, i.e. adding a non-zero +number of \fB/..\fP to the string pointed to by \fIput_old\fP must yield +the same directory as \fInew_root\fP. +.IP \- 3 +No other file system may be mounted on \fIput_old\fP. +.PP +See also \fBpivot_root(8)\fP for additional usage examples. + +If the current root is not a mount point (e.g. after \fBchroot(2)\fP or +\fBpivot_root\fP, see also below), not the old root directory, but the +mount point of that file system is mounted on \fIput_old\fP. +.SH NOTES +\fInew_root\fP does not have to be a mount point. In this case, +\fB/proc/mounts\fP will show the mount point of the file system containing +\fInew_root\fP as root (\fB/\fP). +.SH "RETURN VALUE" +On success, zero is returned. On error, \-1 is returned, and +\fIerrno\fP is set appropriately. +.SH ERRORS +\fBpivot_root\fP may return (in \fIerrno\fP) any of the errors returned by +\fBstat(2)\fP. Additionally, it may return: + +.TP +.B EBUSY +\fInew_root\fP or \fIput_old\fP are on the current root file system, +or a file system is already mounted on \fIput_old\fP. +.TP +.B EINVAL +\fIput_old\fP is not underneath \fInew_root\fP. +.TP +.B ENOTDIR +\fInew_root\fP or \fIput_old\fP is not a directory. +.TP +.B EPERM +The current process does not have the administrator capability. +.SH BUGS +\fBpivot_root\fP should not have to change root and cwd of all other +processes in the system. + +Some of the more obscure uses of \fBpivot_root\fP may quickly lead to +insanity. +.SH HISTORY +\fBpivot_root\fP was introduced in Linux 2.3.41. +.SH "SEE ALSO" +.BR chdir(2), +.BR chroot(2), +.BR initrd(4), +.BR pivot_root(8), +.BR stat(2) diff --git a/mount/pivot_root.8 b/mount/pivot_root.8 new file mode 100644 index 00000000..83d1daa2 --- /dev/null +++ b/mount/pivot_root.8 @@ -0,0 +1,65 @@ +.TH PIVOT_ROOT 8 "Feb 23, 2000" "Linux" "Maintenance Commands" +.SH NAME +pivot_root \- change the root file system +.SH SYNOPSIS +.B pivot_root +.RB \fInew_root\fP +.RB \fIput_old\fP +.SH DESCRIPTION +\fBpivot_root\fP moves the root file system of the current process to the +directory \fIput_old\fP and makes \fInew_root\fP the new root file system. +Since \fBpivot_root(8)\fP simply calls \fBpivot_root(2)\fP, we refer to +the man page of the latter for further details. + +Note that, depending on the implementation of \fBpivot_root\fP, root and +cwd of the caller may or may not change. The following is a sequence for +invoking \fBpivot_root\fP that works in either case, assuming that +\fBpivot_root\fP and \fBchroot\fP are in the current \fBPATH\fP: +.sp +cd \fInew_root\fP +.br +pivot_root . \fIput_old\fP +.br +exec chroot . \fIcommand\fP +.sp +Note that \fBchroot\fP must be available under the old root and under the new +root, because \fBpivot_root\fP may or may not have implicitly changed the +root directory of the shell. + +Note that \fBexec chroot\fP changes the running executable, which is +necessary if the old root directory should be unmounted afterwards. +Also note that standard input, output, and error may still point to a +device on the old root file system, keeping it busy. They can easily be +changed when invoking \fBchroot\fP (see below; note the absence of +leading slashes to make it work whether \fBpivot_root\fP has changed the +shell's root or not). +.SH EXAMPLES +Change the root file system to /dev/hda1 from an interactive shell: +.sp +.nf +mount /dev/hda1 /new-root +cd /new-root +pivot_root . old-root +exec chroot . sh dev/console 2>&1 +umount /old-root +.fi +.sp +Mount the new root file system over NFS from 10.0.0.1:/my_root and run +\fBinit\fP: +.sp +.nf +ifconfig lo 127.0.0.1 up # for portmap +# configure Ethernet or such +portmap # for lockd (implicitly started by mount) +mount -o ro 10.0.0.1:/my_root /mnt +killall portmap # portmap keeps old root busy +cd /mnt +pivot_root . old_root +exec chroot . sh -c 'umount /old_root; exec /sbin/init' \\ + dev/console 2>&1 +.fi +.SH "SEE ALSO" +.BR chroot(1), +.BR mount(8), +.BR pivot_root(2), +.BR umount(8) diff --git a/mount/pivot_root.c b/mount/pivot_root.c new file mode 100644 index 00000000..4ab8be85 --- /dev/null +++ b/mount/pivot_root.c @@ -0,0 +1,24 @@ +/* pivot_root.c - Change the root file system */ + +/* Written 2000 by Werner Almesberger */ + + +#include +#include + + +_syscall2(int,pivot_root,const char *,new_root,const char *,put_old) + + +int main(int argc,const char **argv) +{ + if (argc != 3) { + fprintf(stderr,"usage: %s new_root put_old\n",argv[0]); + return 1; + } + if (pivot_root(argv[1],argv[2]) < 0) { + perror("pivot_root"); + return 1; + } + return 0; +} diff --git a/mount/realpath.c b/mount/realpath.c index f0d7c76c..374f8a3a 100644 --- a/mount/realpath.c +++ b/mount/realpath.c @@ -27,18 +27,20 @@ #define MAX_READLINKS 32 +/* this leaks some memory - unimportant for mount */ char * myrealpath(const char *path, char *resolved_path, int maxreslth) { - char *npath; + char *npath, *buf; char link_path[PATH_MAX+1]; int readlinks = 0; - int n; + int m, n; npath = resolved_path; /* If it's a relative pathname use getcwd for starters. */ if (*path != '/') { - getcwd(npath, maxreslth-2); + if (!getcwd(npath, maxreslth-2)) + return NULL; npath += strlen(npath); if (npath[-1] != '/') *npath++ = '/'; @@ -100,14 +102,13 @@ myrealpath(const char *path, char *resolved_path, int maxreslth) { /* Otherwise back up over this component. */ while (*(--npath) != '/') ; - /* Safe sex check. */ - if (strlen(path) + n >= sizeof(link_path)) { - errno = ENAMETOOLONG; - return NULL; - } + /* Insert symlink contents into path. */ - strcat(link_path, path); - path = xstrdup(link_path); + m = strlen(path); + buf = xmalloc(m + n + 1); + memcpy(buf, link_path, n); + memcpy(buf + n, path, m + 1); + path = buf; } *npath++ = '/'; diff --git a/mount/rpcsvc/nfsmount.h b/mount/rpcsvc/nfsmount.h index 73c71fc6..55b5d8e7 100644 --- a/mount/rpcsvc/nfsmount.h +++ b/mount/rpcsvc/nfsmount.h @@ -8,6 +8,11 @@ #include + +#ifdef __cplusplus +extern "C" { +#endif + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -44,19 +49,33 @@ /* from @(#)mount.x 1.3 91/03/11 TIRPC 1.0 */ #ifndef _rpcsvc_mount_h #define _rpcsvc_mount_h +#include +#define MOUNTPORT 635 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define FHSIZE 32 +#define FHSIZE3 64 typedef char fhandle[FHSIZE]; -#ifdef __cplusplus -extern "C" bool_t xdr_fhandle(XDR *, fhandle); -#elif __STDC__ -extern bool_t xdr_fhandle(XDR *, fhandle); -#else /* Old Style C */ -bool_t xdr_fhandle(); -#endif /* Old Style C */ +typedef struct { + u_int fhandle3_len; + char *fhandle3_val; +} fhandle3; + +enum mountstat3 { + MNT_OK = 0, + MNT3ERR_PERM = 1, + MNT3ERR_NOENT = 2, + MNT3ERR_IO = 5, + MNT3ERR_ACCES = 13, + MNT3ERR_NOTDIR = 20, + MNT3ERR_INVAL = 22, + MNT3ERR_NAMETOOLONG = 63, + MNT3ERR_NOTSUPP = 10004, + MNT3ERR_SERVERFAULT = 10006, +}; +typedef enum mountstat3 mountstat3; struct fhstatus { u_int fhs_status; @@ -65,44 +84,29 @@ struct fhstatus { } fhstatus_u; }; typedef struct fhstatus fhstatus; -#ifdef __cplusplus -extern "C" bool_t xdr_fhstatus(XDR *, fhstatus*); -#elif __STDC__ -extern bool_t xdr_fhstatus(XDR *, fhstatus*); -#else /* Old Style C */ -bool_t xdr_fhstatus(); -#endif /* Old Style C */ +struct mountres3_ok { + fhandle3 fhandle; + struct { + u_int auth_flavours_len; + int *auth_flavours_val; + } auth_flavours; +}; +typedef struct mountres3_ok mountres3_ok; -typedef char *dirpath; -#ifdef __cplusplus -extern "C" bool_t xdr_dirpath(XDR *, dirpath*); -#elif __STDC__ -extern bool_t xdr_dirpath(XDR *, dirpath*); -#else /* Old Style C */ -bool_t xdr_dirpath(); -#endif /* Old Style C */ +struct mountres3 { + mountstat3 fhs_status; + union { + mountres3_ok mountinfo; + } mountres3_u; +}; +typedef struct mountres3 mountres3; +typedef char *dirpath; typedef char *name; -#ifdef __cplusplus -extern "C" bool_t xdr_name(XDR *, name*); -#elif __STDC__ -extern bool_t xdr_name(XDR *, name*); -#else /* Old Style C */ -bool_t xdr_name(); -#endif /* Old Style C */ - typedef struct mountbody *mountlist; -#ifdef __cplusplus -extern "C" bool_t xdr_mountlist(XDR *, mountlist*); -#elif __STDC__ -extern bool_t xdr_mountlist(XDR *, mountlist*); -#else /* Old Style C */ -bool_t xdr_mountlist(); -#endif /* Old Style C */ - struct mountbody { name ml_hostname; @@ -110,48 +114,16 @@ struct mountbody { mountlist ml_next; }; typedef struct mountbody mountbody; -#ifdef __cplusplus -extern "C" bool_t xdr_mountbody(XDR *, mountbody*); -#elif __STDC__ -extern bool_t xdr_mountbody(XDR *, mountbody*); -#else /* Old Style C */ -bool_t xdr_mountbody(); -#endif /* Old Style C */ - typedef struct groupnode *groups; -#ifdef __cplusplus -extern "C" bool_t xdr_groups(XDR *, groups*); -#elif __STDC__ -extern bool_t xdr_groups(XDR *, groups*); -#else /* Old Style C */ -bool_t xdr_groups(); -#endif /* Old Style C */ - struct groupnode { name gr_name; groups gr_next; }; typedef struct groupnode groupnode; -#ifdef __cplusplus -extern "C" bool_t xdr_groupnode(XDR *, groupnode*); -#elif __STDC__ -extern bool_t xdr_groupnode(XDR *, groupnode*); -#else /* Old Style C */ -bool_t xdr_groupnode(); -#endif /* Old Style C */ - typedef struct exportnode *exports; -#ifdef __cplusplus -extern "C" bool_t xdr_exports(XDR *, exports*); -#elif __STDC__ -extern bool_t xdr_exports(XDR *, exports*); -#else /* Old Style C */ -bool_t xdr_exports(); -#endif /* Old Style C */ - struct exportnode { dirpath ex_dir; @@ -159,14 +131,6 @@ struct exportnode { exports ex_next; }; typedef struct exportnode exportnode; -#ifdef __cplusplus -extern "C" bool_t xdr_exportnode(XDR *, exportnode*); -#elif __STDC__ -extern bool_t xdr_exportnode(XDR *, exportnode*); -#else /* Old Style C */ -bool_t xdr_exportnode(); -#endif /* Old Style C */ - struct ppathcnf { int pc_link_max; @@ -180,110 +144,62 @@ struct ppathcnf { short pc_mask[2]; }; typedef struct ppathcnf ppathcnf; -#ifdef __cplusplus -extern "C" bool_t xdr_ppathcnf(XDR *, ppathcnf*); -#elif __STDC__ -extern bool_t xdr_ppathcnf(XDR *, ppathcnf*); -#else /* Old Style C */ -bool_t xdr_ppathcnf(); -#endif /* Old Style C */ - #endif /*!_rpcsvc_mount_h*/ -#define MOUNTPROG ((u_long)100005) -#define MOUNTVERS ((u_long)1) +#define MOUNTPROG 100005 +#define MOUNTVERS 1 -#ifdef __cplusplus -#define MOUNTPROC_NULL ((u_long)0) -extern "C" void * mountproc_null_1(void *, CLIENT *); -extern "C" void * mountproc_null_1_svc(void *, struct svc_req *); -#define MOUNTPROC_MNT ((u_long)1) -extern "C" fhstatus * mountproc_mnt_1(dirpath *, CLIENT *); -extern "C" fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *); -#define MOUNTPROC_DUMP ((u_long)2) -extern "C" mountlist * mountproc_dump_1(void *, CLIENT *); -extern "C" mountlist * mountproc_dump_1_svc(void *, struct svc_req *); -#define MOUNTPROC_UMNT ((u_long)3) -extern "C" void * mountproc_umnt_1(dirpath *, CLIENT *); -extern "C" void * mountproc_umnt_1_svc(dirpath *, struct svc_req *); -#define MOUNTPROC_UMNTALL ((u_long)4) -extern "C" void * mountproc_umntall_1(void *, CLIENT *); -extern "C" void * mountproc_umntall_1_svc(void *, struct svc_req *); -#define MOUNTPROC_EXPORT ((u_long)5) -extern "C" exports * mountproc_export_1(void *, CLIENT *); -extern "C" exports * mountproc_export_1_svc(void *, struct svc_req *); -#define MOUNTPROC_EXPORTALL ((u_long)6) -extern "C" exports * mountproc_exportall_1(void *, CLIENT *); -extern "C" exports * mountproc_exportall_1_svc(void *, struct svc_req *); - -#elif __STDC__ -#define MOUNTPROC_NULL ((u_long)0) +#if defined(__STDC__) || defined(__cplusplus) +#define MOUNTPROC_NULL 0 extern void * mountproc_null_1(void *, CLIENT *); extern void * mountproc_null_1_svc(void *, struct svc_req *); -#define MOUNTPROC_MNT ((u_long)1) +#define MOUNTPROC_MNT 1 extern fhstatus * mountproc_mnt_1(dirpath *, CLIENT *); extern fhstatus * mountproc_mnt_1_svc(dirpath *, struct svc_req *); -#define MOUNTPROC_DUMP ((u_long)2) +#define MOUNTPROC_DUMP 2 extern mountlist * mountproc_dump_1(void *, CLIENT *); extern mountlist * mountproc_dump_1_svc(void *, struct svc_req *); -#define MOUNTPROC_UMNT ((u_long)3) +#define MOUNTPROC_UMNT 3 extern void * mountproc_umnt_1(dirpath *, CLIENT *); extern void * mountproc_umnt_1_svc(dirpath *, struct svc_req *); -#define MOUNTPROC_UMNTALL ((u_long)4) +#define MOUNTPROC_UMNTALL 4 extern void * mountproc_umntall_1(void *, CLIENT *); extern void * mountproc_umntall_1_svc(void *, struct svc_req *); -#define MOUNTPROC_EXPORT ((u_long)5) +#define MOUNTPROC_EXPORT 5 extern exports * mountproc_export_1(void *, CLIENT *); extern exports * mountproc_export_1_svc(void *, struct svc_req *); -#define MOUNTPROC_EXPORTALL ((u_long)6) +#define MOUNTPROC_EXPORTALL 6 extern exports * mountproc_exportall_1(void *, CLIENT *); extern exports * mountproc_exportall_1_svc(void *, struct svc_req *); +extern int mountprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); -#else /* Old Style C */ -#define MOUNTPROC_NULL ((u_long)0) +#else /* K&R C */ +#define MOUNTPROC_NULL 0 extern void * mountproc_null_1(); extern void * mountproc_null_1_svc(); -#define MOUNTPROC_MNT ((u_long)1) +#define MOUNTPROC_MNT 1 extern fhstatus * mountproc_mnt_1(); extern fhstatus * mountproc_mnt_1_svc(); -#define MOUNTPROC_DUMP ((u_long)2) +#define MOUNTPROC_DUMP 2 extern mountlist * mountproc_dump_1(); extern mountlist * mountproc_dump_1_svc(); -#define MOUNTPROC_UMNT ((u_long)3) +#define MOUNTPROC_UMNT 3 extern void * mountproc_umnt_1(); extern void * mountproc_umnt_1_svc(); -#define MOUNTPROC_UMNTALL ((u_long)4) +#define MOUNTPROC_UMNTALL 4 extern void * mountproc_umntall_1(); extern void * mountproc_umntall_1_svc(); -#define MOUNTPROC_EXPORT ((u_long)5) +#define MOUNTPROC_EXPORT 5 extern exports * mountproc_export_1(); extern exports * mountproc_export_1_svc(); -#define MOUNTPROC_EXPORTALL ((u_long)6) +#define MOUNTPROC_EXPORTALL 6 extern exports * mountproc_exportall_1(); extern exports * mountproc_exportall_1_svc(); -#endif /* Old Style C */ -#define MOUNTVERS_POSIX ((u_long)2) +extern int mountprog_1_freeresult (); +#endif /* K&R C */ +#define MOUNTVERS_POSIX 2 -#ifdef __cplusplus -extern "C" void * mountproc_null_2(void *, CLIENT *); -extern "C" void * mountproc_null_2_svc(void *, struct svc_req *); -extern "C" fhstatus * mountproc_mnt_2(dirpath *, CLIENT *); -extern "C" fhstatus * mountproc_mnt_2_svc(dirpath *, struct svc_req *); -extern "C" mountlist * mountproc_dump_2(void *, CLIENT *); -extern "C" mountlist * mountproc_dump_2_svc(void *, struct svc_req *); -extern "C" void * mountproc_umnt_2(dirpath *, CLIENT *); -extern "C" void * mountproc_umnt_2_svc(dirpath *, struct svc_req *); -extern "C" void * mountproc_umntall_2(void *, CLIENT *); -extern "C" void * mountproc_umntall_2_svc(void *, struct svc_req *); -extern "C" exports * mountproc_export_2(void *, CLIENT *); -extern "C" exports * mountproc_export_2_svc(void *, struct svc_req *); -extern "C" exports * mountproc_exportall_2(void *, CLIENT *); -extern "C" exports * mountproc_exportall_2_svc(void *, struct svc_req *); -#define MOUNTPROC_PATHCONF ((u_long)7) -extern "C" ppathcnf * mountproc_pathconf_2(dirpath *, CLIENT *); -extern "C" ppathcnf * mountproc_pathconf_2_svc(dirpath *, struct svc_req *); - -#elif __STDC__ +#if defined(__STDC__) || defined(__cplusplus) extern void * mountproc_null_2(void *, CLIENT *); extern void * mountproc_null_2_svc(void *, struct svc_req *); extern fhstatus * mountproc_mnt_2(dirpath *, CLIENT *); @@ -298,11 +214,12 @@ extern exports * mountproc_export_2(void *, CLIENT *); extern exports * mountproc_export_2_svc(void *, struct svc_req *); extern exports * mountproc_exportall_2(void *, CLIENT *); extern exports * mountproc_exportall_2_svc(void *, struct svc_req *); -#define MOUNTPROC_PATHCONF ((u_long)7) +#define MOUNTPROC_PATHCONF 7 extern ppathcnf * mountproc_pathconf_2(dirpath *, CLIENT *); extern ppathcnf * mountproc_pathconf_2_svc(dirpath *, struct svc_req *); +extern int mountprog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t); -#else /* Old Style C */ +#else /* K&R C */ extern void * mountproc_null_2(); extern void * mountproc_null_2_svc(); extern fhstatus * mountproc_mnt_2(); @@ -317,9 +234,96 @@ extern exports * mountproc_export_2(); extern exports * mountproc_export_2_svc(); extern exports * mountproc_exportall_2(); extern exports * mountproc_exportall_2_svc(); -#define MOUNTPROC_PATHCONF ((u_long)7) +#define MOUNTPROC_PATHCONF 7 extern ppathcnf * mountproc_pathconf_2(); extern ppathcnf * mountproc_pathconf_2_svc(); -#endif /* Old Style C */ +extern int mountprog_2_freeresult (); +#endif /* K&R C */ +#define MOUNT_V3 3 + +#if defined(__STDC__) || defined(__cplusplus) +#define MOUNTPROC3_NULL 0 +extern void * mountproc3_null_3(void *, CLIENT *); +extern void * mountproc3_null_3_svc(void *, struct svc_req *); +#define MOUNTPROC3_MNT 1 +extern mountres3 * mountproc3_mnt_3(dirpath *, CLIENT *); +extern mountres3 * mountproc3_mnt_3_svc(dirpath *, struct svc_req *); +#define MOUNTPROC3_DUMP 2 +extern mountlist * mountproc3_dump_3(void *, CLIENT *); +extern mountlist * mountproc3_dump_3_svc(void *, struct svc_req *); +#define MOUNTPROC3_UMNT 3 +extern void * mountproc3_umnt_3(dirpath *, CLIENT *); +extern void * mountproc3_umnt_3_svc(dirpath *, struct svc_req *); +#define MOUNTPROC3_UMNTALL 4 +extern void * mountproc3_umntall_3(void *, CLIENT *); +extern void * mountproc3_umntall_3_svc(void *, struct svc_req *); +#define MOUNTPROC3_EXPORT 5 +extern exports * mountproc3_export_3(void *, CLIENT *); +extern exports * mountproc3_export_3_svc(void *, struct svc_req *); +extern int mountprog_3_freeresult (SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define MOUNTPROC3_NULL 0 +extern void * mountproc3_null_3(); +extern void * mountproc3_null_3_svc(); +#define MOUNTPROC3_MNT 1 +extern mountres3 * mountproc3_mnt_3(); +extern mountres3 * mountproc3_mnt_3_svc(); +#define MOUNTPROC3_DUMP 2 +extern mountlist * mountproc3_dump_3(); +extern mountlist * mountproc3_dump_3_svc(); +#define MOUNTPROC3_UMNT 3 +extern void * mountproc3_umnt_3(); +extern void * mountproc3_umnt_3_svc(); +#define MOUNTPROC3_UMNTALL 4 +extern void * mountproc3_umntall_3(); +extern void * mountproc3_umntall_3_svc(); +#define MOUNTPROC3_EXPORT 5 +extern exports * mountproc3_export_3(); +extern exports * mountproc3_export_3_svc(); +extern int mountprog_3_freeresult (); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_fhandle (XDR *, fhandle); +extern bool_t xdr_fhandle3 (XDR *, fhandle3*); +extern bool_t xdr_mountstat3 (XDR *, mountstat3*); +extern bool_t xdr_fhstatus (XDR *, fhstatus*); +extern bool_t xdr_mountres3_ok (XDR *, mountres3_ok*); +extern bool_t xdr_mountres3 (XDR *, mountres3*); +extern bool_t xdr_dirpath (XDR *, dirpath*); +extern bool_t xdr_name (XDR *, name*); +extern bool_t xdr_mountlist (XDR *, mountlist*); +extern bool_t xdr_mountbody (XDR *, mountbody*); +extern bool_t xdr_groups (XDR *, groups*); +extern bool_t xdr_groupnode (XDR *, groupnode*); +extern bool_t xdr_exports (XDR *, exports*); +extern bool_t xdr_exportnode (XDR *, exportnode*); +extern bool_t xdr_ppathcnf (XDR *, ppathcnf*); + +#else /* K&R C */ +extern bool_t xdr_fhandle (); +extern bool_t xdr_fhandle3 (); +extern bool_t xdr_mountstat3 (); +extern bool_t xdr_fhstatus (); +extern bool_t xdr_mountres3_ok (); +extern bool_t xdr_mountres3 (); +extern bool_t xdr_dirpath (); +extern bool_t xdr_name (); +extern bool_t xdr_mountlist (); +extern bool_t xdr_mountbody (); +extern bool_t xdr_groups (); +extern bool_t xdr_groupnode (); +extern bool_t xdr_exports (); +extern bool_t xdr_exportnode (); +extern bool_t xdr_ppathcnf (); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif #endif /* !_NFSMOUNT_H_RPCGEN */ diff --git a/mount/rpcsvc/nfsmount.x b/mount/rpcsvc/nfsmount.x index 90590eb2..c27e74b7 100644 --- a/mount/rpcsvc/nfsmount.x +++ b/mount/rpcsvc/nfsmount.x @@ -46,10 +46,13 @@ #ifdef RPC_CLNT %#include /* for memset() */ #endif +%#include +const MOUNTPORT = 635; const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ const MNTNAMLEN = 255; /* maximum bytes in a name argument */ const FHSIZE = 32; /* size in bytes of a file handle */ +const FHSIZE3 = 64; /* size in bytes of a file handle */ /* * The fhandle is the file handle that the server passes to the client. @@ -58,6 +61,20 @@ const FHSIZE = 32; /* size in bytes of a file handle */ * server needs to distinguish an individual file. */ typedef opaque fhandle[FHSIZE]; +typedef opaque fhandle3; + +enum mountstat3 { + MNT_OK = 0, /* no error */ + MNT3ERR_PERM = 1, /* not owner */ + MNT3ERR_NOENT = 2, /* No such file or directory */ + MNT3ERR_IO = 5, /* I/O error */ + MNT3ERR_ACCES = 13, /* Permission denied */ + MNT3ERR_NOTDIR = 20, /* Not a directory */ + MNT3ERR_INVAL = 22, /* Invalid argument */ + MNT3ERR_NAMETOOLONG = 63, /* File name too long */ + MNT3ERR_NOTSUPP = 10004, /* Operation not supported */ + MNT3ERR_SERVERFAULT = 10006 /* A failure on the server */ +}; /* * If a status of zero is returned, the call completed successfully, and @@ -71,6 +88,18 @@ default: void; }; +struct mountres3_ok { + fhandle3 fhandle; + int auth_flavours<>; +}; + +union mountres3 switch (mountstat3 fhs_status) { +case MNT_OK: + mountres3_ok mountinfo; +default: + void; +}; + /* * The type dirpath is the pathname of a directory */ @@ -252,6 +281,55 @@ program MOUNTPROG { ppathcnf MOUNTPROC_PATHCONF(dirpath) = 7; } = 2; + version MOUNT_V3 { + /* + * Does no work. It is made available in all RPC services + * to allow server reponse testing and timing + */ + void + MOUNTPROC3_NULL(void) = 0; + + /* + * If fhs_status is 0, then fhs_fhandle contains the + * file handle for the directory. This file handle may + * be used in the NFS protocol. This procedure also adds + * a new entry to the mount list for this client mounting + * the directory. + * Unix authentication required. + */ + mountres3 + MOUNTPROC3_MNT(dirpath) = 1; + + /* + * Returns the list of remotely mounted filesystems. The + * mountlist contains one entry for each hostname and + * directory pair. + */ + mountlist + MOUNTPROC3_DUMP(void) = 2; + + /* + * Removes the mount list entry for the directory + * Unix authentication required. + */ + void + MOUNTPROC3_UMNT(dirpath) = 3; + + /* + * Removes all of the mount list entries for this client + * Unix authentication required. + */ + void + MOUNTPROC3_UMNTALL(void) = 4; + + /* + * Returns a list of all the exported filesystems, and which + * machines are allowed to import it. + */ + exports + MOUNTPROC3_EXPORT(void) = 5; + + } = 3; } = 100005; #ifdef RPC_HDR diff --git a/mount/rpcsvc/nfsmount_clnt.c b/mount/rpcsvc/nfsmount_clnt.c index a77f4c5e..053d357a 100644 --- a/mount/rpcsvc/nfsmount_clnt.c +++ b/mount/rpcsvc/nfsmount_clnt.c @@ -3,6 +3,7 @@ * It was generated using rpcgen. */ +#include /* for memset */ #include "nfsmount.h" /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -38,217 +39,322 @@ */ /* from @(#)mount.x 1.3 91/03/11 TIRPC 1.0 */ - -#include /* for memset() */ +#include /* for memset() */ +#include /* Default timeout can be changed using clnt_control() */ static struct timeval TIMEOUT = { 25, 0 }; void * -mountproc_null_1(argp, clnt) - void *argp; - CLIENT *clnt; +mountproc_null_1(void *argp, CLIENT *clnt) { static char clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_NULL, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_void, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_NULL, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_void, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return ((void *)&clnt_res); } fhstatus * -mountproc_mnt_1(argp, clnt) - dirpath *argp; - CLIENT *clnt; +mountproc_mnt_1(dirpath *argp, CLIENT *clnt) { static fhstatus clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_MNT, (xdrproc_t) xdr_dirpath, argp, (xdrproc_t) xdr_fhstatus, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_MNT, + (xdrproc_t) xdr_dirpath, (caddr_t) argp, + (xdrproc_t) xdr_fhstatus, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); } mountlist * -mountproc_dump_1(argp, clnt) - void *argp; - CLIENT *clnt; +mountproc_dump_1(void *argp, CLIENT *clnt) { static mountlist clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_DUMP, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_mountlist, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_DUMP, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_mountlist, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); } void * -mountproc_umnt_1(argp, clnt) - dirpath *argp; - CLIENT *clnt; +mountproc_umnt_1(dirpath *argp, CLIENT *clnt) { static char clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_UMNT, (xdrproc_t) xdr_dirpath, argp, (xdrproc_t) xdr_void, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_UMNT, + (xdrproc_t) xdr_dirpath, (caddr_t) argp, + (xdrproc_t) xdr_void, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return ((void *)&clnt_res); } void * -mountproc_umntall_1(argp, clnt) - void *argp; - CLIENT *clnt; +mountproc_umntall_1(void *argp, CLIENT *clnt) { static char clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_UMNTALL, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_void, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_UMNTALL, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_void, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return ((void *)&clnt_res); } exports * -mountproc_export_1(argp, clnt) - void *argp; - CLIENT *clnt; +mountproc_export_1(void *argp, CLIENT *clnt) { static exports clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_EXPORT, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_exports, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_EXPORT, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_exports, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); } exports * -mountproc_exportall_1(argp, clnt) - void *argp; - CLIENT *clnt; +mountproc_exportall_1(void *argp, CLIENT *clnt) { static exports clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_EXPORTALL, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_exports, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_EXPORTALL, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_exports, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); } void * -mountproc_null_2(argp, clnt) - void *argp; - CLIENT *clnt; +mountproc_null_2(void *argp, CLIENT *clnt) { static char clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_NULL, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_void, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_NULL, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_void, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return ((void *)&clnt_res); } fhstatus * -mountproc_mnt_2(argp, clnt) - dirpath *argp; - CLIENT *clnt; +mountproc_mnt_2(dirpath *argp, CLIENT *clnt) { static fhstatus clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_MNT, (xdrproc_t) xdr_dirpath, argp, (xdrproc_t) xdr_fhstatus, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_MNT, + (xdrproc_t) xdr_dirpath, (caddr_t) argp, + (xdrproc_t) xdr_fhstatus, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); } mountlist * -mountproc_dump_2(argp, clnt) - void *argp; - CLIENT *clnt; +mountproc_dump_2(void *argp, CLIENT *clnt) { static mountlist clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_DUMP, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_mountlist, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_DUMP, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_mountlist, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); } void * -mountproc_umnt_2(argp, clnt) - dirpath *argp; - CLIENT *clnt; +mountproc_umnt_2(dirpath *argp, CLIENT *clnt) { static char clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_UMNT, (xdrproc_t) xdr_dirpath, argp, (xdrproc_t) xdr_void, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_UMNT, + (xdrproc_t) xdr_dirpath, (caddr_t) argp, + (xdrproc_t) xdr_void, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return ((void *)&clnt_res); } void * -mountproc_umntall_2(argp, clnt) - void *argp; - CLIENT *clnt; +mountproc_umntall_2(void *argp, CLIENT *clnt) { static char clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_UMNTALL, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_void, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_UMNTALL, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_void, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return ((void *)&clnt_res); } exports * -mountproc_export_2(argp, clnt) - void *argp; - CLIENT *clnt; +mountproc_export_2(void *argp, CLIENT *clnt) { static exports clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_EXPORT, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_exports, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_EXPORT, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_exports, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); } exports * -mountproc_exportall_2(argp, clnt) - void *argp; - CLIENT *clnt; +mountproc_exportall_2(void *argp, CLIENT *clnt) { static exports clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_EXPORTALL, (xdrproc_t) xdr_void, argp, (xdrproc_t) xdr_exports, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_EXPORTALL, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_exports, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); } ppathcnf * -mountproc_pathconf_2(argp, clnt) - dirpath *argp; - CLIENT *clnt; +mountproc_pathconf_2(dirpath *argp, CLIENT *clnt) { static ppathcnf clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); - if (clnt_call(clnt, MOUNTPROC_PATHCONF, (xdrproc_t) xdr_dirpath, argp, (xdrproc_t) xdr_ppathcnf, &clnt_res, TIMEOUT) != RPC_SUCCESS) { + if (clnt_call (clnt, MOUNTPROC_PATHCONF, + (xdrproc_t) xdr_dirpath, (caddr_t) argp, + (xdrproc_t) xdr_ppathcnf, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +void * +mountproc3_null_3(void *argp, CLIENT *clnt) +{ + static char clnt_res; + + memset((char *)&clnt_res, 0, sizeof(clnt_res)); + if (clnt_call (clnt, MOUNTPROC3_NULL, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_void, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return ((void *)&clnt_res); +} + +mountres3 * +mountproc3_mnt_3(dirpath *argp, CLIENT *clnt) +{ + static mountres3 clnt_res; + + memset((char *)&clnt_res, 0, sizeof(clnt_res)); + if (clnt_call (clnt, MOUNTPROC3_MNT, + (xdrproc_t) xdr_dirpath, (caddr_t) argp, + (xdrproc_t) xdr_mountres3, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +mountlist * +mountproc3_dump_3(void *argp, CLIENT *clnt) +{ + static mountlist clnt_res; + + memset((char *)&clnt_res, 0, sizeof(clnt_res)); + if (clnt_call (clnt, MOUNTPROC3_DUMP, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_mountlist, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +void * +mountproc3_umnt_3(dirpath *argp, CLIENT *clnt) +{ + static char clnt_res; + + memset((char *)&clnt_res, 0, sizeof(clnt_res)); + if (clnt_call (clnt, MOUNTPROC3_UMNT, + (xdrproc_t) xdr_dirpath, (caddr_t) argp, + (xdrproc_t) xdr_void, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return ((void *)&clnt_res); +} + +void * +mountproc3_umntall_3(void *argp, CLIENT *clnt) +{ + static char clnt_res; + + memset((char *)&clnt_res, 0, sizeof(clnt_res)); + if (clnt_call (clnt, MOUNTPROC3_UMNTALL, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_void, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return ((void *)&clnt_res); +} + +exports * +mountproc3_export_3(void *argp, CLIENT *clnt) +{ + static exports clnt_res; + + memset((char *)&clnt_res, 0, sizeof(clnt_res)); + if (clnt_call (clnt, MOUNTPROC3_EXPORT, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_exports, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); diff --git a/mount/rpcsvc/nfsmount_xdr.c b/mount/rpcsvc/nfsmount_xdr.c index 6f539c24..c22492de 100644 --- a/mount/rpcsvc/nfsmount_xdr.c +++ b/mount/rpcsvc/nfsmount_xdr.c @@ -38,314 +38,293 @@ */ /* from @(#)mount.x 1.3 91/03/11 TIRPC 1.0 */ +#include bool_t -xdr_fhandle(xdrs, objp) - XDR *xdrs; - fhandle objp; +xdr_fhandle (XDR *xdrs, fhandle objp) { + register int32_t *buf; - register long *buf; + if (!xdr_opaque (xdrs, objp, FHSIZE)) + return FALSE; + return TRUE; +} + +bool_t +xdr_fhandle3 (XDR *xdrs, fhandle3 *objp) +{ + register int32_t *buf; - if (!xdr_opaque(xdrs, objp, FHSIZE)) { - return (FALSE); - } - return (TRUE); + if (!xdr_bytes (xdrs, (char **)&objp->fhandle3_val, (u_int *) &objp->fhandle3_len, FHSIZE3)) + return FALSE; + return TRUE; } bool_t -xdr_fhstatus(xdrs, objp) - XDR *xdrs; - fhstatus *objp; +xdr_mountstat3 (XDR *xdrs, mountstat3 *objp) { + register int32_t *buf; - register long *buf; + if (!xdr_enum (xdrs, (enum_t *) objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_fhstatus (XDR *xdrs, fhstatus *objp) +{ + register int32_t *buf; - if (!xdr_u_int(xdrs, &objp->fhs_status)) { - return (FALSE); - } + if (!xdr_u_int (xdrs, &objp->fhs_status)) + return FALSE; switch (objp->fhs_status) { case 0: - if (!xdr_fhandle(xdrs, objp->fhstatus_u.fhs_fhandle)) { - return (FALSE); - } + if (!xdr_fhandle (xdrs, objp->fhstatus_u.fhs_fhandle)) + return FALSE; + break; + default: break; } - return (TRUE); + return TRUE; } bool_t -xdr_dirpath(xdrs, objp) - XDR *xdrs; - dirpath *objp; +xdr_mountres3_ok (XDR *xdrs, mountres3_ok *objp) { + register int32_t *buf; + + if (!xdr_fhandle3 (xdrs, &objp->fhandle)) + return FALSE; + if (!xdr_array (xdrs, (char **)&objp->auth_flavours.auth_flavours_val, (u_int *) &objp->auth_flavours.auth_flavours_len, ~0, + sizeof (int), (xdrproc_t) xdr_int)) + return FALSE; + return TRUE; +} - register long *buf; +bool_t +xdr_mountres3 (XDR *xdrs, mountres3 *objp) +{ + register int32_t *buf; - if (!xdr_string(xdrs, objp, MNTPATHLEN)) { - return (FALSE); - } - return (TRUE); + if (!xdr_mountstat3 (xdrs, &objp->fhs_status)) + return FALSE; + switch (objp->fhs_status) { + case MNT_OK: + if (!xdr_mountres3_ok (xdrs, &objp->mountres3_u.mountinfo)) + return FALSE; + break; + default: + break; + } + return TRUE; } bool_t -xdr_name(xdrs, objp) - XDR *xdrs; - name *objp; +xdr_dirpath (XDR *xdrs, dirpath *objp) { + register int32_t *buf; - register long *buf; - - if (!xdr_string(xdrs, objp, MNTNAMLEN)) { - return (FALSE); - } - return (TRUE); + if (!xdr_string (xdrs, objp, MNTPATHLEN)) + return FALSE; + return TRUE; } bool_t -xdr_mountlist(xdrs, objp) - XDR *xdrs; - mountlist *objp; +xdr_name (XDR *xdrs, name *objp) { + register int32_t *buf; - register long *buf; - - if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct mountbody), (xdrproc_t)xdr_mountbody)) { - return (FALSE); - } - return (TRUE); + if (!xdr_string (xdrs, objp, MNTNAMLEN)) + return FALSE; + return TRUE; } bool_t -xdr_mountbody(xdrs, objp) - XDR *xdrs; - mountbody *objp; +xdr_mountlist (XDR *xdrs, mountlist *objp) { + register int32_t *buf; - register long *buf; - - if (!xdr_name(xdrs, &objp->ml_hostname)) { - return (FALSE); - } - if (!xdr_dirpath(xdrs, &objp->ml_directory)) { - return (FALSE); - } - if (!xdr_mountlist(xdrs, &objp->ml_next)) { - return (FALSE); - } - return (TRUE); + if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct mountbody), (xdrproc_t) xdr_mountbody)) + return FALSE; + return TRUE; } bool_t -xdr_groups(xdrs, objp) - XDR *xdrs; - groups *objp; +xdr_mountbody (XDR *xdrs, mountbody *objp) { + register int32_t *buf; + + if (!xdr_name (xdrs, &objp->ml_hostname)) + return FALSE; + if (!xdr_dirpath (xdrs, &objp->ml_directory)) + return FALSE; + if (!xdr_mountlist (xdrs, &objp->ml_next)) + return FALSE; + return TRUE; +} - register long *buf; +bool_t +xdr_groups (XDR *xdrs, groups *objp) +{ + register int32_t *buf; - if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct groupnode), (xdrproc_t)xdr_groupnode)) { - return (FALSE); - } - return (TRUE); + if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct groupnode), (xdrproc_t) xdr_groupnode)) + return FALSE; + return TRUE; } bool_t -xdr_groupnode(xdrs, objp) - XDR *xdrs; - groupnode *objp; +xdr_groupnode (XDR *xdrs, groupnode *objp) { + register int32_t *buf; - register long *buf; - - if (!xdr_name(xdrs, &objp->gr_name)) { - return (FALSE); - } - if (!xdr_groups(xdrs, &objp->gr_next)) { - return (FALSE); - } - return (TRUE); + if (!xdr_name (xdrs, &objp->gr_name)) + return FALSE; + if (!xdr_groups (xdrs, &objp->gr_next)) + return FALSE; + return TRUE; } bool_t -xdr_exports(xdrs, objp) - XDR *xdrs; - exports *objp; +xdr_exports (XDR *xdrs, exports *objp) { + register int32_t *buf; - register long *buf; - - if (!xdr_pointer(xdrs, (char **)objp, sizeof(struct exportnode), (xdrproc_t)xdr_exportnode)) { - return (FALSE); - } - return (TRUE); + if (!xdr_pointer (xdrs, (char **)objp, sizeof (struct exportnode), (xdrproc_t) xdr_exportnode)) + return FALSE; + return TRUE; } bool_t -xdr_exportnode(xdrs, objp) - XDR *xdrs; - exportnode *objp; +xdr_exportnode (XDR *xdrs, exportnode *objp) { - - register long *buf; - - if (!xdr_dirpath(xdrs, &objp->ex_dir)) { - return (FALSE); - } - if (!xdr_groups(xdrs, &objp->ex_groups)) { - return (FALSE); - } - if (!xdr_exports(xdrs, &objp->ex_next)) { - return (FALSE); - } - return (TRUE); + register int32_t *buf; + + if (!xdr_dirpath (xdrs, &objp->ex_dir)) + return FALSE; + if (!xdr_groups (xdrs, &objp->ex_groups)) + return FALSE; + if (!xdr_exports (xdrs, &objp->ex_next)) + return FALSE; + return TRUE; } bool_t -xdr_ppathcnf(xdrs, objp) - XDR *xdrs; - ppathcnf *objp; +xdr_ppathcnf (XDR *xdrs, ppathcnf *objp) { + register int32_t *buf; - register long *buf; - - int i; - - if (xdrs->x_op == XDR_ENCODE) { - buf = XDR_INLINE(xdrs,6 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_int(xdrs, &objp->pc_link_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_canon)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_input)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_name_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_path_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_pipe_buf)) { - return (FALSE); - } - - } - else { - IXDR_PUT_LONG(buf,objp->pc_link_max); - IXDR_PUT_SHORT(buf,objp->pc_max_canon); - IXDR_PUT_SHORT(buf,objp->pc_max_input); - IXDR_PUT_SHORT(buf,objp->pc_name_max); - IXDR_PUT_SHORT(buf,objp->pc_path_max); - IXDR_PUT_SHORT(buf,objp->pc_pipe_buf); - } - if (!xdr_u_char(xdrs, &objp->pc_vdisable)) { - return (FALSE); - } - if (!xdr_char(xdrs, &objp->pc_xxx)) { - return (FALSE); - } - buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); + int i; + + if (xdrs->x_op == XDR_ENCODE) { + /* On many machines XDR_INLINE returns a (long *) */ + buf = (int32_t *) XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_int (xdrs, &objp->pc_link_max)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_max_canon)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_max_input)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_name_max)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_path_max)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_pipe_buf)) + return FALSE; + + } else { + IXDR_PUT_LONG(buf, objp->pc_link_max); + IXDR_PUT_SHORT(buf, objp->pc_max_canon); + IXDR_PUT_SHORT(buf, objp->pc_max_input); + IXDR_PUT_SHORT(buf, objp->pc_name_max); + IXDR_PUT_SHORT(buf, objp->pc_path_max); + IXDR_PUT_SHORT(buf, objp->pc_pipe_buf); + } + if (!xdr_u_char (xdrs, &objp->pc_vdisable)) + return FALSE; + if (!xdr_char (xdrs, &objp->pc_xxx)) + return FALSE; + buf = (int32_t *) XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); if (buf == NULL) { - if (!xdr_vector(xdrs, (char *)objp->pc_mask, 2, sizeof(short), (xdrproc_t)xdr_short)) { - return (FALSE); - } - - } - else { - { register short *genp; - for ( i = 0,genp=objp->pc_mask; - i < 2; i++){ - IXDR_PUT_SHORT(buf,*genp++); - } - }; - } - - return (TRUE); + if (!xdr_vector (xdrs, (char *)objp->pc_mask, 2, + sizeof (short), (xdrproc_t) xdr_short)) + return FALSE; + } else { + { + register short *genp; + + for (i = 0, genp = objp->pc_mask; + i < 2; ++i) { + IXDR_PUT_SHORT(buf, *genp++); + } + } + } + return TRUE; } else if (xdrs->x_op == XDR_DECODE) { - buf = XDR_INLINE(xdrs,6 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_int(xdrs, &objp->pc_link_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_canon)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_input)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_name_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_path_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_pipe_buf)) { - return (FALSE); - } - - } - else { - objp->pc_link_max = IXDR_GET_LONG(buf); - objp->pc_max_canon = IXDR_GET_SHORT(buf); - objp->pc_max_input = IXDR_GET_SHORT(buf); - objp->pc_name_max = IXDR_GET_SHORT(buf); - objp->pc_path_max = IXDR_GET_SHORT(buf); - objp->pc_pipe_buf = IXDR_GET_SHORT(buf); - } - if (!xdr_u_char(xdrs, &objp->pc_vdisable)) { - return (FALSE); - } - if (!xdr_char(xdrs, &objp->pc_xxx)) { - return (FALSE); - } - buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); + buf = (int32_t *) XDR_INLINE (xdrs, 6 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_int (xdrs, &objp->pc_link_max)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_max_canon)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_max_input)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_name_max)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_path_max)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_pipe_buf)) + return FALSE; + + } else { + objp->pc_link_max = IXDR_GET_LONG(buf); + objp->pc_max_canon = IXDR_GET_SHORT(buf); + objp->pc_max_input = IXDR_GET_SHORT(buf); + objp->pc_name_max = IXDR_GET_SHORT(buf); + objp->pc_path_max = IXDR_GET_SHORT(buf); + objp->pc_pipe_buf = IXDR_GET_SHORT(buf); + } + if (!xdr_u_char (xdrs, &objp->pc_vdisable)) + return FALSE; + if (!xdr_char (xdrs, &objp->pc_xxx)) + return FALSE; + buf = (int32_t *) XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); if (buf == NULL) { - if (!xdr_vector(xdrs, (char *)objp->pc_mask, 2, sizeof(short), (xdrproc_t)xdr_short)) { - return (FALSE); - } - - } - else { - { register short *genp; - for ( i = 0,genp=objp->pc_mask; - i < 2; i++){ - *genp++ = IXDR_GET_SHORT(buf); - } - }; - } - return(TRUE); + if (!xdr_vector (xdrs, (char *)objp->pc_mask, 2, + sizeof (short), (xdrproc_t) xdr_short)) + return FALSE; + } else { + { + register short *genp; + + for (i = 0, genp = objp->pc_mask; + i < 2; ++i) { + *genp++ = IXDR_GET_SHORT(buf); + } + } + } + return TRUE; } - if (!xdr_int(xdrs, &objp->pc_link_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_canon)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_max_input)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_name_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_path_max)) { - return (FALSE); - } - if (!xdr_short(xdrs, &objp->pc_pipe_buf)) { - return (FALSE); - } - if (!xdr_u_char(xdrs, &objp->pc_vdisable)) { - return (FALSE); - } - if (!xdr_char(xdrs, &objp->pc_xxx)) { - return (FALSE); - } - if (!xdr_vector(xdrs, (char *)objp->pc_mask, 2, sizeof(short), (xdrproc_t)xdr_short)) { - return (FALSE); - } - return (TRUE); + if (!xdr_int (xdrs, &objp->pc_link_max)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_max_canon)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_max_input)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_name_max)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_path_max)) + return FALSE; + if (!xdr_short (xdrs, &objp->pc_pipe_buf)) + return FALSE; + if (!xdr_u_char (xdrs, &objp->pc_vdisable)) + return FALSE; + if (!xdr_char (xdrs, &objp->pc_xxx)) + return FALSE; + if (!xdr_vector (xdrs, (char *)objp->pc_mask, 2, + sizeof (short), (xdrproc_t) xdr_short)) + return FALSE; + return TRUE; } diff --git a/mount/swapon.8 b/mount/swapon.8 index 74f61eea..61cd3b37 100644 --- a/mount/swapon.8 +++ b/mount/swapon.8 @@ -111,9 +111,15 @@ flag is given. You should not use .B swapon on a file with holes. +Swap over NFS may not work. .SH SEE ALSO -.BR swapon "(2), " swapoff "(2), " fstab "(5), " init "(8), " mkswap (8), -.BR rc "(8), " mount (8) +.BR swapon (2), +.BR swapoff (2), +.BR fstab (5), +.BR init (8), +.BR mkswap (8), +.BR rc (8), +.BR mount (8) .SH FILES .I /dev/hd?? standard paging devices diff --git a/partx/Makefile b/partx/Makefile new file mode 100644 index 00000000..39237e01 --- /dev/null +++ b/partx/Makefile @@ -0,0 +1,14 @@ +OBJ = bsd.o dos.o partx.o solaris.o unixware.o + +all: addpart delpart partx + +partx: $(OBJ) + +addpart: addpart.o + +delpart: delpart.o + +clean: + rm -f $(OBJ) addpart.o delpart.o addpart delpart partx *~ + +$(OBJ): partx.h diff --git a/fdisk/addpart.c b/partx/addpart.c similarity index 100% rename from fdisk/addpart.c rename to partx/addpart.c diff --git a/partx/bsd.c b/partx/bsd.c new file mode 100644 index 00000000..531c36c2 --- /dev/null +++ b/partx/bsd.c @@ -0,0 +1,83 @@ +#include +#include "partx.h" + +#define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */ +#define XBSD_MAXPARTITIONS 16 +#define BSD_FS_UNUSED 0 + +struct bsd_disklabel { + unsigned int d_magic; /* the magic number */ + short int d_type; /* drive type */ + short int d_subtype; /* controller/d_type specific */ + char d_typename[16]; /* type name, e.g. "eagle" */ + char d_packname[16]; /* pack identifier */ + unsigned int d_secsize; /* # of bytes per sector */ + unsigned int d_nsectors; /* # of data sectors per track */ + unsigned int d_ntracks; /* # of tracks per cylinder */ + unsigned int d_ncylinders; /* # of data cylinders per unit */ + unsigned int d_secpercyl; /* # of data sectors per cylinder */ + unsigned int d_secperunit; /* # of data sectors per unit */ + unsigned short d_sparespertrack;/* # of spare sectors per track */ + unsigned short d_sparespercyl; /* # of spare sectors per cylinder */ + unsigned int d_acylinders; /* # of alt. cylinders per unit */ + unsigned short d_rpm; /* rotational speed */ + unsigned short d_interleave; /* hardware sector interleave */ + unsigned short d_trackskew; /* sector 0 skew, per track */ + unsigned short d_cylskew; /* sector 0 skew, per cylinder */ + unsigned int d_headswitch; /* head switch time, usec */ + unsigned int d_trkseek; /* track-to-track seek, usec */ + unsigned int d_flags; /* generic flags */ + unsigned int d_drivedata[5]; /* drive-type specific information */ + unsigned int d_spare[5]; /* reserved for future use */ + unsigned int d_magic2; /* the magic number (again) */ + unsigned short d_checksum; /* xor of data incl. partitions */ + + /* filesystem and partition information: */ + unsigned short d_npartitions; /* number of partitions in following */ + unsigned int d_bbsize; /* size of boot area at sn0, bytes */ + unsigned int d_sbsize; /* max size of fs superblock, bytes */ + struct bsd_partition { /* the partition table */ + unsigned int p_size; /* number of sectors in partition */ + unsigned int p_offset; /* starting sector */ + unsigned int p_fsize; /* filesystem basic fragment size */ + unsigned char p_fstype; /* filesystem type, see below */ + unsigned char p_frag; /* filesystem fragments per block */ + unsigned short p_cpg; /* filesystem cylinders per group */ + } d_partitions[XBSD_MAXPARTITIONS];/* actually may be more */ +}; + +int +read_bsd_pt(int fd, struct slice all, struct slice *sp, int ns) { + struct bsd_disklabel *l; + struct bsd_partition *p; + unsigned int offset = all.start; + int max_partitions; + char *bp; + int n = 0; + + bp = getblock(fd, offset+1); /* 1 sector suffices */ + if (bp == NULL) + return -1; + + l = (struct bsd_disklabel *) bp; + if (l->d_magic != BSD_DISKMAGIC) + return -1; + + max_partitions = 16; + if (l->d_npartitions < max_partitions) + max_partitions = l->d_npartitions; + for (p = l->d_partitions; p - l->d_partitions < max_partitions; p++) { + if (p->p_fstype == BSD_FS_UNUSED) + /* nothing */; + else if (n < ns) { + sp[n].start = p->p_offset; + sp[n].size = p->p_size; + n++; + } else { + fprintf(stderr, + "bsd_partition: too many slices\n"); + break; + } + } + return n; +} diff --git a/fdisk/delpart.c b/partx/delpart.c similarity index 100% rename from fdisk/delpart.c rename to partx/delpart.c diff --git a/partx/dos.c b/partx/dos.c new file mode 100644 index 00000000..b32801e0 --- /dev/null +++ b/partx/dos.c @@ -0,0 +1,106 @@ +#include +#include "partx.h" + +struct partition { + unsigned char boot_ind; /* 0x80 - active */ + unsigned char bh, bs, bc; + unsigned char sys_type; + unsigned char eh, es, ec; + unsigned int start_sect; + unsigned int nr_sects; +}; + +static int +is_extended(int type) { + return (type == 5 || type == 0xf || type == 0x85); +} + +static int +read_extended_partition(int fd, struct partition *ep, + struct slice *sp, int ns) { + struct partition *p; + unsigned long start, here, next; + unsigned char *bp; + int loopct = 0; + int moretodo = 1; + int i, n=0; + + here = start = ep->start_sect; + + while (moretodo) { + moretodo = 0; + if (++loopct > 100) + return n; + + bp = getblock(fd, here); + if (bp == NULL) + return n; + + if (bp[510] != 0x55 || bp[511] != 0xaa) + return n; + + p = (struct partition *) (bp + 0x1be); + + for (i=0; i<2; i++, p++) { + if (p->nr_sects == 0 || is_extended(p->sys_type)) + continue; + if (n < ns) { + sp[n].start = here + p->start_sect; + sp[n].size = p->nr_sects; + n++; + } else { + fprintf(stderr, + "dos_extd_partition: too many slices\n"); + return n; + } + loopct = 0; + } + + p -= 2; + for (i=0; i<2; i++, p++) { + if(p->nr_sects != 0 && is_extended(p->sys_type)) { + here = start + p->start_sect; + moretodo = 1; + break; + } + } + } + return n; +} + +int +read_dos_pt(int fd, struct slice all, struct slice *sp, int ns) { + struct partition *p; + unsigned long offset = all.start; + int i, n=0; + unsigned char *bp; + + bp = getblock(fd, offset); + if (bp == NULL) + return -1; + + if (bp[510] != 0x55 || bp[511] != 0xaa) + return -1; + + p = (struct partition *) (bp + 0x1be); + for (i=0; i<4; i++) { + /* always add, even if zero length */ + if (n < ns) { + sp[n].start = p->start_sect; + sp[n].size = p->nr_sects; + n++; + } else { + fprintf(stderr, + "dos_partition: too many slices\n"); + break; + } + p++; + } + p = (struct partition *) (bp + 0x1be); + for (i=0; i<4; i++) { + if (is_extended(p->sys_type)) + n += read_extended_partition(fd, p, sp+n, ns-n); + p++; + } + return n; +} diff --git a/partx/partx.c b/partx/partx.c new file mode 100644 index 00000000..212f651b --- /dev/null +++ b/partx/partx.c @@ -0,0 +1,395 @@ +/* + * Given a block device and a partition table type, + * try to parse the partition table, and list the + * contents. Optionally add or remove partitions. + * + * [This is not an fdisk - adding and removing partitions + * is not a change of the disk, but just telling the kernel + * about presence and numbering of on-disk partitions.] + * + * Call: + * partx [-{l|a|d}] [--type TYPE] [--nr M-N] [partition] wholedisk + * where TYPE is {dos|bsd|solaris|unixware}. + * + * Read wholedisk and add all partitions: + * partx -a wholedisk + * + * Subdivide a partition into slices (and delete or shrink the partition): + * [Not easy: one needs the partition number of partition - + * that is the last 4 or 6 bits of the minor; it can also be found + * in /proc/partitions; but there is no good direct way.] + * partx -a partition wholedisk + * + * Delete all partitions from wholedisk: + * partx -d wholedisk + * + * Delete partitions M-N from wholedisk: + * partx -d --nr M-N wholedisk + * + * aeb, 2000-03-21 -- sah is 42 now + */ + +#include +#include +#include +#include +#include +#include +#include +#include /* HDIO_GETGEO */ +#include +#define BLKGETSIZE _IO(0x12,96) /* return device size */ + +#include "partx.h" +static void errmerge(int err, int m, char *msg1, char *msg2); + +#define SIZE(a) (sizeof(a)/sizeof((a)[0])) + +#define MAXTYPES 64 +#define MAXSLICES 256 + +struct slice slices[MAXSLICES]; + +enum action { LIST, ADD, DELETE }; + +struct pt { + char *type; + ptreader *fn; +} pts[MAXTYPES]; +int ptct; + +addpts(char *t, ptreader f) { + if (ptct >= MAXTYPES) { + fprintf(stderr, "addpts: too many types\n"); + exit(1); + } + pts[ptct].type = t; + pts[ptct].fn = f; + ptct++; +} + +initpts(){ + addpts("dos", read_dos_pt); + addpts("bsd", read_bsd_pt); + addpts("solaris", read_solaris_pt); + addpts("unixware", read_unixware_pt); +} + +static char short_opts[] = "ladvn:t:"; +static const struct option long_opts[] = { + { "type", required_argument, NULL, 't' }, + { "nr", required_argument, NULL, 'n' }, + { NULL, 0, NULL, 0 } +}; + +int +main(int argc, char **argv){ + int fd, fd2, c, i, j, k, n; + long size; + struct hd_geometry g; + struct slice all; + struct blkpg_ioctl_arg a; + struct blkpg_partition pt; + struct pt *ptp; + enum action what = LIST; + char *p, *type, *diskdevice, *device; + int lower, upper; + int verbose = 0; + int ret = 0; + + initpts(); + + lower = upper = 0; + type = device = diskdevice = NULL; + + while ((c = getopt_long (argc, argv, short_opts, long_opts, NULL)) + != -1) switch(c) { + case 'l': + what = LIST; break; + case 'a': + what = ADD; break; + case 'd': + what = DELETE; break; + case 'n': + p = optarg; + lower = atoi(p); + p = index(p, '-'); + if (p) + upper = atoi(p+1); + else + upper = lower; + break; + case 't': + type = optarg; + break; + case 'v': + verbose = 1; + break; + case '?': + default: + fprintf(stderr, "unknown option\n"); + exit(1); + } + + if (optind == argc-2) { + device = argv[optind]; + diskdevice = argv[optind+1]; + } else if (optind == argc-1) { + diskdevice = device = argv[optind]; + } else { + fprintf(stderr, "call: partx -opts [device] wholedisk\n"); + exit(1); + } + + fd = open(diskdevice, O_RDONLY); + if (fd == -1) { + perror(diskdevice); + exit(1); + } + + /* remove the indicated partitions from the kernel partition tables */ + if (what == DELETE) { + if (device != diskdevice) { + fprintf(stderr, + "call: partx -d [--nr M-N] wholedisk\n"); + exit(1); + } + + if (!lower) + lower = 1; + + while (upper == 0 || lower <= upper) { + int err; + + pt.pno = lower; + pt.start = 0; + pt.length = 0; + pt.devname[0] = 0; + pt.volname[0] = 0; + a.op = BLKPG_DEL_PARTITION; + a.flags = 0; + a.datalen = sizeof(pt); + a.data = &pt; + if (ioctl(fd, BLKPG, &a) == -1) + err = errno; + else + err = 0; + errmerge(err, lower, + "error deleting partition %d: ", + "error deleting partitions %d-%d: "); + /* expected errors: + EBUSY: mounted or in use as swap + ENXIO: no such nonempty partition + EINVAL: not wholedisk, or bad pno + EACCES/EPERM: permission denied + */ + if (err && err != EBUSY && err != ENXIO) { + ret = 1; + break; + } + if (err == 0 && verbose) + printf("deleted partition %d\n", lower); + lower++; + } + errmerge(0, 0, + "error deleting partition %d: ", + "error deleting partitions %d-%d: "); + return ret; + } + + if (device != diskdevice) { + fd2 = open(device, O_RDONLY); + if (fd2 == -1) { + perror(device); + exit(1); + } + } else { + fd2 = fd; + } + + if (ioctl(fd, HDIO_GETGEO, &g)) { + perror("HDIO_GETGEO"); + exit(1); + } + if (g.start != 0) { + fprintf(stderr, "last arg is not the whole disk\n"); + fprintf(stderr, "call: partx -opts device wholedisk\n"); + exit(1); + } + + if (ioctl(fd2, HDIO_GETGEO, &g)) { + perror("HDIO_GETGEO"); + exit(1); + } + all.start = g.start; + + if(ioctl(fd2, BLKGETSIZE, &size)) { + perror("BLKGETSIZE"); + exit(1); + } + all.size = size; + + if (verbose) + printf("device %s: start %d size %d\n", + device, all.start, all.size); + + if (all.size == 0) { + fprintf(stderr, "That disk slice has size 0\n"); + exit(0); + } + if (all.size == 2) + all.size = 0; /* probably extended partition */ + + /* add the indicated partitions to the kernel partition tables */ + if (!lower) + lower = 1; + for (i = 0; i < ptct; i++) { + ptp = &pts[i]; + if (!type || !strcmp(type, ptp->type)) { + n = ptp->fn(fd, all, slices, SIZE(slices)); + if (n >= 0 && verbose) + printf("%s: %d slices\n", ptp->type, n); + if (n > 0 && (verbose || what == LIST)) { + for (j=0; j 0 && what == ADD) { + /* test for overlap, as in the case of an + extended partition, and reduce size */ + for (j=0; j slices[j].start && + slices[k].start < slices[j].start + + slices[j].size) { + slices[j].size = slices[k].start - + slices[j].start; + if (verbose) + printf("reduced size of " + "partition #%d to %d\n", + lower+j, + slices[j].size); + } + } + } + for (j=0; j /* _syscall */ +static +_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, + long long *, res, uint, wh); +#endif + +static int +sseek(int fd, unsigned int secnr) { + long long in, out; + in = ((long long) secnr << 9); + out = 1; + +#if !defined (__alpha__) && !defined (__ia64__) + if (_llseek (fd, in>>32, in & 0xffffffff, &out, SEEK_SET) != 0 + || out != in) +#else + if ((out = lseek(fd, in, SEEK_SET)) != in) +#endif + { + fprintf(stderr, "llseek error\n"); + return -1; + } + return 0; +} + +static +struct block { + unsigned int secnr; + char *block; + struct block *next; +} *blockhead; + +char * +getblock(int fd, unsigned int secnr) { + struct block *bp; + + for (bp = blockhead; bp; bp = bp->next) + if (bp->secnr == secnr) + return bp->block; + if (sseek(fd, secnr)) + return NULL; + bp = xmalloc(sizeof(struct block)); + bp->secnr = secnr; + bp->next = blockhead; + blockhead = bp; + bp->block = (char *) xmalloc(1024); + if (read(fd, bp->block, 1024) != 1024) { + fprintf(stderr, "read error, sector %d\n", secnr); + bp->block = NULL; + } + return bp->block; +} + +/* call with errno and integer m and error message */ +/* merge to interval m-n */ +static void +errmerge(int err, int m, char *msg1, char *msg2) { + static int preverr, firstm, prevm; + + if (err != preverr) { + if (preverr) { + if (firstm == prevm) + fprintf(stderr, msg1, firstm); + else + fprintf(stderr, msg2, firstm, prevm); + errno = preverr; + perror("BLKPG"); + } + preverr = err; + firstm = prevm = m; + } else + prevm = m; +} diff --git a/partx/partx.h b/partx/partx.h new file mode 100644 index 00000000..b96588a5 --- /dev/null +++ b/partx/partx.h @@ -0,0 +1,26 @@ +/* + * For each partition type there is a routine that takes + * a block device and a range, and returns the list of + * slices found there in the supplied array SP that can + * hold NS entries. The return value is the number of + * entries stored, or -1 if the appropriate type is not + * present. + */ + + +/* units: 512 byte sectors */ +struct slice { + unsigned int start; + unsigned int size; +}; + +typedef int (ptreader)(int fd, struct slice all, struct slice *sp, int ns); + +extern ptreader read_dos_pt, read_bsd_pt, read_solaris_pt, read_unixware_pt; + +char *getblock(int fd, unsigned int secnr); + +static inline int +four2int(unsigned char *p) { + return p[0] + (p[1]<<8) + (p[2]<<16) + (p[3]<<24); +} diff --git a/partx/solaris.c b/partx/solaris.c new file mode 100644 index 00000000..64c39664 --- /dev/null +++ b/partx/solaris.c @@ -0,0 +1,70 @@ +#include +#include /* time_t */ +#include "partx.h" + +#define SOLARIS_X86_NUMSLICE 8 +#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL) + +typedef int daddr_t; /* or long - check */ + +struct solaris_x86_slice { + unsigned short s_tag; /* ID tag of partition */ + unsigned short s_flag; /* permision flags */ + daddr_t s_start; /* start sector no of partition */ + long s_size; /* # of blocks in partition */ +}; + +struct solaris_x86_vtoc { + unsigned long v_bootinfo[3]; /* info for mboot */ + unsigned long v_sanity; /* to verify vtoc sanity */ + unsigned long v_version; /* layout version */ + char v_volume[8]; /* volume name */ + unsigned short v_sectorsz; /* sector size in bytes */ + unsigned short v_nparts; /* number of partitions */ + unsigned long v_reserved[10]; /* free space */ + struct solaris_x86_slice + v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */ + time_t timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp */ + char v_asciilabel[128]; /* for compatibility */ +}; + +int +read_solaris_pt(int fd, struct slice all, struct slice *sp, int ns) { + struct solaris_x86_vtoc *v; + struct solaris_x86_slice *s; + unsigned int offset = all.start; + int i, n; + char *bp; + + bp = getblock(fd, offset+1); /* 1 sector suffices */ + if (bp == NULL) + return -1; + + v = (struct solaris_x86_vtoc *) bp; + if(v->v_sanity != SOLARIS_X86_VTOC_SANE) + return -1; + + if(v->v_version != 1) { + fprintf(stderr, "Cannot handle solaris version %ld vtoc\n", + v->v_version); + return 0; + } + + for(i=0, n=0; iv_slice[i]; + + if (s->s_size == 0) + continue; + if (n < ns) { + sp[n].start = offset + s->s_start; + sp[n].size = s->s_size; + n++; + } else { + fprintf(stderr, + "solaris_x86_partition: too many slices\n"); + break; + } + } + return n; +} + diff --git a/partx/unixware.c b/partx/unixware.c new file mode 100644 index 00000000..3b3f21e1 --- /dev/null +++ b/partx/unixware.c @@ -0,0 +1,83 @@ +#include +#include "partx.h" + +#define UNIXWARE_FS_UNUSED 0 +#define UNIXWARE_NUMSLICE 16 +#define UNIXWARE_DISKMAGIC (0xCA5E600DUL) +#define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) + +struct unixware_slice { + unsigned short s_label; /* label */ + unsigned short s_flags; /* permission flags */ + unsigned int start_sect; /* starting sector */ + unsigned int nr_sects; /* number of sectors in slice */ +}; + +struct unixware_disklabel { + unsigned int d_type; /* drive type */ + unsigned char d_magic[4]; /* the magic number */ + unsigned int d_version; /* version number */ + char d_serial[12]; /* serial number of the device */ + unsigned int d_ncylinders; /* # of data cylinders per device */ + unsigned int d_ntracks; /* # of tracks per cylinder */ + unsigned int d_nsectors; /* # of data sectors per track */ + unsigned int d_secsize; /* # of bytes per sector */ + unsigned int d_part_start; /* # of first sector of this partition */ + unsigned int d_unknown1[12]; /* ? */ + unsigned int d_alt_tbl; /* byte offset of alternate table */ + unsigned int d_alt_len; /* byte length of alternate table */ + unsigned int d_phys_cyl; /* # of physical cylinders per device */ + unsigned int d_phys_trk; /* # of physical tracks per cylinder */ + unsigned int d_phys_sec; /* # of physical sectors per track */ + unsigned int d_phys_bytes; /* # of physical bytes per sector */ + unsigned int d_unknown2; /* ? */ + unsigned int d_unknown3; /* ? */ + unsigned int d_pad[8]; /* pad */ + + struct unixware_vtoc { + unsigned char v_magic[4]; /* the magic number */ + unsigned int v_version; /* version number */ + char v_name[8]; /* volume name */ + unsigned short v_nslices; /* # of slices */ + unsigned short v_unknown1; /* ? */ + unsigned int v_reserved[10]; /* reserved */ + struct unixware_slice + v_slice[UNIXWARE_NUMSLICE]; /* slice headers */ + } vtoc; + +}; /* 408 */ + +int +read_unixware_pt(int fd, struct slice all, struct slice *sp, int ns) { + struct unixware_disklabel *l; + struct unixware_slice *p; + unsigned int offset = all.start; + char *bp; + int n = 0; + + bp = getblock(fd, offset+29); /* 1 sector suffices */ + if (bp == NULL) + return -1; + + l = (struct unixware_disklabel *) bp; + if (four2int(l->d_magic) != UNIXWARE_DISKMAGIC || + four2int(l->vtoc.v_magic) != UNIXWARE_DISKMAGIC2) + return -1; + + p = &l->vtoc.v_slice[1]; /* slice 0 is the whole disk. */ + while (p - &l->vtoc.v_slice[0] < UNIXWARE_NUMSLICE) { + if (p->s_label == UNIXWARE_FS_UNUSED) + /* nothing */; + else if (n < ns) { + sp[n].start = p->start_sect; + sp[n].size = p->nr_sects; + n++; + } else { + fprintf(stderr, + "unixware_partition: too many slices\n"); + break; + } + p++; + } + return n; +} diff --git a/po/Makefile b/po/Makefile index 7ee4053c..3e59fedc 100644 --- a/po/Makefile +++ b/po/Makefile @@ -38,9 +38,9 @@ INCLUDES = -I.. -I$(INTL) COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) # Enter here all .po files -POFILES = cs.po de.po fr.po it.po ja.po nl.po pt_BR.po +POFILES = cs.po de.po es.po fr.po it.po ja.po nl.po pt_BR.po # the same but with .gmo -GMOFILES = cs.gmo de.gmo fr.gmo it.gmo ja.gmo nl.gmo pt_BR.gmo +GMOFILES = cs.gmo de.gmo es.gmo fr.gmo it.gmo ja.gmo nl.gmo pt_BR.gmo CATALOGS = $(GMOFILES) CATOBJEXT = .gmo diff --git a/po/POTFILES.in b/po/POTFILES.in index 21c17da9..7ea5b805 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -59,14 +59,11 @@ misc-utils/write.c mount/fstab.c mount/getusername.c mount/lomount.c -mount/losetup.c mount/mntent.c mount/mount.c mount/mount_by_label.c mount/mount_guess_fstype.c mount/nfsmount.c -mount/nfsmount_clnt.c -mount/nfsmount_xdr.c mount/realpath.c mount/sundries.c mount/swapon.c diff --git a/po/cat-id-tbl.c b/po/cat-id-tbl.c index b431c0ae..b5f9b134 100644 --- a/po/cat-id-tbl.c +++ b/po/cat-id-tbl.c @@ -28,9 +28,9 @@ const struct _msg_ent _msg_tbl[] = { {"unknown", 19}, {"Waiting for clock tick...\n", 20}, {"...got clock tick\n", 21}, - {"Invalid values in hardware clock: %2d/%.2d/%.2d %.2d:%.2d:%.2d\n", 22}, - {"Hw clock time : %2d/%.2d/%.2d %.2d:%.2d:%.2d = %d seconds since 1969\n", 23}, - {"Time read from Hardware Clock: %02d:%02d:%02d\n", 24}, + {"Invalid values in hardware clock: %4d/%.2d/%.2d %.2d:%.2d:%.2d\n", 22}, + {"Hw clock time : %4d/%.2d/%.2d %.2d:%.2d:%.2d = %ld seconds since 1969\n", 23}, + {"Time read from Hardware Clock: %4d/%.2d/%.2d %02d:%02d:%02d\n", 24}, {"Setting Hardware Clock to %.2d:%.2d:%.2d = %d seconds since 1969\n", 25}, {"Clock not changed - testing only.\n", 26}, {"\ @@ -54,8 +54,8 @@ The command was:\n\ The response was:\n\ %s\n", 35}, {"\ -The date command issued by %s returnedsomething other than an integer where \ -the convertedtime value was expected.\n\ +The date command issued by %s returned something other than an integer where \ +the converted time value was expected.\n\ The command was:\n\ %s\n\ The response was:\n\ @@ -66,7 +66,7 @@ The Hardware Clock does not contain a valid time, so we cannot set the \ System Time from it.\n", 38}, {"Calling settimeofday:\n", 39}, {"\ttv.tv_sec = %ld, tv.tv_usec = %ld\n", 40}, - {"\ttz.tz_minuteswest = %ld\n", 41}, + {"\ttz.tz_minuteswest = %d\n", 41}, {"Not setting system clock because running in test mode.\n", 42}, {"Must be superuser to set system clock.\n", 43}, {"settimeofday() failed", 44}, @@ -143,158 +143,160 @@ You can only perform one function at a time.\n", 67}, both.\n", 68}, {"No usable set-to time. Cannot set clock.\n", 69}, {"Sorry, only the superuser can change the Hardware Clock.\n", 70}, + {"Sorry, only the superuser can change the System Clock.\n", 71}, {"\ Sorry, only the superuser can change the Hardware Clock epoch in the \ -kernel.\n", 71}, - {"\ -Cannot access the Hardware Clock via any known method. Use --debug option \ -to see the details of our search for an access method.\n", 72}, - {"Waiting in loop for time from KDGHWCLK to change\n", 73}, - {"KDGHWCLK ioctl to read time failed", 74}, - {"Timed out waiting for time change.\n", 75}, - {"KDGHWCLK ioctl to read time failed in loop", 76}, - {"ioctl() failed to read time from /dev/tty1", 77}, - {"ioctl() to open /dev/tty1 failed", 78}, - {"KDGHWCLK ioctl failed", 79}, - {"Can't open /dev/tty1", 80}, - {"ioctl() to /dev/rtc to read the time failed.\n", 81}, - {"Waiting in loop for time from /dev/rtc to change\n", 82}, - {"open() of /dev/rtc failed", 83}, - {"/dev/rtc does not have interrupt functions. ", 84}, - {"read() to /dev/rtc to wait for clock tick failed", 85}, - {"ioctl() to /dev/rtc to turn off update interrupts failed", 86}, - {"ioctl() to /dev/rtc to turn on update interrupts failed unexpectedly", 87}, - {"Unable to open /dev/rtc", 88}, - {"ioctl() to /dev/rtc to set the time failed.\n", 89}, - {"ioctl(%s) was successful.\n", 90}, - {"Open of /dev/rtc failed", 91}, +kernel.\n", 72}, + {"Cannot access the Hardware Clock via any known method.\n", 73}, + {"\ +Use the --debug option to see the details of our search for an access \ +method.\n", 74}, + {"Waiting in loop for time from KDGHWCLK to change\n", 75}, + {"KDGHWCLK ioctl to read time failed", 76}, + {"Timed out waiting for time change.\n", 77}, + {"KDGHWCLK ioctl to read time failed in loop", 78}, + {"ioctl() failed to read time from /dev/tty1", 79}, + {"ioctl() to open /dev/tty1 failed", 80}, + {"KDGHWCLK ioctl failed", 81}, + {"Can't open /dev/tty1", 82}, + {"ioctl() to /dev/rtc to read the time failed.\n", 83}, + {"Waiting in loop for time from /dev/rtc to change\n", 84}, + {"open() of /dev/rtc failed", 85}, + {"/dev/rtc does not have interrupt functions. ", 86}, + {"read() to /dev/rtc to wait for clock tick failed", 87}, + {"ioctl() to /dev/rtc to turn off update interrupts failed", 88}, + {"ioctl() to /dev/rtc to turn on update interrupts failed unexpectedly", 89}, + {"Unable to open /dev/rtc", 90}, + {"ioctl() to /dev/rtc to set the time failed.\n", 91}, + {"ioctl(%s) was successful.\n", 92}, + {"Open of /dev/rtc failed", 93}, {"\ To manipulate the epoch value in the kernel, we must access the Linux 'rtc' \ device driver via the device special file /dev/rtc. This file does not \ -exist on this system.\n", 92}, - {"ioctl(RTC_EPOCH_READ) to /dev/rtc failed", 93}, - {"we have read epoch %ld from /dev/rtc with RTC_EPOCH_READ ioctl.\n", 94}, - {"The epoch value may not be less than 1900. You requested %ld\n", 95}, - {"setting epoch to %ld with RTC_EPOCH_SET ioctl to /dev/rtc.\n", 96}, +exist on this system.\n", 94}, + {"ioctl(RTC_EPOCH_READ) to /dev/rtc failed", 95}, + {"we have read epoch %ld from /dev/rtc with RTC_EPOCH_READ ioctl.\n", 96}, + {"The epoch value may not be less than 1900. You requested %ld\n", 97}, + {"setting epoch to %ld with RTC_EPOCH_SET ioctl to /dev/rtc.\n", 98}, {"\ The kernel device driver for /dev/rtc does not have the RTC_EPOCH_SET \ -ioctl.\n", 97}, - {"ioctl(RTC_EPOCH_SET) to /dev/rtc failed", 98}, - {"invalid number `%s'\n", 99}, - {"number `%s' to `%s' out of range\n", 100}, - {"unrecognized option `%s'\n", 101}, - {"option `%s' requires an argument\n", 102}, - {"option `%s' doesn't allow an argument\n", 103}, - {"unrecognized option `-%c'\n", 104}, - {"set read-only", 105}, - {"set read-write", 106}, - {"get read-only", 107}, - {"get sectorsize", 108}, - {"get size", 109}, - {"set readahead", 110}, - {"get readahead", 111}, - {"flush buffers", 112}, - {"reread partition table", 113}, - {"Usage: %s [-V] [-v|-q] commands devices\n", 114}, - {"Available commands:\n", 115}, - {"%s: Unknown command: %s\n", 116}, - {"%s requires an argument\n", 117}, - {"Formatting ... ", 118}, - {"done\n", 119}, - {"Verifying ... ", 120}, - {"Read: ", 121}, - {"Problem reading cylinder %d, expected %d, read %d\n", 122}, +ioctl.\n", 99}, + {"ioctl(RTC_EPOCH_SET) to /dev/rtc failed", 100}, + {"invalid number `%s'\n", 101}, + {"number `%s' to `%s' out of range\n", 102}, + {"unrecognized option `%s'\n", 103}, + {"option `%s' requires an argument\n", 104}, + {"option `%s' doesn't allow an argument\n", 105}, + {"unrecognized option `-%c'\n", 106}, + {"set read-only", 107}, + {"set read-write", 108}, + {"get read-only", 109}, + {"get sectorsize", 110}, + {"get size", 111}, + {"set readahead", 112}, + {"get readahead", 113}, + {"flush buffers", 114}, + {"reread partition table", 115}, + {"Usage: %s [-V] [-v|-q] commands devices\n", 116}, + {"Available commands:\n", 117}, + {"%s: Unknown command: %s\n", 118}, + {"%s requires an argument\n", 119}, + {"Formatting ... ", 120}, + {"done\n", 121}, + {"Verifying ... ", 122}, + {"Read: ", 123}, + {"Problem reading cylinder %d, expected %d, read %d\n", 124}, {"\ bad data in cyl %d\n\ -Continuing ... ", 123}, - {"usage: %s [ -n ] device\n", 124}, - {"%s from %s\n", 125}, - {"%s: not a floppy device\n", 126}, - {"Could not determine current format type", 127}, - {"%s-sided, %d tracks, %d sec/track. Total capacity %d kB.\n", 128}, - {"Double", 129}, - {"Single", 130}, - {"Usage: %s [-larvsmf] /dev/name\n", 131}, - {"%s is mounted.\t ", 132}, - {"Do you really want to continue", 133}, - {"check aborted.\n", 134}, - {"Zone nr < FIRSTZONE in file `", 135}, - {"Zone nr >= ZONES in file `", 136}, - {"Remove block", 137}, - {"Read error: unable to seek to block in file '", 138}, - {"Read error: bad block in file '", 139}, +Continuing ... ", 125}, + {"usage: %s [ -n ] device\n", 126}, + {"%s from %s\n", 127}, + {"%s: not a floppy device\n", 128}, + {"Could not determine current format type", 129}, + {"%s-sided, %d tracks, %d sec/track. Total capacity %d kB.\n", 130}, + {"Double", 131}, + {"Single", 132}, + {"Usage: %s [-larvsmf] /dev/name\n", 133}, + {"%s is mounted.\t ", 134}, + {"Do you really want to continue", 135}, + {"check aborted.\n", 136}, + {"Zone nr < FIRSTZONE in file `", 137}, + {"Zone nr >= ZONES in file `", 138}, + {"Remove block", 139}, + {"Read error: unable to seek to block in file '", 140}, + {"Read error: bad block in file '", 141}, {"\ Internal error: trying to write bad block\n\ -Write request ignored\n", 140}, - {"seek failed in write_block", 141}, - {"Write error: bad block in file '", 142}, - {"seek failed in write_super_block", 143}, - {"unable to write super-block", 144}, - {"Unable to write inode map", 145}, - {"Unable to write zone map", 146}, - {"Unable to write inodes", 147}, - {"seek failed", 148}, - {"unable to read super block", 149}, - {"bad magic number in super-block", 150}, - {"Only 1k blocks/zones supported", 151}, - {"bad s_imap_blocks field in super-block", 152}, - {"bad s_zmap_blocks field in super-block", 153}, - {"Unable to allocate buffer for inode map", 154}, - {"Unable to allocate buffer for inodes", 155}, - {"Unable to allocate buffer for inode count", 156}, - {"Unable to allocate buffer for zone count", 157}, - {"Unable to read inode map", 158}, - {"Unable to read zone map", 159}, - {"Unable to read inodes", 160}, - {"Warning: Firstzone != Norm_firstzone\n", 161}, - {"%ld inodes\n", 162}, - {"%ld blocks\n", 163}, - {"Firstdatazone=%ld (%ld)\n", 164}, - {"Zonesize=%d\n", 165}, - {"Maxsize=%ld\n", 166}, - {"Filesystem state=%d\n", 167}, +Write request ignored\n", 142}, + {"seek failed in write_block", 143}, + {"Write error: bad block in file '", 144}, + {"seek failed in write_super_block", 145}, + {"unable to write super-block", 146}, + {"Unable to write inode map", 147}, + {"Unable to write zone map", 148}, + {"Unable to write inodes", 149}, + {"seek failed", 150}, + {"unable to read super block", 151}, + {"bad magic number in super-block", 152}, + {"Only 1k blocks/zones supported", 153}, + {"bad s_imap_blocks field in super-block", 154}, + {"bad s_zmap_blocks field in super-block", 155}, + {"Unable to allocate buffer for inode map", 156}, + {"Unable to allocate buffer for inodes", 157}, + {"Unable to allocate buffer for inode count", 158}, + {"Unable to allocate buffer for zone count", 159}, + {"Unable to read inode map", 160}, + {"Unable to read zone map", 161}, + {"Unable to read inodes", 162}, + {"Warning: Firstzone != Norm_firstzone\n", 163}, + {"%ld inodes\n", 164}, + {"%ld blocks\n", 165}, + {"Firstdatazone=%ld (%ld)\n", 166}, + {"Zonesize=%d\n", 167}, + {"Maxsize=%ld\n", 168}, + {"Filesystem state=%d\n", 169}, {"\ namelen=%d\n\ -\n", 168}, - {"Inode %d marked not used, but used for file '", 169}, - {"Mark in use", 170}, - {" has mode %05o\n", 171}, - {"Warning: inode count too big.\n", 172}, - {"root inode isn't a directory", 173}, - {"Block has been used before. Now in file `", 174}, - {"Clear", 175}, - {"Block %d in file `", 176}, - {"' is marked not in use.", 177}, - {"Correct", 178}, - {" contains a bad inode number for file '", 179}, - {" Remove", 180}, - {": bad directory: '.' isn't first\n", 181}, - {": bad directory: '..' isn't second\n", 182}, - {"internal error", 183}, - {": bad directory: size<32", 184}, - {": bad directory: size < 32", 185}, - {"seek failed in bad_zone", 186}, - {"Inode %d mode not cleared.", 187}, - {"Inode %d not used, marked used in the bitmap.", 188}, - {"Inode %d used, marked unused in the bitmap.", 189}, - {"Inode %d (mode = %07o), i_nlinks=%d, counted=%d.", 190}, - {"Set i_nlinks to count", 191}, - {"Zone %d: marked in use, no file uses it.", 192}, - {"Unmark", 193}, - {"Zone %d: %sin use, counted=%d\n", 194}, - {"not ", 195}, - {"Set", 196}, - {"bad inode size", 197}, - {"bad v2 inode size", 198}, - {"need terminal for interactive repairs", 199}, - {"unable to open '%s'", 200}, - {"%s is clean, no check.\n", 201}, - {"Forcing filesystem check on %s.\n", 202}, - {"Filesystem on %s is dirty, needs checking.\n", 203}, +\n", 170}, + {"Inode %d marked not used, but used for file '", 171}, + {"Mark in use", 172}, + {" has mode %05o\n", 173}, + {"Warning: inode count too big.\n", 174}, + {"root inode isn't a directory", 175}, + {"Block has been used before. Now in file `", 176}, + {"Clear", 177}, + {"Block %d in file `", 178}, + {"' is marked not in use.", 179}, + {"Correct", 180}, + {" contains a bad inode number for file '", 181}, + {" Remove", 182}, + {": bad directory: '.' isn't first\n", 183}, + {": bad directory: '..' isn't second\n", 184}, + {"internal error", 185}, + {": bad directory: size<32", 186}, + {": bad directory: size < 32", 187}, + {"seek failed in bad_zone", 188}, + {"Inode %d mode not cleared.", 189}, + {"Inode %d not used, marked used in the bitmap.", 190}, + {"Inode %d used, marked unused in the bitmap.", 191}, + {"Inode %d (mode = %07o), i_nlinks=%d, counted=%d.", 192}, + {"Set i_nlinks to count", 193}, + {"Zone %d: marked in use, no file uses it.", 194}, + {"Unmark", 195}, + {"Zone %d: %sin use, counted=%d\n", 196}, + {"not ", 197}, + {"Set", 198}, + {"bad inode size", 199}, + {"bad v2 inode size", 200}, + {"need terminal for interactive repairs", 201}, + {"unable to open '%s'", 202}, + {"%s is clean, no check.\n", 203}, + {"Forcing filesystem check on %s.\n", 204}, + {"Filesystem on %s is dirty, needs checking.\n", 205}, {"\ \n\ -%6ld inodes used (%ld%%)\n", 204}, - {"%6ld zones used (%ld%%)\n", 205}, +%6ld inodes used (%ld%%)\n", 206}, + {"%6ld zones used (%ld%%)\n", 207}, {"\ \n\ %6d regular files\n\ @@ -304,272 +306,272 @@ namelen=%d\n\ %6d links\n\ %6d symbolic links\n\ ------\n\ -%6d files\n", 206}, +%6d files\n", 208}, {"\ ----------------------------\n\ FILE SYSTEM HAS BEEN CHANGED\n\ -----------------------------\n", 207}, - {"Usage: mkfs [-V] [-t fstype] [fs-options] device [size]\n", 208}, - {"%s: Out of memory!\n", 209}, - {"mkfs version %s (%s)\n", 210}, - {"Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n", 211}, - {"%s is mounted; will not make a filesystem here!", 212}, - {"seek to boot block failed in write_tables", 213}, - {"unable to clear boot sector", 214}, - {"seek failed in write_tables", 215}, - {"unable to write inode map", 216}, - {"unable to write zone map", 217}, - {"unable to write inodes", 218}, - {"write failed in write_block", 219}, - {"too many bad blocks", 220}, - {"not enough good blocks", 221}, - {"unable to allocate buffers for maps", 222}, - {"unable to allocate buffer for inodes", 223}, +----------------------------\n", 209}, + {"Usage: mkfs [-V] [-t fstype] [fs-options] device [size]\n", 210}, + {"%s: Out of memory!\n", 211}, + {"mkfs version %s (%s)\n", 212}, + {"Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n", 213}, + {"%s is mounted; will not make a filesystem here!", 214}, + {"seek to boot block failed in write_tables", 215}, + {"unable to clear boot sector", 216}, + {"seek failed in write_tables", 217}, + {"unable to write inode map", 218}, + {"unable to write zone map", 219}, + {"unable to write inodes", 220}, + {"write failed in write_block", 221}, + {"too many bad blocks", 222}, + {"not enough good blocks", 223}, + {"unable to allocate buffers for maps", 224}, + {"unable to allocate buffer for inodes", 225}, {"\ Maxsize=%ld\n\ -\n", 224}, - {"seek failed during testing of blocks", 225}, - {"Weird values in do_check: probably bugs\n", 226}, - {"seek failed in check_blocks", 227}, - {"bad blocks before data-area: cannot make fs", 228}, - {"%d bad blocks\n", 229}, - {"one bad block\n", 230}, - {"can't open file of bad blocks", 231}, - {"%s: not compiled with minix v2 support\n", 232}, - {"strtol error: number of blocks not specified", 233}, - {"unable to open %s", 234}, - {"unable to stat %s", 235}, - {"will not try to make filesystem on '%s'", 236}, - {"Bad user-specified page size %d\n", 237}, - {"Using user-specified page size %d, instead of the system values %d/%d\n", 238}, - {"Assuming pages of size %d (not %d)\n", 239}, - {"Usage: %s [-c] [-v0|-v1] [-pPAGESZ] /dev/name [blocks]\n", 240}, - {"too many bad pages", 241}, - {"Out of memory", 242}, - {"one bad page\n", 243}, - {"%d bad pages\n", 244}, - {"%s: error: Nowhere to set up swap on?\n", 245}, - {"%s: error: size %ld is larger than device size %d\n", 246}, - {"%s: error: unknown version %d\n", 247}, - {"%s: error: swap area needs to be at least %ldkB\n", 248}, - {"%s: warning: truncating swap area to %ldkB\n", 249}, - {"Will not try to make swapdevice on '%s'", 250}, - {"fatal: first page unreadable", 251}, +\n", 226}, + {"seek failed during testing of blocks", 227}, + {"Weird values in do_check: probably bugs\n", 228}, + {"seek failed in check_blocks", 229}, + {"bad blocks before data-area: cannot make fs", 230}, + {"%d bad blocks\n", 231}, + {"one bad block\n", 232}, + {"can't open file of bad blocks", 233}, + {"%s: not compiled with minix v2 support\n", 234}, + {"strtol error: number of blocks not specified", 235}, + {"unable to open %s", 236}, + {"unable to stat %s", 237}, + {"will not try to make filesystem on '%s'", 238}, + {"Bad user-specified page size %d\n", 239}, + {"Using user-specified page size %d, instead of the system values %d/%d\n", 240}, + {"Assuming pages of size %d (not %d)\n", 241}, + {"Usage: %s [-c] [-v0|-v1] [-pPAGESZ] /dev/name [blocks]\n", 242}, + {"too many bad pages", 243}, + {"Out of memory", 244}, + {"one bad page\n", 245}, + {"%d bad pages\n", 246}, + {"%s: error: Nowhere to set up swap on?\n", 247}, + {"%s: error: size %ld is larger than device size %d\n", 248}, + {"%s: error: unknown version %d\n", 249}, + {"%s: error: swap area needs to be at least %ldkB\n", 250}, + {"%s: warning: truncating swap area to %ldkB\n", 251}, + {"Will not try to make swapdevice on '%s'", 252}, + {"fatal: first page unreadable", 253}, {"\ %s: Device '%s' contains a valid Sun disklabel.\n\ This probably means creating v0 swap would destroy your partition table\n\ No swap created. If you really want to create swap v0 on that device, use\n\ -the -f option to force it.\n", 252}, - {"Unable to set up swap-space: unreadable", 253}, - {"Setting up swapspace version %d, size = %ld bytes\n", 254}, - {"unable to rewind swap-device", 255}, - {"unable to write signature page", 256}, - {"fsync failed", 257}, - {"Invalid number: %s\n", 258}, - {"Syntax error: '%s'\n", 259}, - {"No such parameter set: '%s'\n", 260}, - {"usage: %s [ -p ] dev name\n", 261}, - {"\ - %s [ -p ] dev size sect heads tracks stretch gap rate spec1 fmt_gap\n", 262}, - {" %s [ -c | -y | -n | -d ] dev\n", 263}, - {" %s [ -c | -y | -n ] dev\n", 264}, - {"Unusable", 265}, - {"Free Space", 266}, - {"Linux ext2", 267}, - {"Linux", 268}, - {"OS/2 HPFS", 269}, - {"OS/2 IFS", 270}, - {"NTFS", 271}, - {"Disk has been changed.\n", 272}, - {"Reboot the system to ensure the partition table is correctly updated.\n", 273}, +the -f option to force it.\n", 254}, + {"Unable to set up swap-space: unreadable", 255}, + {"Setting up swapspace version %d, size = %ld bytes\n", 256}, + {"unable to rewind swap-device", 257}, + {"unable to write signature page", 258}, + {"fsync failed", 259}, + {"Invalid number: %s\n", 260}, + {"Syntax error: '%s'\n", 261}, + {"No such parameter set: '%s'\n", 262}, + {"usage: %s [ -p ] dev name\n", 263}, + {"\ + %s [ -p ] dev size sect heads tracks stretch gap rate spec1 fmt_gap\n", 264}, + {" %s [ -c | -y | -n | -d ] dev\n", 265}, + {" %s [ -c | -y | -n ] dev\n", 266}, + {"Unusable", 267}, + {"Free Space", 268}, + {"Linux ext2", 269}, + {"Linux", 270}, + {"OS/2 HPFS", 271}, + {"OS/2 IFS", 272}, + {"NTFS", 273}, + {"Disk has been changed.\n", 274}, + {"Reboot the system to ensure the partition table is correctly updated.\n", 275}, {"\ \n\ WARNING: If you have created or modified any\n\ DOS 6.x partitions, please see the cfdisk manual\n\ -page for additional information.\n", 274}, - {"FATAL ERROR", 275}, - {"Press any key to exit cfdisk", 276}, - {"Cannot seek on disk drive", 277}, - {"Cannot read disk drive", 278}, - {"Cannot write disk drive", 279}, - {"Too many partitions", 280}, - {"Partition begins before sector 0", 281}, - {"Partition ends before sector 0", 282}, - {"Partition begins after end-of-disk", 283}, - {"Partition ends after end-of-disk", 284}, - {"logical partitions not in disk order", 285}, - {"logical partitions overlap", 286}, - {"enlarged logical partitions overlap", 287}, - {"\ -!!!! Internal error creating logical drive with no extended partition !!!!", 288}, - {"\ -Cannot create logical drive here -- would create two extended partitions", 289}, - {"Menu item too long. Menu may look odd.", 290}, - {"Menu without direction. Defaulting horizontal.", 291}, - {"Illegal key", 292}, - {"Press a key to continue", 293}, - {"Primary", 294}, - {"Create a new primary partition", 295}, - {"Logical", 296}, - {"Create a new logical partition", 297}, - {"Cancel", 298}, - {"Don't create a partition", 299}, - {"!!! Internal error !!!", 300}, - {"Size (in MB): ", 301}, - {"Beginning", 302}, - {"Add partition at beginning of free space", 303}, - {"End", 304}, - {"Add partition at end of free space", 305}, - {"No room to create the extended partition", 306}, - {"Bad signature on partition table", 307}, - {"You specified more cylinders than fit on disk", 308}, - {"Cannot open disk drive", 309}, - {"Opened disk read-only - you have no permission to write", 310}, - {"Cannot get disk size", 311}, - {"Bad primary partition", 312}, - {"Bad logical partition", 313}, - {"Warning!! This may destroy data on your disk!", 314}, - {"Are you sure you want write the partition table to disk? (yes or no): ", 315}, - {"no", 316}, - {"Did not write partition table to disk", 317}, - {"yes", 318}, - {"Please enter `yes' or `no'", 319}, - {"Writing partition table to disk...", 320}, - {"Wrote partition table to disk", 321}, - {"\ -Wrote partition table, but re-read table failed. Reboot to update table.", 322}, - {"\ -Not precisely one primary partition is bootable. DOS MBR cannot boot this.", 323}, - {"Enter filename or press RETURN to display on screen: ", 324}, - {"Cannot open file '%s'", 325}, - {"Disk Drive: %s\n", 326}, - {"Sector 0:\n", 327}, - {"Sector %d:\n", 328}, - {" None ", 329}, - {" Pri/Log", 330}, - {" Primary", 331}, - {" Logical", 332}, - {"Unknown", 333}, - {"Boot (%02X)", 334}, - {"Unknown (%02X)", 335}, - {"None (%02X)", 336}, - {"Partition Table for %s\n", 337}, - {" First Last\n", 338}, - {"\ - # Type Sector Sector Offset Length Filesystem Type (ID) Flags\n", 339}, +page for additional information.\n", 276}, + {"FATAL ERROR", 277}, + {"Press any key to exit cfdisk", 278}, + {"Cannot seek on disk drive", 279}, + {"Cannot read disk drive", 280}, + {"Cannot write disk drive", 281}, + {"Too many partitions", 282}, + {"Partition begins before sector 0", 283}, + {"Partition ends before sector 0", 284}, + {"Partition begins after end-of-disk", 285}, + {"Partition ends after end-of-disk", 286}, + {"logical partitions not in disk order", 287}, + {"logical partitions overlap", 288}, + {"enlarged logical partitions overlap", 289}, + {"\ +!!!! Internal error creating logical drive with no extended partition !!!!", 290}, + {"\ +Cannot create logical drive here -- would create two extended partitions", 291}, + {"Menu item too long. Menu may look odd.", 292}, + {"Menu without direction. Defaulting horizontal.", 293}, + {"Illegal key", 294}, + {"Press a key to continue", 295}, + {"Primary", 296}, + {"Create a new primary partition", 297}, + {"Logical", 298}, + {"Create a new logical partition", 299}, + {"Cancel", 300}, + {"Don't create a partition", 301}, + {"!!! Internal error !!!", 302}, + {"Size (in MB): ", 303}, + {"Beginning", 304}, + {"Add partition at beginning of free space", 305}, + {"End", 306}, + {"Add partition at end of free space", 307}, + {"No room to create the extended partition", 308}, + {"Bad signature on partition table", 309}, + {"You specified more cylinders than fit on disk", 310}, + {"Cannot open disk drive", 311}, + {"Opened disk read-only - you have no permission to write", 312}, + {"Cannot get disk size", 313}, + {"Bad primary partition", 314}, + {"Bad logical partition", 315}, + {"Warning!! This may destroy data on your disk!", 316}, + {"Are you sure you want write the partition table to disk? (yes or no): ", 317}, + {"no", 318}, + {"Did not write partition table to disk", 319}, + {"yes", 320}, + {"Please enter `yes' or `no'", 321}, + {"Writing partition table to disk...", 322}, + {"Wrote partition table to disk", 323}, + {"\ +Wrote partition table, but re-read table failed. Reboot to update table.", 324}, + {"\ +Not precisely one primary partition is bootable. DOS MBR cannot boot this.", 325}, + {"Enter filename or press RETURN to display on screen: ", 326}, + {"Cannot open file '%s'", 327}, + {"Disk Drive: %s\n", 328}, + {"Sector 0:\n", 329}, + {"Sector %d:\n", 330}, + {" None ", 331}, + {" Pri/Log", 332}, + {" Primary", 333}, + {" Logical", 334}, + {"Unknown", 335}, + {"Boot (%02X)", 336}, + {"Unknown (%02X)", 337}, + {"None (%02X)", 338}, + {"Partition Table for %s\n", 339}, + {" First Last\n", 340}, + {"\ + # Type Sector Sector Offset Length Filesystem Type (ID) Flags\n", 341}, {"\ -- ------- -------- --------- ------ --------- ---------------------- \ ----------\n", 340}, - {" ---Starting--- ----Ending---- Start Number of\n", 341}, - {" # Flags Head Sect Cyl ID Head Sect Cyl Sector Sectors\n", 342}, - {"-- ----- ---- ---- ---- ---- ---- ---- ---- -------- ---------\n", 343}, - {"Raw", 344}, - {"Print the table using raw data format", 345}, - {"Sectors", 346}, - {"Print the table ordered by sectors", 347}, - {"Table", 348}, - {"Just print the partition table", 349}, - {"Don't print the table", 350}, - {"Help Screen for cfdisk", 351}, - {"This is cfdisk, a curses based disk partitioning program, which", 352}, - {"allows you to create, delete and modify partitions on your hard", 353}, - {"disk drive.", 354}, - {"Copyright (C) 1994-1999 Kevin E. Martin & aeb", 355}, - {"Command Meaning", 356}, - {"------- -------", 357}, - {" b Toggle bootable flag of the current partition", 358}, - {" d Delete the current partition", 359}, - {" g Change cylinders, heads, sectors-per-track parameters", 360}, - {" WARNING: This option should only be used by people who", 361}, - {" know what they are doing.", 362}, - {" h Print this screen", 363}, - {" m Maximize disk usage of the current partition", 364}, - {" Note: This may make the partition incompatible with", 365}, - {" DOS, OS/2, ...", 366}, - {" n Create new partition from free space", 367}, - {" p Print partition table to the screen or to a file", 368}, - {" There are several different formats for the partition", 369}, - {" that you can choose from:", 370}, - {" r - Raw data (exactly what would be written to disk)", 371}, - {" s - Table ordered by sectors", 372}, - {" t - Table in raw format", 373}, - {" q Quit program without writing partition table", 374}, - {" t Change the filesystem type", 375}, - {" u Change units of the partition size display", 376}, - {" Rotates through MB, sectors and cylinders", 377}, - {" W Write partition table to disk (must enter upper case W)", 378}, - {" Since this might destroy data on the disk, you must", 379}, - {" either confirm or deny the write by entering `yes' or", 380}, - {" `no'", 381}, - {"Up Arrow Move cursor to the previous partition", 382}, - {"Down Arrow Move cursor to the next partition", 383}, - {"CTRL-L Redraws the screen", 384}, - {" ? Print this screen", 385}, - {"Note: All of the commands can be entered with either upper or lower", 386}, - {"case letters (except for Writes).", 387}, - {"Cylinders", 388}, - {"Change cylinder geometry", 389}, - {"Heads", 390}, - {"Change head geometry", 391}, - {"Change sector geometry", 392}, - {"Done", 393}, - {"Done with changing geometry", 394}, - {"Enter the number of cylinders: ", 395}, - {"Illegal cylinders value", 396}, - {"Enter the number of heads: ", 397}, - {"Illegal heads value", 398}, - {"Enter the number of sectors per track: ", 399}, - {"Illegal sectors value", 400}, - {"Enter filesystem type: ", 401}, - {"Cannot change FS Type to empty", 402}, - {"Cannot change FS Type to extended", 403}, - {"Boot", 404}, - {"Unk(%02X)", 405}, - {", NC", 406}, - {"NC", 407}, - {"Pri/Log", 408}, - {"Disk Drive: %s", 409}, - {"Size: %lld bytes", 410}, - {"Heads: %d Sectors per Track: %d Cylinders: %d", 411}, - {"Name", 412}, - {"Flags", 413}, - {"Part Type", 414}, - {"FS Type", 415}, - {"[Label]", 416}, - {" Sectors", 417}, - {"Size (MB)", 418}, - {"Size (GB)", 419}, - {"Bootable", 420}, - {"Toggle bootable flag of the current partition", 421}, - {"Delete", 422}, - {"Delete the current partition", 423}, - {"Geometry", 424}, - {"Change disk geometry (experts only)", 425}, - {"Help", 426}, - {"Print help screen", 427}, - {"Maximize", 428}, - {"Maximize disk usage of the current partition (experts only)", 429}, - {"New", 430}, - {"Create new partition from free space", 431}, - {"Print", 432}, - {"Print partition table to the screen or to a file", 433}, - {"Quit", 434}, - {"Quit program without writing partition table", 435}, - {"Type", 436}, - {"Change the filesystem type (DOS, Linux, OS/2 and so on)", 437}, - {"Units", 438}, - {"Change units of the partition size display (MB, sect, cyl)", 439}, - {"Write", 440}, - {"Write partition table to disk (this might destroy data)", 441}, - {"Cannot make this partition bootable", 442}, - {"Cannot delete an empty partition", 443}, - {"Cannot maximize this partition", 444}, - {"This partition is unusable", 445}, - {"This partition is already in use", 446}, - {"Cannot change the type of an empty partition", 447}, - {"No more partitions", 448}, - {"Illegal command", 449}, - {"Copyright (C) 1994-1999 Kevin E. Martin & aeb\n", 450}, +---------\n", 342}, + {" ---Starting--- ----Ending---- Start Number of\n", 343}, + {" # Flags Head Sect Cyl ID Head Sect Cyl Sector Sectors\n", 344}, + {"-- ----- ---- ---- ---- ---- ---- ---- ---- -------- ---------\n", 345}, + {"Raw", 346}, + {"Print the table using raw data format", 347}, + {"Sectors", 348}, + {"Print the table ordered by sectors", 349}, + {"Table", 350}, + {"Just print the partition table", 351}, + {"Don't print the table", 352}, + {"Help Screen for cfdisk", 353}, + {"This is cfdisk, a curses based disk partitioning program, which", 354}, + {"allows you to create, delete and modify partitions on your hard", 355}, + {"disk drive.", 356}, + {"Copyright (C) 1994-1999 Kevin E. Martin & aeb", 357}, + {"Command Meaning", 358}, + {"------- -------", 359}, + {" b Toggle bootable flag of the current partition", 360}, + {" d Delete the current partition", 361}, + {" g Change cylinders, heads, sectors-per-track parameters", 362}, + {" WARNING: This option should only be used by people who", 363}, + {" know what they are doing.", 364}, + {" h Print this screen", 365}, + {" m Maximize disk usage of the current partition", 366}, + {" Note: This may make the partition incompatible with", 367}, + {" DOS, OS/2, ...", 368}, + {" n Create new partition from free space", 369}, + {" p Print partition table to the screen or to a file", 370}, + {" There are several different formats for the partition", 371}, + {" that you can choose from:", 372}, + {" r - Raw data (exactly what would be written to disk)", 373}, + {" s - Table ordered by sectors", 374}, + {" t - Table in raw format", 375}, + {" q Quit program without writing partition table", 376}, + {" t Change the filesystem type", 377}, + {" u Change units of the partition size display", 378}, + {" Rotates through MB, sectors and cylinders", 379}, + {" W Write partition table to disk (must enter upper case W)", 380}, + {" Since this might destroy data on the disk, you must", 381}, + {" either confirm or deny the write by entering `yes' or", 382}, + {" `no'", 383}, + {"Up Arrow Move cursor to the previous partition", 384}, + {"Down Arrow Move cursor to the next partition", 385}, + {"CTRL-L Redraws the screen", 386}, + {" ? Print this screen", 387}, + {"Note: All of the commands can be entered with either upper or lower", 388}, + {"case letters (except for Writes).", 389}, + {"Cylinders", 390}, + {"Change cylinder geometry", 391}, + {"Heads", 392}, + {"Change head geometry", 393}, + {"Change sector geometry", 394}, + {"Done", 395}, + {"Done with changing geometry", 396}, + {"Enter the number of cylinders: ", 397}, + {"Illegal cylinders value", 398}, + {"Enter the number of heads: ", 399}, + {"Illegal heads value", 400}, + {"Enter the number of sectors per track: ", 401}, + {"Illegal sectors value", 402}, + {"Enter filesystem type: ", 403}, + {"Cannot change FS Type to empty", 404}, + {"Cannot change FS Type to extended", 405}, + {"Boot", 406}, + {"Unk(%02X)", 407}, + {", NC", 408}, + {"NC", 409}, + {"Pri/Log", 410}, + {"Disk Drive: %s", 411}, + {"Size: %lld bytes", 412}, + {"Heads: %d Sectors per Track: %d Cylinders: %d", 413}, + {"Name", 414}, + {"Flags", 415}, + {"Part Type", 416}, + {"FS Type", 417}, + {"[Label]", 418}, + {" Sectors", 419}, + {"Size (MB)", 420}, + {"Size (GB)", 421}, + {"Bootable", 422}, + {"Toggle bootable flag of the current partition", 423}, + {"Delete", 424}, + {"Delete the current partition", 425}, + {"Geometry", 426}, + {"Change disk geometry (experts only)", 427}, + {"Help", 428}, + {"Print help screen", 429}, + {"Maximize", 430}, + {"Maximize disk usage of the current partition (experts only)", 431}, + {"New", 432}, + {"Create new partition from free space", 433}, + {"Print", 434}, + {"Print partition table to the screen or to a file", 435}, + {"Quit", 436}, + {"Quit program without writing partition table", 437}, + {"Type", 438}, + {"Change the filesystem type (DOS, Linux, OS/2 and so on)", 439}, + {"Units", 440}, + {"Change units of the partition size display (MB, sect, cyl)", 441}, + {"Write", 442}, + {"Write partition table to disk (this might destroy data)", 443}, + {"Cannot make this partition bootable", 444}, + {"Cannot delete an empty partition", 445}, + {"Cannot maximize this partition", 446}, + {"This partition is unusable", 447}, + {"This partition is already in use", 448}, + {"Cannot change the type of an empty partition", 449}, + {"No more partitions", 450}, + {"Illegal command", 451}, + {"Copyright (C) 1994-2000 Kevin E. Martin & aeb\n", 452}, {"\ \n\ Usage:\n\ @@ -585,7 +587,7 @@ Options:\n\ -z: Start with a zero partition table, instead of reading the pt from disk;\n\ -c C -h H -s S: Override the kernel's idea of the number of cylinders,\n\ the number of heads and the number of sectors/track.\n\ -\n", 451}, +\n", 453}, {"\ Usage: fdisk [-b SSZ] [-u] DISK Change partition table\n\ fdisk -l [-b SSZ] [-u] DISK List partition table(s)\n\ @@ -594,200 +596,211 @@ Usage: fdisk [-b SSZ] [-u] DISK Change partition table\n\ Here DISK is something like /dev/hdb or /dev/sda\n\ and PARTITION is something like /dev/hda7\n\ -u: give Start and End in sector (instead of cylinder) units\n\ --b 2048: (for certain MO drives) use 2048-byte sectors\n", 452}, +-b 2048: (for certain MO drives) use 2048-byte sectors\n", 454}, {"\ Usage: fdisk [-l] [-b SSZ] [-u] device\n\ E.g.: fdisk /dev/hda (for the first IDE disk)\n\ or: fdisk /dev/sdc (for the third SCSI disk)\n\ or: fdisk /dev/eda (for the first PS/2 ESDI drive)\n\ or: fdisk /dev/rd/c0d0 or: fdisk /dev/ida/c0d0 (for RAID devices)\n\ - ...\n", 453}, - {"Unable to open %s\n", 454}, - {"Unable to read %s\n", 455}, - {"Unable to seek on %s\n", 456}, - {"Unable to write %s\n", 457}, - {"BLKGETSIZE ioctl failed on %s\n", 458}, - {"Unable to allocate any more memory\n", 459}, - {"Fatal error\n", 460}, - {"Command action", 461}, - {" a toggle a read only flag", 462}, - {" b edit bsd disklabel", 463}, - {" c toggle the mountable flag", 464}, - {" d delete a partition", 465}, - {" l list known partition types", 466}, - {" m print this menu", 467}, - {" n add a new partition", 468}, - {" o create a new empty DOS partition table", 469}, - {" p print the partition table", 470}, - {" q quit without saving changes", 471}, - {" s create a new empty Sun disklabel", 472}, - {" t change a partition's system id", 473}, - {" u change display/entry units", 474}, - {" v verify the partition table", 475}, - {" w write table to disk and exit", 476}, - {" x extra functionality (experts only)", 477}, - {" a select bootable partition", 478}, - {" b edit bootfile entry", 479}, - {" c select sgi swap partition", 480}, - {" a toggle a bootable flag", 481}, - {" c toggle the dos compatibility flag", 482}, - {" a change number of alternate cylinders", 483}, - {" c change number of cylinders", 484}, - {" d print the raw data in the partition table", 485}, - {" e change number of extra sectors per cylinder", 486}, - {" h change number of heads", 487}, - {" i change interleave factor", 488}, - {" o change rotation speed (rpm)", 489}, - {" r return to main menu", 490}, - {" s change number of sectors/track", 491}, - {" y change number of physical cylinders", 492}, - {" b move beginning of data in a partition", 493}, - {" e list extended partitions", 494}, - {" g create an IRIX partition table", 495}, - {"You must set", 496}, - {"heads", 497}, - {"sectors", 498}, - {"cylinders", 499}, + ...\n", 455}, + {"Unable to open %s\n", 456}, + {"Unable to read %s\n", 457}, + {"Unable to seek on %s\n", 458}, + {"Unable to write %s\n", 459}, + {"BLKGETSIZE ioctl failed on %s\n", 460}, + {"Unable to allocate any more memory\n", 461}, + {"Fatal error\n", 462}, + {"Command action", 463}, + {" a toggle a read only flag", 464}, + {" b edit bsd disklabel", 465}, + {" c toggle the mountable flag", 466}, + {" d delete a partition", 467}, + {" l list known partition types", 468}, + {" m print this menu", 469}, + {" n add a new partition", 470}, + {" o create a new empty DOS partition table", 471}, + {" p print the partition table", 472}, + {" q quit without saving changes", 473}, + {" s create a new empty Sun disklabel", 474}, + {" t change a partition's system id", 475}, + {" u change display/entry units", 476}, + {" v verify the partition table", 477}, + {" w write table to disk and exit", 478}, + {" x extra functionality (experts only)", 479}, + {" a select bootable partition", 480}, + {" b edit bootfile entry", 481}, + {" c select sgi swap partition", 482}, + {" a toggle a bootable flag", 483}, + {" c toggle the dos compatibility flag", 484}, + {" a change number of alternate cylinders", 485}, + {" c change number of cylinders", 486}, + {" d print the raw data in the partition table", 487}, + {" e change number of extra sectors per cylinder", 488}, + {" h change number of heads", 489}, + {" i change interleave factor", 490}, + {" o change rotation speed (rpm)", 491}, + {" r return to main menu", 492}, + {" s change number of sectors/track", 493}, + {" y change number of physical cylinders", 494}, + {" b move beginning of data in a partition", 495}, + {" e list extended partitions", 496}, + {" g create an IRIX partition table", 497}, + {" f fix partition order", 498}, + {"You must set", 499}, + {"heads", 500}, + {"sectors", 501}, + {"cylinders", 502}, {"\ %s%s.\n\ -You can do this from the extra functions menu.\n", 500}, - {" and ", 501}, - {"Bad offset in primary extended partition\n", 502}, - {"Warning: deleting partitions after %d\n", 503}, - {"Warning: extra link pointer in partition table %d\n", 504}, - {"Warning: ignoring extra data in partition table %d\n", 505}, +You can do this from the extra functions menu.\n", 503}, + {" and ", 504}, + {"Bad offset in primary extended partition\n", 505}, + {"Warning: deleting partitions after %d\n", 506}, + {"Warning: extra link pointer in partition table %d\n", 507}, + {"Warning: ignoring extra data in partition table %d\n", 508}, {"\ Building a new DOS disklabel. Changes will remain in memory only,\n\ until you decide to write them. After that, of course, the previous\n\ content won't be recoverable.\n\ -\n", 506}, - {"You will not be able to write the partition table.\n", 507}, - {"Note: sector size is %d (not %d)\n", 508}, +\n", 509}, + {"Note: sector size is %d (not %d)\n", 510}, + {"You will not be able to write the partition table.\n", 511}, {"\ -Device contains neither a valid DOS partition table, nor Sun or SGI \ -disklabel\n", 509}, - {"Internal error\n", 510}, - {"Ignoring extra extended partition %d\n", 511}, +Device contains neither a valid DOS partition table, nor Sun, SGI or OSF \ +disklabel\n", 512}, + {"Internal error\n", 513}, + {"Ignoring extra extended partition %d\n", 514}, {"\ Warning: invalid flag 0x%04x of partition table %d will be corrected by \ -w(rite)\n", 512}, +w(rite)\n", 515}, {"\ \n\ -got EOF thrice - exiting..\n", 513}, - {"Hex code (type L to list codes): ", 514}, - {"%s (%d-%d, default %d): ", 515}, - {"Using default value %d\n", 516}, - {"Value out of range.\n", 517}, - {"Partition number", 518}, - {"Warning: partition %d has empty type\n", 519}, - {"cylinder", 520}, - {"sector", 521}, - {"Changing display/entry units to %s\n", 522}, - {"WARNING: Partition %d is an extended partition\n", 523}, - {"DOS Compatibility flag is set\n", 524}, - {"DOS Compatibility flag is not set\n", 525}, - {"Partition %d does not exist yet!\n", 526}, +got EOF thrice - exiting..\n", 516}, + {"Hex code (type L to list codes): ", 517}, + {"%s (%d-%d, default %d): ", 518}, + {"Using default value %d\n", 519}, + {"Value out of range.\n", 520}, + {"Partition number", 521}, + {"Warning: partition %d has empty type\n", 522}, + {"cylinder", 523}, + {"sector", 524}, + {"Changing display/entry units to %s\n", 525}, + {"WARNING: Partition %d is an extended partition\n", 526}, + {"DOS Compatibility flag is set\n", 527}, + {"DOS Compatibility flag is not set\n", 528}, + {"Partition %d does not exist yet!\n", 529}, {"\ Type 0 means free space to many systems\n\ (but not to Linux). Having partitions of\n\ type 0 is probably unwise. You can delete\n\ -a partition using the `d' command.\n", 527}, +a partition using the `d' command.\n", 530}, {"\ You cannot change a partition into an extended one or vice versa\n\ -Delete it first.\n", 528}, +Delete it first.\n", 531}, {"\ Consider leaving partition 3 as Whole disk (5),\n\ as SunOS/Solaris expects it and even Linux likes it.\n\ -\n", 529}, +\n", 532}, {"\ Consider leaving partition 9 as volume header (0),\n\ and partition 11 as entire volume (6)as IRIX expects it.\n\ -\n", 530}, - {"Changed system type of partition %d to %x (%s)\n", 531}, - {"Partition %d has different physical/logical beginnings (non-Linux?):\n", 532}, - {" phys=(%d, %d, %d) ", 533}, - {"logical=(%d, %d, %d)\n", 534}, - {"Partition %d has different physical/logical endings:\n", 535}, - {"Partition %i does not start on cylinder boundary:\n", 536}, - {"should be (%d, %d, 1)\n", 537}, - {"Partition %i does not end on cylinder boundary:\n", 538}, - {"should be (%d, %d, %d)\n", 539}, +\n", 533}, + {"Changed system type of partition %d to %x (%s)\n", 534}, + {"Partition %d has different physical/logical beginnings (non-Linux?):\n", 535}, + {" phys=(%d, %d, %d) ", 536}, + {"logical=(%d, %d, %d)\n", 537}, + {"Partition %d has different physical/logical endings:\n", 538}, + {"Partition %i does not start on cylinder boundary:\n", 539}, + {"should be (%d, %d, 1)\n", 540}, + {"Partition %i does not end on cylinder boundary:\n", 541}, + {"should be (%d, %d, %d)\n", 542}, {"\ \n\ Disk %s: %d heads, %d sectors, %d cylinders\n\ Units = %s of %d * %d bytes\n\ -\n", 540}, - {"%*s Boot Start End Blocks Id System\n", 541}, - {"Device", 542}, +\n", 543}, + {"\ +Nothing to do. Ordering is correct already.\n\ +\n", 544}, + {"%*s Boot Start End Blocks Id System\n", 545}, + {"Device", 546}, + {"\ +\n\ +Partition table entries are not in disk order\n", 547}, {"\ \n\ Disk %s: %d heads, %d sectors, %d cylinders\n\ -\n", 543}, - {"Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n", 544}, - {"Warning: partition %d contains sector 0\n", 545}, - {"Partition %d: head %d greater than maximum %d\n", 546}, - {"Partition %d: sector %d greater than maximum %d\n", 547}, - {"Partitions %d: cylinder %d greater than maximum %d\n", 548}, - {"Partition %d: previous sectors %d disagrees with total %d\n", 549}, - {"Warning: bad start-of-data in partition %d\n", 550}, - {"Warning: partition %d overlaps partition %d.\n", 551}, - {"Warning: partition %d is empty\n", 552}, - {"Logical partition %d not entirely in partition %d\n", 553}, - {"Total allocated sectors %d greater than the maximum %d\n", 554}, - {"%d unallocated sectors\n", 555}, - {"Partition %d is already defined. Delete it before re-adding it.\n", 556}, - {"First %s", 557}, - {"Sector %d is already allocated\n", 558}, - {"No free sectors available\n", 559}, - {"Last %s or +size or +sizeM or +sizeK", 560}, - {"Warning: partition %d has an odd number of sectors.\n", 561}, - {"The maximum number of partitions has been created\n", 562}, - {"You must delete some partition and add an extended partition first\n", 563}, +\n", 548}, + {"Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n", 549}, + {"Warning: partition %d contains sector 0\n", 550}, + {"Partition %d: head %d greater than maximum %d\n", 551}, + {"Partition %d: sector %d greater than maximum %d\n", 552}, + {"Partitions %d: cylinder %d greater than maximum %d\n", 553}, + {"Partition %d: previous sectors %d disagrees with total %d\n", 554}, + {"Warning: bad start-of-data in partition %d\n", 555}, + {"Warning: partition %d overlaps partition %d.\n", 556}, + {"Warning: partition %d is empty\n", 557}, + {"Logical partition %d not entirely in partition %d\n", 558}, + {"Total allocated sectors %d greater than the maximum %d\n", 559}, + {"%d unallocated sectors\n", 560}, + {"Partition %d is already defined. Delete it before re-adding it.\n", 561}, + {"First %s", 562}, + {"Sector %d is already allocated\n", 563}, + {"No free sectors available\n", 564}, + {"Last %s or +size or +sizeM or +sizeK", 565}, + {"Warning: partition %d has an odd number of sectors.\n", 566}, + {"The maximum number of partitions has been created\n", 567}, + {"You must delete some partition and add an extended partition first\n", 568}, {"\ Command action\n\ %s\n\ - p primary partition (1-4)\n", 564}, - {"l logical (5 or over)", 565}, - {"e extended", 566}, - {"Invalid partition number for type `%c'\n", 567}, + p primary partition (1-4)\n", 569}, + {"l logical (5 or over)", 570}, + {"e extended", 571}, + {"Invalid partition number for type `%c'\n", 572}, {"\ The partition table has been altered!\n\ -\n", 568}, - {"Calling ioctl() to re-read partition table.\n", 569}, +\n", 573}, + {"Calling ioctl() to re-read partition table.\n", 574}, {"\ Re-read table failed with error %d: %s.\n\ -Reboot your system to ensure the partition table is updated.\n", 570}, +Reboot your system to ensure the partition table is updated.\n", 575}, {"\ \n\ WARNING: If you have created or modified any DOS 6.x\n\ partitions, please see the fdisk manual page for additional\n\ -information.\n", 571}, - {"Syncing disks.\n", 572}, - {"Device: %s\n", 573}, - {"Partition %d has no data area\n", 574}, - {"New beginning of data", 575}, - {"Expert command (m for help): ", 576}, - {"Number of cylinders", 577}, - {"Number of heads", 578}, - {"Number of sectors", 579}, - {"Warning: setting sector offset for DOS compatiblity\n", 580}, - {"Disk %s doesn't contain a valid partition table\n", 581}, - {"Cannot open %s\n", 582}, - {"cannot open %s\n", 583}, - {"This kernel finds the sector size itself - -b option ignored\n", 584}, +information.\n", 576}, + {"Syncing disks.\n", 577}, + {"Device: %s\n", 578}, + {"Partition %d has no data area\n", 579}, + {"New beginning of data", 580}, + {"Expert command (m for help): ", 581}, + {"Number of cylinders", 582}, + {"Number of heads", 583}, + {"Number of sectors", 584}, + {"Warning: setting sector offset for DOS compatiblity\n", 585}, + {"Disk %s doesn't contain a valid partition table\n", 586}, + {"Cannot open %s\n", 587}, + {"cannot open %s\n", 588}, + {"%c: unknown command\n", 589}, + {"This kernel finds the sector size itself - -b option ignored\n", 590}, {"\ Warning: the -b (set sector size) option should be used with one specified \ -device\n", 585}, - {"Command (m for help): ", 586}, +device\n", 591}, + {"\ +Detected an OSF/1 disklabel on %s, entering disklabel mode.\n\ +To return to DOS partition table mode, use the 'r' command.\n", 592}, + {"Command (m for help): ", 593}, {"\ \n\ -The current boot file is: %s\n", 587}, - {"Please enter the name of the new boot file: ", 588}, - {"Boot file unchanged\n", 589}, +The current boot file is: %s\n", 594}, + {"Please enter the name of the new boot file: ", 595}, + {"Boot file unchanged\n", 596}, {"\ \n\ \tSorry, no experts menu for SGI partition tables available.\n\ -\n", 590}, +\n", 597}, {"\ \n\ \tThere is a valid AIX label on this disk.\n\ @@ -800,93 +813,92 @@ The current boot file is: %s\n", 587}, \t erase the other disks as well, if unmirrored.)\n\ \t3. Before deleting this physical volume be sure\n\ \t to remove the disk logically from your AIX\n\ -\t machine. (Otherwise you become an AIXpert).", 591}, +\t machine. (Otherwise you become an AIXpert).", 598}, {"\ \n\ -BSD label for device: %s\n", 592}, - {" d delete a BSD partition", 593}, - {" e edit drive data", 594}, - {" i install bootstrap", 595}, - {" l list known filesystem types", 596}, - {" n add a new BSD partition", 597}, - {" p print BSD partition table", 598}, - {" s show complete disklabel", 599}, - {" t change a partition's filesystem id", 600}, - {" w write disklabel to disk", 601}, - {" x link BSD partition to non-BSD partition", 602}, - {"Partition %s%d has invalid starting sector 0.\n", 603}, - {"Reading disklabel of %s%d at sector %d.\n", 604}, - {"There is no *BSD partition on %s.\n", 605}, - {"BSD disklabel command (m for help): ", 606}, - {"type: %s\n", 607}, - {"type: %d\n", 608}, - {"disk: %.*s\n", 609}, - {"label: %.*s\n", 610}, - {"flags:", 611}, - {" removable", 612}, - {" ecc", 613}, - {" badsect", 614}, - {"bytes/sector: %ld\n", 615}, - {"sectors/track: %ld\n", 616}, - {"tracks/cylinder: %ld\n", 617}, - {"sectors/cylinder: %ld\n", 618}, - {"cylinders: %ld\n", 619}, - {"rpm: %d\n", 620}, - {"interleave: %d\n", 621}, - {"trackskew: %d\n", 622}, - {"cylinderskew: %d\n", 623}, - {"headswitch: %ld\t\t# milliseconds\n", 624}, - {"track-to-track seek: %ld\t# milliseconds\n", 625}, - {"drivedata: ", 626}, +BSD label for device: %s\n", 599}, + {" d delete a BSD partition", 600}, + {" e edit drive data", 601}, + {" i install bootstrap", 602}, + {" l list known filesystem types", 603}, + {" n add a new BSD partition", 604}, + {" p print BSD partition table", 605}, + {" s show complete disklabel", 606}, + {" t change a partition's filesystem id", 607}, + {" u change units (cylinders/sectors)", 608}, + {" w write disklabel to disk", 609}, + {" x link BSD partition to non-BSD partition", 610}, + {"Partition %s has invalid starting sector 0.\n", 611}, + {"Reading disklabel of %s at sector %d.\n", 612}, + {"There is no *BSD partition on %s.\n", 613}, + {"BSD disklabel command (m for help): ", 614}, + {"type: %s\n", 615}, + {"type: %d\n", 616}, + {"disk: %.*s\n", 617}, + {"label: %.*s\n", 618}, + {"flags:", 619}, + {" removable", 620}, + {" ecc", 621}, + {" badsect", 622}, + {"bytes/sector: %ld\n", 623}, + {"sectors/track: %ld\n", 624}, + {"tracks/cylinder: %ld\n", 625}, + {"sectors/cylinder: %ld\n", 626}, + {"cylinders: %ld\n", 627}, + {"rpm: %d\n", 628}, + {"interleave: %d\n", 629}, + {"trackskew: %d\n", 630}, + {"cylinderskew: %d\n", 631}, + {"headswitch: %ld\t\t# milliseconds\n", 632}, + {"track-to-track seek: %ld\t# milliseconds\n", 633}, + {"drivedata: ", 634}, {"\ \n\ -%d partitions:\n", 627}, - {"# size offset fstype [fsize bsize cpg]\n", 628}, - {"Writing disklabel to %s%d.\n", 629}, - {"Writing disklabel to %s.\n", 630}, - {"%s%d contains no disklabel.\n", 631}, - {"%s contains no disklabel.\n", 632}, - {"Do you want to create a disklabel? (y/n) ", 633}, - {"bytes/sector", 634}, - {"sectors/track", 635}, - {"tracks/cylinder", 636}, - {"sectors/cylinder", 637}, - {"Must be <= sectors/track * tracks/cylinder (default).\n", 638}, - {"rpm", 639}, - {"interleave", 640}, - {"trackskew", 641}, - {"cylinderskew", 642}, - {"headswitch", 643}, - {"track-to-track seek", 644}, - {"Bootstrap: %sboot -> boot%s (%s): ", 645}, - {"Bootstrap overlaps with disk label!\n", 646}, - {"Bootstrap installed on %s%d.\n", 647}, - {"Bootstrap installed on %s.\n", 648}, - {"Partition (a-%c): ", 649}, - {"This partition already exists.\n", 650}, - {"Warning: too many partitions (%d, maximum is %d).\n", 651}, +%d partitions:\n", 635}, + {"# start end size fstype [fsize bsize cpg]\n", 636}, + {"Writing disklabel to %s.\n", 637}, + {"%s contains no disklabel.\n", 638}, + {"Do you want to create a disklabel? (y/n) ", 639}, + {"bytes/sector", 640}, + {"sectors/track", 641}, + {"tracks/cylinder", 642}, + {"sectors/cylinder", 643}, + {"Must be <= sectors/track * tracks/cylinder (default).\n", 644}, + {"rpm", 645}, + {"interleave", 646}, + {"trackskew", 647}, + {"cylinderskew", 648}, + {"headswitch", 649}, + {"track-to-track seek", 650}, + {"Bootstrap: %sboot -> boot%s (%s): ", 651}, + {"Bootstrap overlaps with disk label!\n", 652}, + {"Bootstrap installed on %s.\n", 653}, + {"Partition (a-%c): ", 654}, + {"This partition already exists.\n", 655}, + {"Warning: too many partitions (%d, maximum is %d).\n", 656}, {"\ \n\ -Syncing disks.\n", 652}, - {"SGI volhdr", 653}, - {"SGI trkrepl", 654}, - {"SGI secrepl", 655}, - {"SGI raw", 656}, - {"SGI bsd", 657}, - {"SGI sysv", 658}, - {"SGI volume", 659}, - {"SGI efs", 660}, - {"SGI lvol", 661}, - {"SGI rlvol", 662}, - {"SGI xfs", 663}, - {"SGI xlvol", 664}, - {"SGI rxlvol", 665}, - {"Linux swap", 666}, - {"Linux native", 667}, +Syncing disks.\n", 657}, + {"SGI volhdr", 658}, + {"SGI trkrepl", 659}, + {"SGI secrepl", 660}, + {"SGI raw", 661}, + {"SGI bsd", 662}, + {"SGI sysv", 663}, + {"SGI volume", 664}, + {"SGI efs", 665}, + {"SGI lvol", 666}, + {"SGI rlvol", 667}, + {"SGI xfs", 668}, + {"SGI xlvol", 669}, + {"SGI rxlvol", 670}, + {"Linux swap", 671}, + {"Linux native", 672}, + {"Linux LVM", 673}, {"\ According to MIPS Computer Systems, Inc the Label must not contain more than \ -512 bytes\n", 668}, - {"Detected sgi disklabel with wrong checksum.\n", 669}, +512 bytes\n", 674}, + {"Detected sgi disklabel with wrong checksum.\n", 675}, {"\ \n\ Disk %s (SGI disk label): %d heads, %d sectors\n\ @@ -894,139 +906,139 @@ Disk %s (SGI disk label): %d heads, %d sectors\n\ %d extra sects/cyl, interleave %d:1\n\ %s\n\ Units = %s of %d * 512 bytes\n\ -\n", 670}, +\n", 676}, {"\ \n\ Disk %s (SGI disk label): %d heads, %d sectors, %d cylinders\n\ Units = %s of %d * 512 bytes\n\ -\n", 671}, +\n", 677}, {"\ ----- partitions -----\n\ -%*s Info Start End Sectors Id System\n", 672}, +%*s Info Start End Sectors Id System\n", 678}, {"\ ----- bootinfo -----\n\ Bootfile: %s\n\ ------ directory entries -----\n", 673}, - {"%2d: %-10s sector%5u size%8u\n", 674}, +----- directory entries -----\n", 679}, + {"%2d: %-10s sector%5u size%8u\n", 680}, {"\ \n\ Invalid Bootfile!\n\ \tThe bootfile must be an absolute non-zero pathname,\n\ -\te.g. \"/unix\" or \"/unix.save\".\n", 675}, +\te.g. \"/unix\" or \"/unix.save\".\n", 681}, {"\ \n\ -\tName of Bootfile too long: 16 bytes maximum.\n", 676}, +\tName of Bootfile too long: 16 bytes maximum.\n", 682}, {"\ \n\ -\tBootfile must have a fully qualified pathname.\n", 677}, +\tBootfile must have a fully qualified pathname.\n", 683}, {"\ \n\ \tBe aware, that the bootfile is not checked for existence.\n\ -\tSGI's default is \"/unix\" and for backup \"/unix.save\".\n", 678}, +\tSGI's default is \"/unix\" and for backup \"/unix.save\".\n", 684}, {"\ \n\ -\tBootfile is changed to \"%s\".\n", 679}, - {"More than one entire disk entry present.\n", 680}, - {"No partitions defined\n", 681}, - {"IRIX likes when Partition 11 covers the entire disk.\n", 682}, +\tBootfile is changed to \"%s\".\n", 685}, + {"More than one entire disk entry present.\n", 686}, + {"No partitions defined\n", 687}, + {"IRIX likes when Partition 11 covers the entire disk.\n", 688}, {"\ The entire disk partition should start at block 0,\n\ -not at diskblock %d.\n", 683}, +not at diskblock %d.\n", 689}, {"\ The entire disk partition is only %d diskblock large,\n\ -but the disk is %d diskblocks long.\n", 684}, - {"One Partition (#11) should cover the entire disk.\n", 685}, - {"Partition %d does not start on cylinder boundary.\n", 686}, - {"Partition %d does not end on cylinder boundary.\n", 687}, - {"The Partition %d and %d overlap by %d sectors.\n", 688}, - {"Unused gap of %8d sectors - sectors %8d-%d\n", 689}, +but the disk is %d diskblocks long.\n", 690}, + {"One Partition (#11) should cover the entire disk.\n", 691}, + {"Partition %d does not start on cylinder boundary.\n", 692}, + {"Partition %d does not end on cylinder boundary.\n", 693}, + {"The Partition %d and %d overlap by %d sectors.\n", 694}, + {"Unused gap of %8d sectors - sectors %8d-%d\n", 695}, {"\ \n\ -The boot partition does not exist.\n", 690}, +The boot partition does not exist.\n", 696}, {"\ \n\ -The swap partition does not exist.\n", 691}, +The swap partition does not exist.\n", 697}, {"\ \n\ -The swap partition has no swap type.\n", 692}, - {"\tYou have chosen an unusual boot file name.\n", 693}, - {"Sorry You may change the Tag of non-empty partitions.\n", 694}, +The swap partition has no swap type.\n", 698}, + {"\tYou have chosen an unusual boot file name.\n", 699}, + {"Sorry You may change the Tag of non-empty partitions.\n", 700}, {"\ It is highly recommended that the partition at offset 0\n\ is of type \"SGI volhdr\", the IRIX system will rely on it to\n\ retrieve from its directory standalone tools like sash and fx.\n\ Only the \"SGI volume\" entire disk section may violate this.\n\ -Type YES if you are sure about tagging this partition differently.\n", 695}, - {"Do You know, You got a partition overlap on the disk?\n", 696}, - {"Attempting to generate entire disk entry automatically.\n", 697}, - {"The entire disk is already covered with partitions.\n", 698}, - {"You got a partition overlap on the disk. Fix it first!\n", 699}, +Type YES if you are sure about tagging this partition differently.\n", 701}, + {"Do You know, You got a partition overlap on the disk?\n", 702}, + {"Attempting to generate entire disk entry automatically.\n", 703}, + {"The entire disk is already covered with partitions.\n", 704}, + {"You got a partition overlap on the disk. Fix it first!\n", 705}, {"\ It is highly recommended that eleventh partition\n\ -covers the entire disk and is of type `SGI volume'\n", 700}, - {"You will get a partition overlap on the disk. Fix it first!\n", 701}, - {" Last %s", 702}, +covers the entire disk and is of type `SGI volume'\n", 706}, + {"You will get a partition overlap on the disk. Fix it first!\n", 707}, + {" Last %s", 708}, {"\ Building a new SGI disklabel. Changes will remain in memory only,\n\ until you decide to write them. After that, of course, the previous\n\ -content will be unrecoverable lost.\n\ -\n", 703}, - {"Trying to keep parameters of partition %d.\n", 704}, - {"ID=%02x\tSTART=%d\tLENGTH=%d\n", 705}, - {"Empty", 706}, - {"SunOS root", 707}, - {"SunOS swap", 708}, - {"SunOS usr", 709}, - {"Whole disk", 710}, - {"SunOS stand", 711}, - {"SunOS var", 712}, - {"SunOS home", 713}, +content will be unrecoverably lost.\n\ +\n", 709}, + {"Trying to keep parameters of partition %d.\n", 710}, + {"ID=%02x\tSTART=%d\tLENGTH=%d\n", 711}, + {"Empty", 712}, + {"SunOS root", 713}, + {"SunOS swap", 714}, + {"SunOS usr", 715}, + {"Whole disk", 716}, + {"SunOS stand", 717}, + {"SunOS var", 718}, + {"SunOS home", 719}, {"\ Detected sun disklabel with wrong checksum.\n\ Probably you'll have to set all the values,\n\ e.g. heads, sectors, cylinders and partitions\n\ -or force a fresh label (s command in main menu)\n", 714}, - {"Autoconfigure found a %s%s%s\n", 715}, +or force a fresh label (s command in main menu)\n", 720}, + {"Autoconfigure found a %s%s%s\n", 721}, {"\ Building a new sun disklabel. Changes will remain in memory only,\n\ until you decide to write them. After that, of course, the previous\n\ content won't be recoverable.\n\ -\n", 716}, +\n", 722}, {"\ Drive type\n\ ? auto configure\n\ - 0 custom (with hardware detected defaults)", 717}, - {"Select type (? for auto, 0 for custom): ", 718}, - {"Autoconfigure failed.\n", 719}, - {"Sectors/track", 720}, - {"Alternate cylinders", 721}, - {"Physical cylinders", 722}, - {"Rotation speed (rpm)", 723}, - {"Interleave factor", 724}, - {"Extra sectors per cylinder", 725}, - {"You may change all the disk params from the x menu", 726}, - {"3,5\" floppy", 727}, - {"Linux custom", 728}, - {"Partition %d doesn't end on cylinder boundary\n", 729}, - {"Partition %d overlaps with others in sectors %d-%d\n", 730}, - {"Unused gap - sectors 0-%d\n", 731}, - {"Unused gap - sectors %d-%d\n", 732}, + 0 custom (with hardware detected defaults)", 723}, + {"Select type (? for auto, 0 for custom): ", 724}, + {"Autoconfigure failed.\n", 725}, + {"Sectors/track", 726}, + {"Alternate cylinders", 727}, + {"Physical cylinders", 728}, + {"Rotation speed (rpm)", 729}, + {"Interleave factor", 730}, + {"Extra sectors per cylinder", 731}, + {"You may change all the disk params from the x menu", 732}, + {"3,5\" floppy", 733}, + {"Linux custom", 734}, + {"Partition %d doesn't end on cylinder boundary\n", 735}, + {"Partition %d overlaps with others in sectors %d-%d\n", 736}, + {"Unused gap - sectors 0-%d\n", 737}, + {"Unused gap - sectors %d-%d\n", 738}, {"\ Other partitions already cover the whole disk.\n\ -Delete some/shrink them before retry.\n", 733}, +Delete some/shrink them before retry.\n", 739}, {"\ You haven't covered the whole disk with the 3rd partition, but your value\n\ %d %s covers some other partition. Your entry has been changed\n\ -to %d %s\n", 734}, +to %d %s\n", 740}, {"\ If you want to maintain SunOS/Solaris compatibility, consider leaving this\n\ -partition as Whole disk (5), starting at 0, with %u sectors\n", 735}, +partition as Whole disk (5), starting at 0, with %u sectors\n", 741}, {"\ It is highly recommended that the partition at offset 0\n\ is UFS, EXT2FS filesystem or SunOS swap. Putting Linux swap\n\ there may destroy your partition table and bootblock.\n\ Type YES if you're very sure you would like that partition\n\ -tagged with 82 (Linux swap): ", 736}, +tagged with 82 (Linux swap): ", 742}, {"\ \n\ Disk %s (Sun disk label): %d heads, %d sectors, %d rpm\n\ @@ -1034,1088 +1046,1099 @@ Disk %s (Sun disk label): %d heads, %d sectors, %d rpm\n\ %d extra sects/cyl, interleave %d:1\n\ %s\n\ Units = %s of %d * 512 bytes\n\ -\n", 737}, +\n", 743}, {"\ \n\ Disk %s (Sun disk label): %d heads, %d sectors, %d cylinders\n\ Units = %s of %d * 512 bytes\n\ -\n", 738}, - {"%*s Flag Start End Blocks Id System\n", 739}, - {"Number of alternate cylinders", 740}, - {"Number of physical cylinders", 741}, - {"FAT12", 742}, - {"XENIX root", 743}, - {"XENIX usr", 744}, - {"FAT16 <32M", 745}, - {"Extended", 746}, - {"FAT16", 747}, - {"HPFS/NTFS", 748}, - {"AIX", 749}, - {"AIX bootable", 750}, - {"OS/2 Boot Manager", 751}, - {"Win95 FAT32", 752}, - {"Win95 FAT32 (LBA)", 753}, - {"Win95 FAT16 (LBA)", 754}, - {"Win95 Ext'd (LBA)", 755}, - {"OPUS", 756}, - {"Hidden FAT12", 757}, - {"Compaq diagnostics", 758}, - {"Hidden FAT16 <32M", 759}, - {"Hidden FAT16", 760}, - {"Hidden HPFS/NTFS", 761}, - {"AST Windows swapfile", 762}, - {"Hidden Win95 FAT32", 763}, - {"Hidden Win95 FAT32 (LBA)", 764}, - {"Hidden Win95 FAT16 (LBA)", 765}, - {"NEC DOS", 766}, - {"PartitionMagic recovery", 767}, - {"Venix 80286", 768}, - {"PPC PReP Boot", 769}, - {"SFS", 770}, - {"QNX4.x", 771}, - {"QNX4.x 2nd part", 772}, - {"QNX4.x 3rd part", 773}, - {"OnTrack DM", 774}, - {"OnTrack DM6 Aux1", 775}, - {"CP/M", 776}, - {"OnTrack DM6 Aux3", 777}, - {"OnTrackDM6", 778}, - {"EZ-Drive", 779}, - {"Golden Bow", 780}, - {"Priam Edisk", 781}, - {"SpeedStor", 782}, - {"GNU HURD or SysV", 783}, - {"Novell Netware 286", 784}, - {"Novell Netware 386", 785}, - {"DiskSecure Multi-Boot", 786}, - {"PC/IX", 787}, - {"Old Minix", 788}, - {"Minix / old Linux", 789}, - {"OS/2 hidden C: drive", 790}, - {"Linux extended", 791}, - {"NTFS volume set", 792}, - {"Amoeba", 793}, - {"Amoeba BBT", 794}, - {"IBM Thinkpad hibernation", 795}, - {"BSD/386", 796}, - {"OpenBSD", 797}, - {"NeXTSTEP", 798}, - {"BSDI fs", 799}, - {"BSDI swap", 800}, - {"DRDOS/sec (FAT-12)", 801}, - {"DRDOS/sec (FAT-16 < 32M)", 802}, - {"DRDOS/sec (FAT-16)", 803}, - {"Syrinx", 804}, - {"CP/M / CTOS / ...", 805}, - {"DOS access", 806}, - {"DOS R/O", 807}, - {"BeOS fs", 808}, - {"DOS secondary", 809}, - {"Linux raid autodetect", 810}, - {"LANstep", 811}, - {"BBT", 812}, - {"seek error on %s - cannot seek to %lu\n", 813}, - {"seek error: wanted 0x%08x%08x, got 0x%08x%08x\n", 814}, - {"out of memory - giving up\n", 815}, - {"read error on %s - cannot read sector %lu\n", 816}, - {"ERROR: sector %lu does not have an msdos signature\n", 817}, - {"write error on %s - cannot write sector %lu\n", 818}, - {"cannot open partition sector save file (%s)\n", 819}, - {"write error on %s\n", 820}, - {"cannot stat partition restore file (%s)\n", 821}, - {"partition restore file has wrong size - not restoring\n", 822}, - {"out of memory?\n", 823}, - {"cannot open partition restore file (%s)\n", 824}, - {"error reading %s\n", 825}, - {"cannot open device %s for writing\n", 826}, - {"error writing sector %lu on %s\n", 827}, +\n", 744}, + {"%*s Flag Start End Blocks Id System\n", 745}, + {"Number of alternate cylinders", 746}, + {"Number of physical cylinders", 747}, + {"FAT12", 748}, + {"XENIX root", 749}, + {"XENIX usr", 750}, + {"FAT16 <32M", 751}, + {"Extended", 752}, + {"FAT16", 753}, + {"HPFS/NTFS", 754}, + {"AIX", 755}, + {"AIX bootable", 756}, + {"OS/2 Boot Manager", 757}, + {"Win95 FAT32", 758}, + {"Win95 FAT32 (LBA)", 759}, + {"Win95 FAT16 (LBA)", 760}, + {"Win95 Ext'd (LBA)", 761}, + {"OPUS", 762}, + {"Hidden FAT12", 763}, + {"Compaq diagnostics", 764}, + {"Hidden FAT16 <32M", 765}, + {"Hidden FAT16", 766}, + {"Hidden HPFS/NTFS", 767}, + {"AST Windows swapfile", 768}, + {"Hidden Win95 FAT32", 769}, + {"Hidden Win95 FAT32 (LBA)", 770}, + {"Hidden Win95 FAT16 (LBA)", 771}, + {"NEC DOS", 772}, + {"PartitionMagic recovery", 773}, + {"Venix 80286", 774}, + {"PPC PReP Boot", 775}, + {"SFS", 776}, + {"QNX4.x", 777}, + {"QNX4.x 2nd part", 778}, + {"QNX4.x 3rd part", 779}, + {"OnTrack DM", 780}, + {"OnTrack DM6 Aux1", 781}, + {"CP/M", 782}, + {"OnTrack DM6 Aux3", 783}, + {"OnTrackDM6", 784}, + {"EZ-Drive", 785}, + {"Golden Bow", 786}, + {"Priam Edisk", 787}, + {"SpeedStor", 788}, + {"GNU HURD or SysV", 789}, + {"Novell Netware 286", 790}, + {"Novell Netware 386", 791}, + {"DiskSecure Multi-Boot", 792}, + {"PC/IX", 793}, + {"Old Minix", 794}, + {"Minix / old Linux", 795}, + {"OS/2 hidden C: drive", 796}, + {"Linux extended", 797}, + {"NTFS volume set", 798}, + {"Amoeba", 799}, + {"Amoeba BBT", 800}, + {"BSD/OS", 801}, + {"IBM Thinkpad hibernation", 802}, + {"BSD/386", 803}, + {"OpenBSD", 804}, + {"NeXTSTEP", 805}, + {"BSDI fs", 806}, + {"BSDI swap", 807}, + {"DRDOS/sec (FAT-12)", 808}, + {"DRDOS/sec (FAT-16 < 32M)", 809}, + {"DRDOS/sec (FAT-16)", 810}, + {"Syrinx", 811}, + {"CP/M / CTOS / ...", 812}, + {"DOS access", 813}, + {"DOS R/O", 814}, + {"BeOS fs", 815}, + {"DOS secondary", 816}, + {"Linux raid autodetect", 817}, + {"LANstep", 818}, + {"BBT", 819}, + {"seek error on %s - cannot seek to %lu\n", 820}, + {"seek error: wanted 0x%08x%08x, got 0x%08x%08x\n", 821}, + {"out of memory - giving up\n", 822}, + {"read error on %s - cannot read sector %lu\n", 823}, + {"ERROR: sector %lu does not have an msdos signature\n", 824}, + {"write error on %s - cannot write sector %lu\n", 825}, + {"cannot open partition sector save file (%s)\n", 826}, + {"write error on %s\n", 827}, + {"cannot stat partition restore file (%s)\n", 828}, + {"partition restore file has wrong size - not restoring\n", 829}, + {"out of memory?\n", 830}, + {"cannot open partition restore file (%s)\n", 831}, + {"error reading %s\n", 832}, + {"cannot open device %s for writing\n", 833}, + {"error writing sector %lu on %s\n", 834}, + {"Disk %s: cannot get size\n", 835}, + {"Disk %s: cannot get geometry\n", 836}, {"\ Warning: start=%d - this looks like a partition rather than\n\ the entire disk. Using fdisk on it is probably meaningless.\n\ -[Use the --force option if you really want this]\n", 828}, - {"Warning: HDIO_GETGEO says that there are %d heads\n", 829}, - {"Warning: HDIO_GETGEO says that there are %d sectors\n", 830}, - {"Warning: HDIO_GETGEO says that there are %d cylinders\n", 831}, - {"Disk %s: cannot get geometry\n", 832}, +[Use the --force option if you really want this]\n", 837}, + {"Warning: HDIO_GETGEO says that there are %d heads\n", 838}, + {"Warning: HDIO_GETGEO says that there are %d sectors\n", 839}, + {"Warning: BLKGETSIZE/HDIO_GETGEO says that there are %d cylinders\n", 840}, {"\ Warning: unlikely number of sectors (%d) - usually at most 63\n\ -This will give problems with all software that uses C/H/S addressing.\n", 833}, +This will give problems with all software that uses C/H/S addressing.\n", 841}, {"\ \n\ -Disk %s: %lu cylinders, %lu heads, %lu sectors/track\n", 834}, +Disk %s: %lu cylinders, %lu heads, %lu sectors/track\n", 842}, {"\ -%s of partition %s has impossible value for head: %d (should be in 0-%d)\n", 835}, +%s of partition %s has impossible value for head: %d (should be in 0-%d)\n", 843}, {"\ -%s of partition %s has impossible value for sector: %d (should be in 1-%d)\n", 836}, +%s of partition %s has impossible value for sector: %d (should be in 1-%d)\n", 844}, {"\ %s of partition %s has impossible value for cylinders: %d (should be in \ -0-%d)\n", 837}, +0-%d)\n", 845}, {"\ Id Name\n\ -\n", 838}, - {"Re-reading the partition table ...\n", 839}, +\n", 846}, + {"Re-reading the partition table ...\n", 847}, {"\ The command to re-read the partition table failed\n\ -Reboot your system now, before using mkfs\n", 840}, - {"Error closing %s\n", 841}, - {"%s: no such partition\n", 842}, - {"unrecognized format - using sectors\n", 843}, - {"# partition table of %s\n", 844}, - {"unimplemented format - using %s\n", 845}, +Reboot your system now, before using mkfs\n", 848}, + {"Error closing %s\n", 849}, + {"%s: no such partition\n", 850}, + {"unrecognized format - using sectors\n", 851}, + {"# partition table of %s\n", 852}, + {"unimplemented format - using %s\n", 853}, {"\ Units = cylinders of %lu bytes, blocks of 1024 bytes, counting from %d\n\ -\n", 846}, - {" Device Boot Start End #cyls #blocks Id System\n", 847}, +\n", 854}, + {" Device Boot Start End #cyls #blocks Id System\n", 855}, {"\ Units = sectors of 512 bytes, counting from %d\n\ -\n", 848}, - {" Device Boot Start End #sectors Id System\n", 849}, +\n", 856}, + {" Device Boot Start End #sectors Id System\n", 857}, {"\ Units = blocks of 1024 bytes, counting from %d\n\ -\n", 850}, - {" Device Boot Start End #blocks Id System\n", 851}, +\n", 858}, + {" Device Boot Start End #blocks Id System\n", 859}, {"\ Units = megabytes of 1048576 bytes, blocks of 1024 bytes, counting from %d\n\ -\n", 852}, - {" Device Boot Start End MB #blocks Id System\n", 853}, - {"\t\tstart: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", 854}, - {"\t\tend: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", 855}, - {"partition ends on cylinder %ld, beyond the end of the disk\n", 856}, - {"No partitions found\n", 857}, +\n", 860}, + {" Device Boot Start End MB #blocks Id System\n", 861}, + {"\t\tstart: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", 862}, + {"\t\tend: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", 863}, + {"partition ends on cylinder %ld, beyond the end of the disk\n", 864}, + {"No partitions found\n", 865}, {"\ Warning: The first partition looks like it was made\n\ for C/H/S=*/%ld/%ld (instead of %ld/%ld/%ld).\n\ -For this listing I'll assume that geometry.\n", 858}, - {"no partition table present.\n", 859}, - {"strange, only %d partitions defined.\n", 860}, - {"Warning: partition %s has size 0 but is not marked Empty\n", 861}, - {"Warning: partition %s has size 0 and is bootable\n", 862}, - {"Warning: partition %s has size 0 and nonzero start\n", 863}, - {"Warning: partition %s ", 864}, - {"is not contained in partition %s\n", 865}, - {"Warning: partitions %s ", 866}, - {"and %s overlap\n", 867}, - {"Warning: partition %s contains part of ", 868}, - {"the partition table (sector %lu),\n", 869}, - {"and will destroy it when filled\n", 870}, - {"Warning: partition %s starts at sector 0\n", 871}, - {"Warning: partition %s extends past end of disk\n", 872}, - {"Among the primary partitions, at most one can be extended\n", 873}, - {" (although this is not a problem under Linux)\n", 874}, - {"Warning: partition %s does not start at a cylinder boundary\n", 875}, - {"Warning: partition %s does not end at a cylinder boundary\n", 876}, +For this listing I'll assume that geometry.\n", 866}, + {"no partition table present.\n", 867}, + {"strange, only %d partitions defined.\n", 868}, + {"Warning: partition %s has size 0 but is not marked Empty\n", 869}, + {"Warning: partition %s has size 0 and is bootable\n", 870}, + {"Warning: partition %s has size 0 and nonzero start\n", 871}, + {"Warning: partition %s ", 872}, + {"is not contained in partition %s\n", 873}, + {"Warning: partitions %s ", 874}, + {"and %s overlap\n", 875}, + {"Warning: partition %s contains part of ", 876}, + {"the partition table (sector %lu),\n", 877}, + {"and will destroy it when filled\n", 878}, + {"Warning: partition %s starts at sector 0\n", 879}, + {"Warning: partition %s extends past end of disk\n", 880}, + {"Among the primary partitions, at most one can be extended\n", 881}, + {" (although this is not a problem under Linux)\n", 882}, + {"Warning: partition %s does not start at a cylinder boundary\n", 883}, + {"Warning: partition %s does not end at a cylinder boundary\n", 884}, {"\ Warning: more than one primary partition is marked bootable (active)\n\ -This does not matter for LILO, but the DOS MBR will not boot this disk.\n", 877}, +This does not matter for LILO, but the DOS MBR will not boot this disk.\n", 885}, {"\ Warning: usually one can boot from primary partitions only\n\ -LILO disregards the `bootable' flag.\n", 878}, +LILO disregards the `bootable' flag.\n", 886}, {"\ Warning: no primary partition is marked bootable (active)\n\ -This does not matter for LILO, but the DOS MBR will not boot this disk.\n", 879}, - {"\ -partition %s: start: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", 880}, - {"partition %s: end: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", 881}, - {"partition %s ends on cylinder %ld, beyond the end of the disk\n", 882}, - {"too many partitions - ignoring those past nr (%d)\n", 883}, - {"tree of partitions?\n", 884}, - {"detected Disk Manager - unable to handle that\n", 885}, - {"DM6 signature found - giving up\n", 886}, - {"strange..., an extended partition of size 0?\n", 887}, - {"strange..., a BSD partition of size 0?\n", 888}, - {" %s: unrecognized partition\n", 889}, - {"-n flag was given: Nothing changed\n", 890}, - {"Failed saving the old sectors - aborting\n", 891}, - {"Failed writing the partition on %s\n", 892}, - {"long or incomplete input line - quitting\n", 893}, - {"input error: `=' expected after %s field\n", 894}, - {"input error: unexpected character %c after %s field\n", 895}, - {"unrecognized input: %s\n", 896}, - {"number too big\n", 897}, - {"trailing junk after number\n", 898}, - {"no room for partition descriptor\n", 899}, - {"cannot build surrounding extended partition\n", 900}, - {"too many input fields\n", 901}, - {"No room for more\n", 902}, - {"Illegal type\n", 903}, - {"Warning: exceeds max allowable size (%lu)\n", 904}, - {"Warning: empty partition\n", 905}, - {"Warning: bad partition start (earliest %lu)\n", 906}, - {"unrecognized bootable flag - choose - or *\n", 907}, - {"partial c,h,s specification?\n", 908}, - {"Extended partition not where expected\n", 909}, - {"bad input\n", 910}, - {"too many partitions\n", 911}, +This does not matter for LILO, but the DOS MBR will not boot this disk.\n", 887}, + {"\ +partition %s: start: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", 888}, + {"partition %s: end: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n", 889}, + {"partition %s ends on cylinder %ld, beyond the end of the disk\n", 890}, + {"Warning: shifted start of the extd partition from %ld to %ld\n", 891}, + {"(For listing purposes only. Do not change its contents.)\n", 892}, + {"Warning: extended partition does not start at a cylinder boundary.\n", 893}, + {"DOS and Linux will interpret the contents differently.\n", 894}, + {"too many partitions - ignoring those past nr (%d)\n", 895}, + {"tree of partitions?\n", 896}, + {"detected Disk Manager - unable to handle that\n", 897}, + {"DM6 signature found - giving up\n", 898}, + {"strange..., an extended partition of size 0?\n", 899}, + {"strange..., a BSD partition of size 0?\n", 900}, + {" %s: unrecognized partition\n", 901}, + {"-n flag was given: Nothing changed\n", 902}, + {"Failed saving the old sectors - aborting\n", 903}, + {"Failed writing the partition on %s\n", 904}, + {"long or incomplete input line - quitting\n", 905}, + {"input error: `=' expected after %s field\n", 906}, + {"input error: unexpected character %c after %s field\n", 907}, + {"unrecognized input: %s\n", 908}, + {"number too big\n", 909}, + {"trailing junk after number\n", 910}, + {"no room for partition descriptor\n", 911}, + {"cannot build surrounding extended partition\n", 912}, + {"too many input fields\n", 913}, + {"No room for more\n", 914}, + {"Illegal type\n", 915}, + {"Warning: given size (%lu) exceeds max allowable size (%lu)\n", 916}, + {"Warning: empty partition\n", 917}, + {"Warning: bad partition start (earliest %lu)\n", 918}, + {"unrecognized bootable flag - choose - or *\n", 919}, + {"partial c,h,s specification?\n", 920}, + {"Extended partition not where expected\n", 921}, + {"bad input\n", 922}, + {"too many partitions\n", 923}, {"\ Input in the following format; absent fields get a default value.\n\ \n\ -Usually you only need to specify and (and perhaps ).\n", 912}, - {"version", 913}, - {"Usage: %s [options] device ...\n", 914}, - {"device: something like /dev/hda or /dev/sda", 915}, - {"useful options:", 916}, - {" -s [or --show-size]: list size of a partition", 917}, - {" -c [or --id]: print or change partition Id", 918}, - {" -l [or --list]: list partitions of each device", 919}, - {" -d [or --dump]: idem, but in a format suitable for later input", 920}, - {" -i [or --increment]: number cylinders etc. from 1 instead of from 0", 921}, +Usually you only need to specify and (and perhaps ).\n", 924}, + {"version", 925}, + {"Usage: %s [options] device ...\n", 926}, + {"device: something like /dev/hda or /dev/sda", 927}, + {"useful options:", 928}, + {" -s [or --show-size]: list size of a partition", 929}, + {" -c [or --id]: print or change partition Id", 930}, + {" -l [or --list]: list partitions of each device", 931}, + {" -d [or --dump]: idem, but in a format suitable for later input", 932}, + {" -i [or --increment]: number cylinders etc. from 1 instead of from 0", 933}, {"\ -uS, -uB, -uC, -uM: accept/report in units of \ -sectors/blocks/cylinders/MB", 922}, - {" -T [or --list-types]:list the known partition types", 923}, - {" -D [or --DOS]: for DOS-compatibility: waste a little space", 924}, - {" -R [or --re-read]: make kernel reread partition table", 925}, - {" -N# : change only the partition with number #", 926}, - {" -n : do not actually write to disk", 927}, - {"\ - -O file : save the sectors that will be overwritten to file", 928}, - {" -I file : restore these sectors again", 929}, - {" -v [or --version]: print version", 930}, - {" -? [or --help]: print this message", 931}, - {"dangerous options:", 932}, - {" -g [or --show-geometry]: print the kernel's idea of the geometry", 933}, +sectors/blocks/cylinders/MB", 934}, + {" -T [or --list-types]:list the known partition types", 935}, + {" -D [or --DOS]: for DOS-compatibility: waste a little space", 936}, + {" -R [or --re-read]: make kernel reread partition table", 937}, + {" -N# : change only the partition with number #", 938}, + {" -n : do not actually write to disk", 939}, + {"\ + -O file : save the sectors that will be overwritten to file", 940}, + {" -I file : restore these sectors again", 941}, + {" -v [or --version]: print version", 942}, + {" -? [or --help]: print this message", 943}, + {"dangerous options:", 944}, + {" -g [or --show-geometry]: print the kernel's idea of the geometry", 945}, {"\ -x [or --show-extended]: also list extended partitions on output\n\ - or expect descriptors for them on input", 934}, - {"\ - -L [or --Linux]: do not complain about things irrelevant for Linux", 935}, - {" -q [or --quiet]: suppress warning messages", 936}, - {" You can override the detected geometry using:", 937}, - {" -C# [or --cylinders #]:set the number of cylinders to use", 938}, - {" -H# [or --heads #]: set the number of heads to use", 939}, - {" -S# [or --sectors #]: set the number of sectors to use", 940}, - {"You can disable all consistency checking with:", 941}, - {" -f [or --force]: do what I say, even if it is stupid", 942}, - {"Usage:", 943}, - {"%s device\t\t list active partitions on device\n", 944}, - {"%s device n1 n2 ... activate partitions n1 ..., inactivate the rest\n", 945}, - {"%s -An device\t activate partition n, inactivate the other ones\n", 946}, - {"no command?\n", 947}, - {"total: %d blocks\n", 948}, - {"usage: sfdisk --print-id device partition-number\n", 949}, - {"usage: sfdisk --change-id device partition-number Id\n", 950}, - {"usage: sfdisk --id device partition-number [Id]\n", 951}, - {"can specify only one device (except with -l or -s)\n", 952}, - {"cannot open %s %s\n", 953}, - {"read-write", 954}, - {"for reading", 955}, - {"%s: OK\n", 956}, - {"%s: %d cylinders, %d heads, %d sectors/track\n", 957}, - {"%s: unknown geometry\n", 958}, - {"BLKGETSIZE ioctl failed for %s\n", 959}, - {"bad active byte: 0x%x instead of 0x80\n", 960}, + or expect descriptors for them on input", 946}, + {"\ + -L [or --Linux]: do not complain about things irrelevant for Linux", 947}, + {" -q [or --quiet]: suppress warning messages", 948}, + {" You can override the detected geometry using:", 949}, + {" -C# [or --cylinders #]:set the number of cylinders to use", 950}, + {" -H# [or --heads #]: set the number of heads to use", 951}, + {" -S# [or --sectors #]: set the number of sectors to use", 952}, + {"You can disable all consistency checking with:", 953}, + {" -f [or --force]: do what I say, even if it is stupid", 954}, + {"Usage:", 955}, + {"%s device\t\t list active partitions on device\n", 956}, + {"%s device n1 n2 ... activate partitions n1 ..., inactivate the rest\n", 957}, + {"%s -An device\t activate partition n, inactivate the other ones\n", 958}, + {"no command?\n", 959}, + {"total: %d blocks\n", 960}, + {"usage: sfdisk --print-id device partition-number\n", 961}, + {"usage: sfdisk --change-id device partition-number Id\n", 962}, + {"usage: sfdisk --id device partition-number [Id]\n", 963}, + {"can specify only one device (except with -l or -s)\n", 964}, + {"cannot open %s %s\n", 965}, + {"read-write", 966}, + {"for reading", 967}, + {"%s: OK\n", 968}, + {"%s: %ld cylinders, %ld heads, %ld sectors/track\n", 969}, + {"BLKGETSIZE ioctl failed for %s\n", 970}, + {"bad active byte: 0x%x instead of 0x80\n", 971}, {"\ Done\n\ -\n", 961}, +\n", 972}, {"\ You have %d active primary partitions. This does not matter for LILO,\n\ -but the DOS MBR will only boot a disk with 1 active partition.\n", 962}, - {"partition %s has id %x and is not hidden\n", 963}, - {"Bad Id %x\n", 964}, - {"This disk is currently in use.\n", 965}, - {"Fatal error: cannot find %s\n", 966}, - {"Warning: %s is not a block device\n", 967}, - {"Checking that no-one is using this disk right now ...\n", 968}, +but the DOS MBR will only boot a disk with 1 active partition.\n", 973}, + {"partition %s has id %x and is not hidden\n", 974}, + {"Bad Id %x\n", 975}, + {"This disk is currently in use.\n", 976}, + {"Fatal error: cannot find %s\n", 977}, + {"Warning: %s is not a block device\n", 978}, + {"Checking that no-one is using this disk right now ...\n", 979}, {"\ \n\ -This disk is currently in use - repartitioning is probably a bad idea.Umount \ -all file systems, and swapoff all swap partitions on this disk.Use the \ ---no-reread flag to suppress this check.\n", 969}, - {"Use the --force flag to overrule all checks.\n", 970}, - {"OK", 971}, - {"Old situation:\n", 972}, - {"Partition %d does not exist, cannot change it\n", 973}, - {"New situation:\n", 974}, +This disk is currently in use - repartitioning is probably a bad idea.\n\ +Umount all file systems, and swapoff all swap partitions on this disk.\n\ +Use the --no-reread flag to suppress this check.\n", 980}, + {"Use the --force flag to overrule all checks.\n", 981}, + {"OK\n", 982}, + {"Old situation:\n", 983}, + {"Partition %d does not exist, cannot change it\n", 984}, + {"New situation:\n", 985}, {"\ I don't like these partitions - nothing changed.\n\ -(If you really want this, use the --force option.)\n", 975}, - {"I don't like this - probably you should answer No\n", 976}, - {"Are you satisfied with this? [ynq] ", 977}, - {"Do you want to write this to disk? [ynq] ", 978}, +(If you really want this, use the --force option.)\n", 986}, + {"I don't like this - probably you should answer No\n", 987}, + {"Are you satisfied with this? [ynq] ", 988}, + {"Do you want to write this to disk? [ynq] ", 989}, {"\ \n\ -sfdisk: premature end of input\n", 979}, - {"Quitting - nothing changed\n", 980}, - {"Please answer one of y,n,q\n", 981}, +sfdisk: premature end of input\n", 990}, + {"Quitting - nothing changed\n", 991}, + {"Please answer one of y,n,q\n", 992}, {"\ Successfully wrote the new partition table\n\ -\n", 982}, +\n", 993}, {"\ If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)\n\ to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1\n\ -(See fdisk(8).)\n", 983}, - {"usage: banner [-w width]\n", 984}, - {"Message: ", 985}, - {"The character '%c' is not in my character set", 986}, - {"Message '%s' is OK\n", 987}, - {"Try `getopt --help' for more information.\n", 988}, - {"empty long option after -l or --long argument", 989}, - {"unknown shell after -s or --shell argument", 990}, - {"Usage: getopt optstring parameters\n", 991}, - {" getopt [options] [--] optstring parameters\n", 992}, - {" getopt [options] -o|--options optstring [options] [--]\n", 993}, - {" parameters\n", 994}, - {"\ - -a, --alternative Allow long options starting with single -\n", 995}, - {" -h, --help This small usage guide\n", 996}, - {" -l, --longoptions=longopts Long options to be recognized\n", 997}, - {"\ - -n, --name=progname The name under which errors are reported\n", 998}, - {" -o, --options=optstring Short options to be recognized\n", 999}, - {" -q, --quiet Disable error reporting by getopt(3)\n", 1000}, - {" -Q, --quiet-output No normal output\n", 1001}, - {" -s, --shell=shell Set shell quoting conventions\n", 1002}, - {" -T, --test Test for getopt(1) version\n", 1003}, - {" -V, --version Output version information\n", 1004}, - {"missing optstring argument", 1005}, - {"getopt (enhanced) 1.0.3\n", 1006}, - {"internal error, contact the author.", 1007}, - {"calling open_tty\n", 1008}, - {"calling termio_init\n", 1009}, - {"writing init string\n", 1010}, - {"before autobaud\n", 1011}, - {"waiting for cr-lf\n", 1012}, - {"read %c\n", 1013}, - {"reading login name\n", 1014}, - {"%s: can't exec %s: %m", 1015}, - {"can't malloc initstring", 1016}, - {"bad timeout value: %s", 1017}, - {"after getopt loop\n", 1018}, - {"exiting parseargs\n", 1019}, - {"entered parse_speeds\n", 1020}, - {"bad speed: %s", 1021}, - {"too many alternate speeds", 1022}, - {"exiting parsespeeds\n", 1023}, - {"%s: open for update: %m", 1024}, - {"%s: no utmp entry", 1025}, - {"/dev: chdir() failed: %m", 1026}, - {"/dev/%s: not a character device", 1027}, - {"open(2)\n", 1028}, - {"/dev/%s: cannot open as standard input: %m", 1029}, - {"%s: not open for read/write", 1030}, - {"duping\n", 1031}, - {"%s: dup problem: %m", 1032}, - {"term_io 2\n", 1033}, - {"user", 1034}, - {"users", 1035}, - {"%s: read: %m", 1036}, - {"%s: input overrun", 1037}, +(See fdisk(8).)\n", 994}, + {"usage: banner [-w width]\n", 995}, + {"Message: ", 996}, + {"The character '%c' is not in my character set", 997}, + {"Message '%s' is OK\n", 998}, + {"Try `getopt --help' for more information.\n", 999}, + {"empty long option after -l or --long argument", 1000}, + {"unknown shell after -s or --shell argument", 1001}, + {"Usage: getopt optstring parameters\n", 1002}, + {" getopt [options] [--] optstring parameters\n", 1003}, + {" getopt [options] -o|--options optstring [options] [--]\n", 1004}, + {" parameters\n", 1005}, + {"\ + -a, --alternative Allow long options starting with single -\n", 1006}, + {" -h, --help This small usage guide\n", 1007}, + {" -l, --longoptions=longopts Long options to be recognized\n", 1008}, + {"\ + -n, --name=progname The name under which errors are reported\n", 1009}, + {" -o, --options=optstring Short options to be recognized\n", 1010}, + {" -q, --quiet Disable error reporting by getopt(3)\n", 1011}, + {" -Q, --quiet-output No normal output\n", 1012}, + {" -s, --shell=shell Set shell quoting conventions\n", 1013}, + {" -T, --test Test for getopt(1) version\n", 1014}, + {" -V, --version Output version information\n", 1015}, + {"missing optstring argument", 1016}, + {"getopt (enhanced) 1.0.3\n", 1017}, + {"internal error, contact the author.", 1018}, + {"calling open_tty\n", 1019}, + {"calling termio_init\n", 1020}, + {"writing init string\n", 1021}, + {"before autobaud\n", 1022}, + {"waiting for cr-lf\n", 1023}, + {"read %c\n", 1024}, + {"reading login name\n", 1025}, + {"%s: can't exec %s: %m", 1026}, + {"can't malloc initstring", 1027}, + {"bad timeout value: %s", 1028}, + {"after getopt loop\n", 1029}, + {"exiting parseargs\n", 1030}, + {"entered parse_speeds\n", 1031}, + {"bad speed: %s", 1032}, + {"too many alternate speeds", 1033}, + {"exiting parsespeeds\n", 1034}, + {"%s: open for update: %m", 1035}, + {"%s: no utmp entry", 1036}, + {"/dev: chdir() failed: %m", 1037}, + {"/dev/%s: not a character device", 1038}, + {"open(2)\n", 1039}, + {"/dev/%s: cannot open as standard input: %m", 1040}, + {"%s: not open for read/write", 1041}, + {"duping\n", 1042}, + {"%s: dup problem: %m", 1043}, + {"term_io 2\n", 1044}, + {"user", 1045}, + {"users", 1046}, + {"%s: read: %m", 1047}, + {"%s: input overrun", 1048}, {"\ Usage: %s [-hiLmw] [-l login_program] [-t timeout] [-I initstring] [-H \ login_host] baud_rate,... line [termtype]\n\ or\t[-hiLmw] [-l login_program] [-t timeout] [-I initstring] [-H login_host] \ -line baud_rate,... [termtype]\n", 1038}, - {"badlogin: %s\n", 1039}, - {"sleepexit %d\n", 1040}, - {"login: memory low, login may fail\n", 1041}, - {"can't malloc for ttyclass", 1042}, - {"can't malloc for grplist", 1043}, - {"Login on %s from %s denied by default.\n", 1044}, - {"Login on %s from %s denied.\n", 1045}, - {"%s: you (user %d) don't exist.\n", 1046}, - {"%s: user \"%s\" does not exist.\n", 1047}, - {"%s: can only change local entries; use yp%s instead.\n", 1048}, - {"Changing finger information for %s.\n", 1049}, - {"Password error.", 1050}, - {"Password: ", 1051}, - {"Incorrect password.", 1052}, - {"Finger information not changed.\n", 1053}, - {"Usage: %s [ -f full-name ] [ -o office ] ", 1054}, +line baud_rate,... [termtype]\n", 1049}, + {"badlogin: %s\n", 1050}, + {"sleepexit %d\n", 1051}, + {"login: memory low, login may fail\n", 1052}, + {"can't malloc for ttyclass", 1053}, + {"can't malloc for grplist", 1054}, + {"Login on %s from %s denied by default.\n", 1055}, + {"Login on %s from %s denied.\n", 1056}, + {"%s: you (user %d) don't exist.\n", 1057}, + {"%s: user \"%s\" does not exist.\n", 1058}, + {"%s: can only change local entries; use yp%s instead.\n", 1059}, + {"Changing finger information for %s.\n", 1060}, + {"Password error.", 1061}, + {"Password: ", 1062}, + {"Incorrect password.", 1063}, + {"Finger information not changed.\n", 1064}, + {"Usage: %s [ -f full-name ] [ -o office ] ", 1065}, {"\ [ -p office-phone ]\n\ -\t[ -h home-phone ] ", 1055}, - {"[ --help ] [ --version ]\n", 1056}, +\t[ -h home-phone ] ", 1066}, + {"[ --help ] [ --version ]\n", 1067}, {"\ \n\ -Aborted.\n", 1057}, - {"field is too long.\n", 1058}, - {"'%c' is not allowed.\n", 1059}, - {"Control characters are not allowed.\n", 1060}, - {"Finger information *NOT* changed. Try again later.\n", 1061}, - {"Finger information changed.\n", 1062}, - {"malloc failed", 1063}, - {"%s: Your shell is not in /etc/shells, shell change denied\n", 1064}, - {"Changing shell for %s.\n", 1065}, - {"New shell", 1066}, - {"Shell not changed.\n", 1067}, - {"Shell *NOT* changed. Try again later.\n", 1068}, - {"Shell changed.\n", 1069}, - {"Usage: %s [ -s shell ] ", 1070}, - {"[ --list-shells ] [ --help ] [ --version ]\n", 1071}, - {" [ username ]\n", 1072}, - {"%s: shell must be a full path name.\n", 1073}, - {"%s: \"%s\" does not exist.\n", 1074}, - {"%s: \"%s\" is not executable.\n", 1075}, - {"%s: '%c' is not allowed.\n", 1076}, - {"%s: Control characters are not allowed.\n", 1077}, - {"Warning: \"%s\" is not listed in /etc/shells\n", 1078}, - {"%s: \"%s\" is not listed in /etc/shells.\n", 1079}, - {"%s: use -l option to see list\n", 1080}, - {"Warning: \"%s\" is not listed in /etc/shells.\n", 1081}, - {"Use %s -l to see list.\n", 1082}, - {"No known shells.\n", 1083}, - {"couldn't open /dev/urandom", 1084}, - {"couldn't read random data from /dev/urandom", 1085}, - {"can't open %s for reading", 1086}, - {"can't stat(%s)", 1087}, - {"%s doesn't have the correct filemodes", 1088}, - {"can't read data from %s", 1089}, - {"Can't read %s, exiting.", 1090}, - {"usage: last [-#] [-f file] [-t tty] [-h hostname] [user ...]\n", 1091}, - {" still logged in", 1092}, +Aborted.\n", 1068}, + {"field is too long.\n", 1069}, + {"'%c' is not allowed.\n", 1070}, + {"Control characters are not allowed.\n", 1071}, + {"Finger information *NOT* changed. Try again later.\n", 1072}, + {"Finger information changed.\n", 1073}, + {"malloc failed", 1074}, + {"%s: Your shell is not in /etc/shells, shell change denied\n", 1075}, + {"Changing shell for %s.\n", 1076}, + {"New shell", 1077}, + {"Shell not changed.\n", 1078}, + {"Shell *NOT* changed. Try again later.\n", 1079}, + {"Shell changed.\n", 1080}, + {"Usage: %s [ -s shell ] ", 1081}, + {"[ --list-shells ] [ --help ] [ --version ]\n", 1082}, + {" [ username ]\n", 1083}, + {"%s: shell must be a full path name.\n", 1084}, + {"%s: \"%s\" does not exist.\n", 1085}, + {"%s: \"%s\" is not executable.\n", 1086}, + {"%s: '%c' is not allowed.\n", 1087}, + {"%s: Control characters are not allowed.\n", 1088}, + {"Warning: \"%s\" is not listed in /etc/shells\n", 1089}, + {"%s: \"%s\" is not listed in /etc/shells.\n", 1090}, + {"%s: use -l option to see list\n", 1091}, + {"Warning: \"%s\" is not listed in /etc/shells.\n", 1092}, + {"Use %s -l to see list.\n", 1093}, + {"No known shells.\n", 1094}, + {"couldn't open /dev/urandom", 1095}, + {"couldn't read random data from /dev/urandom", 1096}, + {"can't open %s for reading", 1097}, + {"can't stat(%s)", 1098}, + {"%s doesn't have the correct filemodes", 1099}, + {"can't read data from %s", 1100}, + {"Can't read %s, exiting.", 1101}, + {"usage: last [-#] [-f file] [-t tty] [-h hostname] [user ...]\n", 1102}, + {" still logged in", 1103}, {"\ \n\ -wtmp begins %s", 1093}, - {"last: malloc failure.\n", 1094}, - {"last: gethostname", 1095}, +wtmp begins %s", 1104}, + {"last: malloc failure.\n", 1105}, + {"last: gethostname", 1106}, {"\ \n\ -interrupted %10.10s %5.5s \n", 1096}, - {"login: -h for super-user only.\n", 1097}, - {"usage: login [-fp] [username]\n", 1098}, - {"login: PAM Failure, aborting: %s\n", 1099}, - {"Couldn't initialize PAM: %s", 1100}, - {"login: ", 1101}, - {"FAILED LOGIN %d FROM %s FOR %s, %s", 1102}, +interrupted %10.10s %5.5s \n", 1107}, + {"login: -h for super-user only.\n", 1108}, + {"usage: login [-fp] [username]\n", 1109}, + {"login: PAM Failure, aborting: %s\n", 1110}, + {"Couldn't initialize PAM: %s", 1111}, + {"login: ", 1112}, + {"FAILED LOGIN %d FROM %s FOR %s, %s", 1113}, {"\ Login incorrect\n\ -\n", 1103}, - {"TOO MANY LOGIN TRIES (%d) FROM %s FOR %s, %s", 1104}, - {"FAILED LOGIN SESSION FROM %s FOR %s, %s", 1105}, +\n", 1114}, + {"TOO MANY LOGIN TRIES (%d) FROM %s FOR %s, %s", 1115}, + {"FAILED LOGIN SESSION FROM %s FOR %s, %s", 1116}, {"\ \n\ -Login incorrect\n", 1106}, - {"Illegal username", 1107}, - {"%s login refused on this terminal.\n", 1108}, - {"LOGIN %s REFUSED FROM %s ON TTY %s", 1109}, - {"LOGIN %s REFUSED ON TTY %s", 1110}, - {"Login incorrect\n", 1111}, +Login incorrect\n", 1117}, + {"Illegal username", 1118}, + {"%s login refused on this terminal.\n", 1119}, + {"LOGIN %s REFUSED FROM %s ON TTY %s", 1120}, + {"LOGIN %s REFUSED ON TTY %s", 1121}, + {"Login incorrect\n", 1122}, {"\ Too many users logged on already.\n\ -Try again later.\n", 1112}, - {"You have too many processes running.\n", 1113}, - {"Warning: no Kerberos tickets issued\n", 1114}, - {"Sorry -- your password has expired.\n", 1115}, - {"Warning: your password expires on %s %d, %d\n", 1116}, - {"Sorry -- your account has expired.\n", 1117}, - {"Warning: your account expires on %s %d, %d\n", 1118}, - {"DIALUP AT %s BY %s", 1119}, - {"ROOT LOGIN ON %s FROM %s", 1120}, - {"ROOT LOGIN ON %s", 1121}, - {"LOGIN ON %s BY %s FROM %s", 1122}, - {"LOGIN ON %s BY %s", 1123}, - {"You have %smail.\n", 1124}, - {"new ", 1125}, - {"login: failure forking: %s", 1126}, - {"setuid() failed", 1127}, - {"No directory %s!\n", 1128}, - {"Logging in with home = \"/\".\n", 1129}, - {"login: no memory for shell script.\n", 1130}, - {"login: couldn't exec shell script: %s.\n", 1131}, - {"login: no shell: %s.\n", 1132}, +Try again later.\n", 1123}, + {"You have too many processes running.\n", 1124}, + {"Warning: no Kerberos tickets issued\n", 1125}, + {"Sorry -- your password has expired.\n", 1126}, + {"Warning: your password expires on %s %d, %d\n", 1127}, + {"Sorry -- your account has expired.\n", 1128}, + {"Warning: your account expires on %s %d, %d\n", 1129}, + {"DIALUP AT %s BY %s", 1130}, + {"ROOT LOGIN ON %s FROM %s", 1131}, + {"ROOT LOGIN ON %s", 1132}, + {"LOGIN ON %s BY %s FROM %s", 1133}, + {"LOGIN ON %s BY %s", 1134}, + {"You have %smail.\n", 1135}, + {"new ", 1136}, + {"login: failure forking: %s", 1137}, + {"setuid() failed", 1138}, + {"No directory %s!\n", 1139}, + {"Logging in with home = \"/\".\n", 1140}, + {"login: no memory for shell script.\n", 1141}, + {"login: couldn't exec shell script: %s.\n", 1142}, + {"login: no shell: %s.\n", 1143}, {"\ \n\ -%s login: ", 1133}, - {"login name much too long.\n", 1134}, - {"NAME too long", 1135}, - {"login names may not start with '-'.\n", 1136}, - {"too many bare linefeeds.\n", 1137}, - {"EXCESSIVE linefeeds", 1138}, - {"Login timed out after %d seconds\n", 1139}, - {"Last login: %.*s ", 1140}, - {"from %.*s\n", 1141}, - {"on %.*s\n", 1142}, - {"LOGIN FAILURE FROM %s, %s", 1143}, - {"LOGIN FAILURE ON %s, %s", 1144}, - {"%d LOGIN FAILURES FROM %s, %s", 1145}, - {"%d LOGIN FAILURES ON %s, %s", 1146}, - {"is y\n", 1147}, - {"is n\n", 1148}, - {"usage: mesg [y | n]\n", 1149}, - {"newgrp: Who are you?", 1150}, - {"newgrp: setgid", 1151}, - {"newgrp: No such group.", 1152}, - {"newgrp: Permission denied", 1153}, - {"newgrp: setuid", 1154}, - {"No shell", 1155}, - {"The password must have at least 6 characters, try again.\n", 1156}, - {"The password must contain characters out of two of the following\n", 1157}, - {"classes: upper and lower case letters, digits and non alphanumeric\n", 1158}, - {"characters. See passwd(1) for more information.\n", 1159}, - {"You cannot reuse the old password.\n", 1160}, - {"Please don't use something like your username as password!\n", 1161}, - {"Please don't use something like your realname as password!\n", 1162}, - {"Usage: passwd [username [password]]\n", 1163}, - {"Only root may use the one and two argument forms.\n", 1164}, - {"Usage: passwd [-foqsvV] [user [password]]\n", 1165}, - {"Can't exec %s: %s\n", 1166}, - {"Cannot find login name", 1167}, - {"Only root can change the password for others.\n", 1168}, - {"Too many arguments.\n", 1169}, - {"Can't find username anywhere. Is `%s' really a user?", 1170}, - {"Sorry, I can only change local passwords. Use yppasswd instead.", 1171}, - {"UID and username does not match, imposter!", 1172}, - {"Changing password for %s\n", 1173}, - {"Enter old password: ", 1174}, - {"Illegal password, imposter.", 1175}, - {"Enter new password: ", 1176}, - {"Password not changed.", 1177}, - {"Re-type new password: ", 1178}, - {"You misspelled it. Password not changed.", 1179}, - {"password changed, user %s", 1180}, - {"ROOT PASSWORD CHANGED", 1181}, - {"password changed by root, user %s", 1182}, - {"calling setpwnam to set password.\n", 1183}, - {"Password *NOT* changed. Try again later.\n", 1184}, - {"Password changed.\n", 1185}, - {"Usage: shutdown [-h|-r] [-fqs] [now|hh:ss|+mins]\n", 1186}, - {"Shutdown process aborted", 1187}, - {"%s: Only root can shut a system down.\n", 1188}, - {"That must be tomorrow, can't you wait till then?\n", 1189}, - {"for maintenance; bounce, bounce", 1190}, - {"timeout = %d, quiet = %d, reboot = %d\n", 1191}, - {"The system is being shut down within 5 minutes", 1192}, - {"Login is therefore prohibited.", 1193}, - {"%s by %s: %s", 1194}, - {"rebooted", 1195}, - {"halted", 1196}, +%s login: ", 1144}, + {"login name much too long.\n", 1145}, + {"NAME too long", 1146}, + {"login names may not start with '-'.\n", 1147}, + {"too many bare linefeeds.\n", 1148}, + {"EXCESSIVE linefeeds", 1149}, + {"Login timed out after %d seconds\n", 1150}, + {"Last login: %.*s ", 1151}, + {"from %.*s\n", 1152}, + {"on %.*s\n", 1153}, + {"LOGIN FAILURE FROM %s, %s", 1154}, + {"LOGIN FAILURE ON %s, %s", 1155}, + {"%d LOGIN FAILURES FROM %s, %s", 1156}, + {"%d LOGIN FAILURES ON %s, %s", 1157}, + {"is y\n", 1158}, + {"is n\n", 1159}, + {"usage: mesg [y | n]\n", 1160}, + {"newgrp: Who are you?", 1161}, + {"newgrp: setgid", 1162}, + {"newgrp: No such group.", 1163}, + {"newgrp: Permission denied", 1164}, + {"newgrp: setuid", 1165}, + {"No shell", 1166}, + {"The password must have at least 6 characters, try again.\n", 1167}, + {"The password must contain characters out of two of the following\n", 1168}, + {"classes: upper and lower case letters, digits and non alphanumeric\n", 1169}, + {"characters. See passwd(1) for more information.\n", 1170}, + {"You cannot reuse the old password.\n", 1171}, + {"Please don't use something like your username as password!\n", 1172}, + {"Please don't use something like your realname as password!\n", 1173}, + {"Usage: passwd [username [password]]\n", 1174}, + {"Only root may use the one and two argument forms.\n", 1175}, + {"Usage: passwd [-foqsvV] [user [password]]\n", 1176}, + {"Can't exec %s: %s\n", 1177}, + {"Cannot find login name", 1178}, + {"Only root can change the password for others.\n", 1179}, + {"Too many arguments.\n", 1180}, + {"Can't find username anywhere. Is `%s' really a user?", 1181}, + {"Sorry, I can only change local passwords. Use yppasswd instead.", 1182}, + {"UID and username does not match, imposter!", 1183}, + {"Changing password for %s\n", 1184}, + {"Enter old password: ", 1185}, + {"Illegal password, imposter.", 1186}, + {"Enter new password: ", 1187}, + {"Password not changed.", 1188}, + {"Re-type new password: ", 1189}, + {"You misspelled it. Password not changed.", 1190}, + {"password changed, user %s", 1191}, + {"ROOT PASSWORD CHANGED", 1192}, + {"password changed by root, user %s", 1193}, + {"calling setpwnam to set password.\n", 1194}, + {"Password *NOT* changed. Try again later.\n", 1195}, + {"Password changed.\n", 1196}, + {"Usage: shutdown [-h|-r] [-fqs] [now|hh:ss|+mins]\n", 1197}, + {"Shutdown process aborted", 1198}, + {"%s: Only root can shut a system down.\n", 1199}, + {"That must be tomorrow, can't you wait till then?\n", 1200}, + {"for maintenance; bounce, bounce", 1201}, + {"timeout = %d, quiet = %d, reboot = %d\n", 1202}, + {"The system is being shut down within 5 minutes", 1203}, + {"Login is therefore prohibited.", 1204}, + {"%s by %s: %s", 1205}, + {"rebooted", 1206}, + {"halted", 1207}, {"\ \n\ -Why am I still alive after reboot?", 1197}, +Why am I still alive after reboot?", 1208}, {"\ \n\ -Now you can turn off the power...", 1198}, - {"Calling kernel power-off facility...\n", 1199}, - {"Error powering off\t%s\n", 1200}, - {"Executing the program \"%s\" ...\n", 1201}, - {"Error executing\t%s\n", 1202}, - {"URGENT: broadcast message from %s:", 1203}, - {"System going down IMMEDIATELY!\n", 1204}, - {"System going down in %d hour%s %d minutes", 1205}, - {"s", 1206}, - {"System going down in %d minute%s\n", 1207}, - {"\t... %s ...\n", 1208}, - {"Cannot fork for swapoff. Shrug!", 1209}, - {"Cannot exec swapoff, hoping umount will do the trick.", 1210}, - {"Cannot fork for umount, trying manually.", 1211}, - {"Cannot exec %s, trying umount.\n", 1212}, - {"Cannot exec umount, giving up on umount.", 1213}, - {"Unmounting any remaining filesystems...", 1214}, - {"shutdown: Couldn't umount %s\n", 1215}, - {"Booting to single user mode.\n", 1216}, - {"exec of single user shell failed\n", 1217}, - {"fork of single user shell failed\n", 1218}, +Now you can turn off the power...", 1209}, + {"Calling kernel power-off facility...\n", 1210}, + {"Error powering off\t%s\n", 1211}, + {"Executing the program \"%s\" ...\n", 1212}, + {"Error executing\t%s\n", 1213}, + {"URGENT: broadcast message from %s:", 1214}, + {"System going down IMMEDIATELY!\n", 1215}, + {"System going down in %d hour%s %d minutes", 1216}, + {"s", 1217}, + {"System going down in %d minute%s\n", 1218}, + {"\t... %s ...\n", 1219}, + {"Cannot fork for swapoff. Shrug!", 1220}, + {"Cannot exec swapoff, hoping umount will do the trick.", 1221}, + {"Cannot fork for umount, trying manually.", 1222}, + {"Cannot exec %s, trying umount.\n", 1223}, + {"Cannot exec umount, giving up on umount.", 1224}, + {"Unmounting any remaining filesystems...", 1225}, + {"shutdown: Couldn't umount %s\n", 1226}, + {"Booting to single user mode.\n", 1227}, + {"exec of single user shell failed\n", 1228}, + {"fork of single user shell failed\n", 1229}, + {"error opening fifo\n", 1230}, {"\ \n\ -Wrong password.\n", 1219}, - {"exec rc failed\n", 1220}, - {"open of rc file failed\n", 1221}, - {"fork of rc shell failed\n", 1222}, - {"fork failed\n", 1223}, - {"exec failed\n", 1224}, - {"cannot open inittab\n", 1225}, - {"no TERM or cannot stat tty\n", 1226}, - {"too many iov's (change code in wall/ttymsg.c)", 1227}, - {"excessively long line arg", 1228}, - {"cannot fork", 1229}, - {"fork: %s", 1230}, - {"%s: BAD ERROR", 1231}, - {"%s: the %s file is busy.\n", 1232}, - {"%s: the %s file is busy (%s present)\n", 1233}, - {"%s: can't link %s: %s\n", 1234}, - {"%s: can't unlock %s: %s (your changes are still in %s)\n", 1235}, - {"%s: Cannot fork\n", 1236}, - {"%s: %s unchanged\n", 1237}, - {"%s: no changes made\n", 1238}, - {"usage: %s [file]\n", 1239}, - {"%s: can't open temporary file.\n", 1240}, - {"Broadcast Message from %s@%s", 1241}, - {"%s: can't read %s.\n", 1242}, - {"%s: can't stat temporary file.\n", 1243}, - {"%s: can't read temporary file.\n", 1244}, - {"illegal month value: use 1-12", 1245}, - {"illegal year value: use 1-9999", 1246}, - {"usage: cal [-mjyV] [[month] year]\n", 1247}, - {"usage: %s [+format] [day month year]\n", 1248}, - {"St. Tib's Day", 1249}, - {"%s: unknown signal %s\n", 1250}, - {"%s: can't find process \"%s\"\n", 1251}, - {"%s: unknown signal %s; valid signals:\n", 1252}, - {"usage: %s [ -s signal | -p ] [ -a ] pid ...\n", 1253}, - {" %s -l [ signal ]\n", 1254}, - {"logger: %s: %s.\n", 1255}, - {"logger: unknown facility name: %s.\n", 1256}, - {"logger: unknown priority name: %s.\n", 1257}, - {"\ -usage: logger [-is] [-f file] [-p pri] [-t tag] [-u socket] [ message ... ]\n", 1258}, - {"usage: look [-dfa] [-t char] string [file]\n", 1259}, - {"Could not open %s\n", 1260}, - {"Got %d bytes from %s\n", 1261}, - {"namei: unable to get current directory - %s\n", 1262}, - {"namei: unable to chdir to %s - %s (%d)\n", 1263}, - {"usage: namei [-mx] pathname [pathname ...]\n", 1264}, - {"namei: could not chdir to root!\n", 1265}, - {"namei: could not stat root!\n", 1266}, - {" ? could not chdir into %s - %s (%d)\n", 1267}, - {" ? problems reading symlink %s - %s (%d)\n", 1268}, - {" *** EXCEEDED UNIX LIMIT OF SYMLINKS ***\n", 1269}, - {"namei: unknown file type 0%06o on file %s\n", 1270}, - {"usage: script [-a] [file]\n", 1271}, - {"Script started, file is %s\n", 1272}, - {"Script started on %s", 1273}, +Wrong password.\n", 1231}, + {"stat of path failed\n", 1232}, + {"open of directory failed\n", 1233}, + {"fork failed\n", 1234}, + {"exec failed\n", 1235}, + {"cannot open inittab\n", 1236}, + {"no TERM or cannot stat tty\n", 1237}, + {"error running programme\n", 1238}, + {"too many iov's (change code in wall/ttymsg.c)", 1239}, + {"excessively long line arg", 1240}, + {"cannot fork", 1241}, + {"fork: %s", 1242}, + {"%s: BAD ERROR", 1243}, + {"%s: the %s file is busy.\n", 1244}, + {"%s: the %s file is busy (%s present)\n", 1245}, + {"%s: can't link %s: %s\n", 1246}, + {"%s: can't unlock %s: %s (your changes are still in %s)\n", 1247}, + {"%s: Cannot fork\n", 1248}, + {"%s: %s unchanged\n", 1249}, + {"%s: no changes made\n", 1250}, + {"usage: %s [file]\n", 1251}, + {"%s: can't open temporary file.\n", 1252}, + {"Broadcast Message from %s@%s", 1253}, + {"%s: can't read %s.\n", 1254}, + {"%s: can't stat temporary file.\n", 1255}, + {"%s: can't read temporary file.\n", 1256}, + {"illegal month value: use 1-12", 1257}, + {"illegal year value: use 1-9999", 1258}, + {"usage: cal [-mjyV] [[month] year]\n", 1259}, + {"usage: %s [+format] [day month year]\n", 1260}, + {"St. Tib's Day", 1261}, + {"%s: unknown signal %s\n", 1262}, + {"%s: can't find process \"%s\"\n", 1263}, + {"%s: unknown signal %s; valid signals:\n", 1264}, + {"usage: %s [ -s signal | -p ] [ -a ] pid ...\n", 1265}, + {" %s -l [ signal ]\n", 1266}, + {"logger: %s: %s.\n", 1267}, + {"logger: unknown facility name: %s.\n", 1268}, + {"logger: unknown priority name: %s.\n", 1269}, + {"\ +usage: logger [-is] [-f file] [-p pri] [-t tag] [-u socket] [ message ... ]\n", 1270}, + {"usage: look [-dfa] [-t char] string [file]\n", 1271}, + {"Could not open %s\n", 1272}, + {"Got %d bytes from %s\n", 1273}, + {"namei: unable to get current directory - %s\n", 1274}, + {"namei: unable to chdir to %s - %s (%d)\n", 1275}, + {"usage: namei [-mx] pathname [pathname ...]\n", 1276}, + {"namei: could not chdir to root!\n", 1277}, + {"namei: could not stat root!\n", 1278}, + {" ? could not chdir into %s - %s (%d)\n", 1279}, + {" ? problems reading symlink %s - %s (%d)\n", 1280}, + {" *** EXCEEDED UNIX LIMIT OF SYMLINKS ***\n", 1281}, + {"namei: unknown file type 0%06o on file %s\n", 1282}, + {"usage: script [-a] [file]\n", 1283}, + {"Script started, file is %s\n", 1284}, + {"Script started on %s", 1285}, {"\ \n\ -Script done on %s", 1274}, - {"Script done, file is %s\n", 1275}, - {"openpty failed\n", 1276}, - {"Out of pty's\n", 1277}, - {"%s: Argument error, usage\n", 1278}, - {" [ -term terminal_name ]\n", 1279}, - {" [ -reset ]\n", 1280}, - {" [ -initialize ]\n", 1281}, - {" [ -cursor [on|off] ]\n", 1282}, - {" [ -snow [on|off] ]\n", 1283}, - {" [ -softscroll [on|off] ]\n", 1284}, - {" [ -repeat [on|off] ]\n", 1285}, - {" [ -appcursorkeys [on|off] ]\n", 1286}, - {" [ -linewrap [on|off] ]\n", 1287}, - {" [ -default ]\n", 1288}, - {" [ -foreground black|blue|green|cyan", 1289}, - {"|red|magenta|yellow|white|default ]\n", 1290}, - {" [ -background black|blue|green|cyan", 1291}, - {" [ -ulcolor black|grey|blue|green|cyan", 1292}, - {"|red|magenta|yellow|white ]\n", 1293}, - {" [ -ulcolor bright blue|green|cyan", 1294}, - {" [ -hbcolor black|grey|blue|green|cyan", 1295}, - {" [ -hbcolor bright blue|green|cyan", 1296}, - {" [ -standout [ attr ] ]\n", 1297}, - {" [ -inversescreen [on|off] ]\n", 1298}, - {" [ -bold [on|off] ]\n", 1299}, - {" [ -half-bright [on|off] ]\n", 1300}, - {" [ -blink [on|off] ]\n", 1301}, - {" [ -reverse [on|off] ]\n", 1302}, - {" [ -underline [on|off] ]\n", 1303}, - {" [ -store ]\n", 1304}, - {" [ -clear [all|rest] ]\n", 1305}, - {" [ -tabs [ tab1 tab2 tab3 ... ] ] (tabn = 1-160)\n", 1306}, - {" [ -clrtabs [ tab1 tab2 tab3 ... ] ] (tabn = 1-160)\n", 1307}, - {" [ -regtabs [1-160] ]\n", 1308}, - {" [ -blank [0-60] ]\n", 1309}, - {" [ -dump [1-NR_CONSOLES] ]\n", 1310}, - {" [ -append [1-NR_CONSOLES] ]\n", 1311}, - {" [ -file dumpfilename ]\n", 1312}, - {" [ -msg [on|off] ]\n", 1313}, - {" [ -msglevel [0-8] ]\n", 1314}, - {" [ -powersave [on|vsync|hsync|powerdown|off] ]\n", 1315}, - {" [ -powerdown [0-60] ]\n", 1316}, - {" [ -blength [0-2000] ]\n", 1317}, - {" [ -bfreq freqnumber ]\n", 1318}, - {"snow.on", 1319}, - {"snow.off", 1320}, - {"softscroll.on", 1321}, - {"softscroll.off", 1322}, - {"cannot (un)set powersave mode\n", 1323}, - {"klogctl error: %s\n", 1324}, - {"Error reading %s\n", 1325}, - {"Error writing screendump\n", 1326}, - {"couldn't read %s, and cannot ioctl dump\n", 1327}, - {"%s: $TERM is not defined.\n", 1328}, - {"usage: tsort [ inputfile ]\n", 1329}, - {"tsort: odd data count.\n", 1330}, - {"tsort: cycle in data.\n", 1331}, - {"tsort: internal error -- could not find cycle.\n", 1332}, - {"whereis [ -sbmu ] [ -SBM dir ... -f ] name...\n", 1333}, - {"write: can't find your tty's name\n", 1334}, - {"write: you have write permission turned off.\n", 1335}, - {"write: %s is not logged in on %s.\n", 1336}, - {"write: %s has messages disabled on %s\n", 1337}, - {"usage: write user [tty]\n", 1338}, - {"write: %s is not logged in\n", 1339}, - {"write: %s has messages disabled\n", 1340}, - {"write: %s is logged in more than once; writing to %s\n", 1341}, - {"Message from %s@%s on %s at %s ...", 1342}, - {"warning: error reading %s: %s", 1343}, - {"warning: can't open %s: %s", 1344}, - {"mount: could not open %s - using %s instead\n", 1345}, - {"can't create lock file %s: %s (use -n flag to override)", 1346}, - {"can't link lock file %s: %s (use -n flag to override)", 1347}, - {"can't open lock file %s: %s (use -n flag to override)", 1348}, - {"Can't lock lock file %s: %s\n", 1349}, - {"can't lock lock file %s: %s", 1350}, - {"timed out", 1351}, +Script done on %s", 1286}, + {"Script done, file is %s\n", 1287}, + {"openpty failed\n", 1288}, + {"Out of pty's\n", 1289}, + {"%s: Argument error, usage\n", 1290}, + {" [ -term terminal_name ]\n", 1291}, + {" [ -reset ]\n", 1292}, + {" [ -initialize ]\n", 1293}, + {" [ -cursor [on|off] ]\n", 1294}, + {" [ -snow [on|off] ]\n", 1295}, + {" [ -softscroll [on|off] ]\n", 1296}, + {" [ -repeat [on|off] ]\n", 1297}, + {" [ -appcursorkeys [on|off] ]\n", 1298}, + {" [ -linewrap [on|off] ]\n", 1299}, + {" [ -default ]\n", 1300}, + {" [ -foreground black|blue|green|cyan", 1301}, + {"|red|magenta|yellow|white|default ]\n", 1302}, + {" [ -background black|blue|green|cyan", 1303}, + {" [ -ulcolor black|grey|blue|green|cyan", 1304}, + {"|red|magenta|yellow|white ]\n", 1305}, + {" [ -ulcolor bright blue|green|cyan", 1306}, + {" [ -hbcolor black|grey|blue|green|cyan", 1307}, + {" [ -hbcolor bright blue|green|cyan", 1308}, + {" [ -standout [ attr ] ]\n", 1309}, + {" [ -inversescreen [on|off] ]\n", 1310}, + {" [ -bold [on|off] ]\n", 1311}, + {" [ -half-bright [on|off] ]\n", 1312}, + {" [ -blink [on|off] ]\n", 1313}, + {" [ -reverse [on|off] ]\n", 1314}, + {" [ -underline [on|off] ]\n", 1315}, + {" [ -store ]\n", 1316}, + {" [ -clear [all|rest] ]\n", 1317}, + {" [ -tabs [ tab1 tab2 tab3 ... ] ] (tabn = 1-160)\n", 1318}, + {" [ -clrtabs [ tab1 tab2 tab3 ... ] ] (tabn = 1-160)\n", 1319}, + {" [ -regtabs [1-160] ]\n", 1320}, + {" [ -blank [0-60] ]\n", 1321}, + {" [ -dump [1-NR_CONSOLES] ]\n", 1322}, + {" [ -append [1-NR_CONSOLES] ]\n", 1323}, + {" [ -file dumpfilename ]\n", 1324}, + {" [ -msg [on|off] ]\n", 1325}, + {" [ -msglevel [0-8] ]\n", 1326}, + {" [ -powersave [on|vsync|hsync|powerdown|off] ]\n", 1327}, + {" [ -powerdown [0-60] ]\n", 1328}, + {" [ -blength [0-2000] ]\n", 1329}, + {" [ -bfreq freqnumber ]\n", 1330}, + {"snow.on", 1331}, + {"snow.off", 1332}, + {"softscroll.on", 1333}, + {"softscroll.off", 1334}, + {"cannot (un)set powersave mode\n", 1335}, + {"klogctl error: %s\n", 1336}, + {"Error reading %s\n", 1337}, + {"Error writing screendump\n", 1338}, + {"couldn't read %s, and cannot ioctl dump\n", 1339}, + {"%s: $TERM is not defined.\n", 1340}, + {"usage: tsort [ inputfile ]\n", 1341}, + {"tsort: odd data count.\n", 1342}, + {"tsort: cycle in data.\n", 1343}, + {"tsort: internal error -- could not find cycle.\n", 1344}, + {"whereis [ -sbmu ] [ -SBM dir ... -f ] name...\n", 1345}, + {"write: can't find your tty's name\n", 1346}, + {"write: you have write permission turned off.\n", 1347}, + {"write: %s is not logged in on %s.\n", 1348}, + {"write: %s has messages disabled on %s\n", 1349}, + {"usage: write user [tty]\n", 1350}, + {"write: %s is not logged in\n", 1351}, + {"write: %s has messages disabled\n", 1352}, + {"write: %s is logged in more than once; writing to %s\n", 1353}, + {"Message from %s@%s on %s at %s ...", 1354}, + {"warning: error reading %s: %s", 1355}, + {"warning: can't open %s: %s", 1356}, + {"mount: could not open %s - using %s instead\n", 1357}, + {"can't create lock file %s: %s (use -n flag to override)", 1358}, + {"can't link lock file %s: %s (use -n flag to override)", 1359}, + {"can't open lock file %s: %s (use -n flag to override)", 1360}, + {"Can't lock lock file %s: %s\n", 1361}, + {"can't lock lock file %s: %s", 1362}, + {"timed out", 1363}, {"\ Cannot create link %s\n\ -Perhaps there is a stale lock file?\n", 1352}, - {"cannot open %s (%s) - mtab not updated", 1353}, - {"mount: warning: cannot change mounted device with a remount\n", 1354}, - {"mount: warning: cannot change filesystem type with a remount\n", 1355}, - {"error writing %s: %s", 1356}, - {"error changing mode of %s: %s\n", 1357}, - {"can't rename %s to %s: %s\n", 1358}, - {"loop: can't open device %s: %s\n", 1359}, - {"loop: can't get info on device %s: %s\n", 1360}, - {"%s: [%04x]:%ld (%s) offset %d, %s encryption\n", 1361}, - {"mount: could not find any device /dev/loop#", 1362}, +Perhaps there is a stale lock file?\n", 1364}, + {"cannot open %s (%s) - mtab not updated", 1365}, + {"mount: warning: cannot change mounted device with a remount\n", 1366}, + {"mount: warning: cannot change filesystem type with a remount\n", 1367}, + {"error writing %s: %s", 1368}, + {"error changing mode of %s: %s\n", 1369}, + {"can't rename %s to %s: %s\n", 1370}, + {"loop: can't open device %s: %s\n", 1371}, + {"loop: can't get info on device %s: %s\n", 1372}, + {"%s: [%04x]:%ld (%s) offset %d, %s encryption\n", 1373}, + {"mount: could not find any device /dev/loop#", 1374}, {"\ mount: Could not find any loop device.\n\ - Maybe /dev/loop# has a wrong major number?", 1363}, + Maybe /dev/loop# has a wrong major number?", 1375}, {"\ mount: Could not find any loop device, and, according to %s,\n\ this kernel does not know about the loop device.\n\ - (If so, then recompile or `insmod loop.o'.)", 1364}, + (If so, then recompile or `insmod loop.o'.)", 1376}, {"\ mount: Could not find any loop device. Maybe this kernel does not know\n\ about the loop device (then recompile or `insmod loop.o'), or\n\ - maybe /dev/loop# has the wrong major number?", 1365}, - {"mount: could not find any free loop device", 1366}, - {"Unsupported encryption type %s\n", 1367}, - {"Init (up to 16 hex digits): ", 1368}, - {"Non-hex digit '%c'.\n", 1369}, - {"Don't know how to get key for encryption system %d\n", 1370}, - {"set_loop(%s,%s,%d): success\n", 1371}, - {"loop: can't delete device %s: %s\n", 1372}, - {"del_loop(%s): success\n", 1373}, - {"This mount was compiled without loop support. Please recompile.\n", 1374}, - {"Cannot get loop info", 1375}, + maybe /dev/loop# has the wrong major number?", 1377}, + {"mount: could not find any free loop device", 1378}, + {"Unsupported encryption type %s\n", 1379}, + {"Couldn't lock into memory, exiting.\n", 1380}, + {"Init (up to 16 hex digits): ", 1381}, + {"Non-hex digit '%c'.\n", 1382}, + {"Don't know how to get key for encryption system %d\n", 1383}, + {"set_loop(%s,%s,%d): success\n", 1384}, + {"loop: can't delete device %s: %s\n", 1385}, + {"del_loop(%s): success\n", 1386}, + {"This mount was compiled without loop support. Please recompile.\n", 1387}, {"\ usage:\n\ %s loop_device # give info\n\ %s -d loop_device # delete\n\ - %s [ -e encryption ] [ -o offset ] loop_device file # setup\n", 1376}, - {"No loop support was available at compile time. Please recompile.\n", 1377}, - {"[mntent]: warning: no final newline at the end of %s\n", 1378}, - {"[mntent]: line %d in %s is bad%s\n", 1379}, - {"; rest of file ignored", 1380}, - {"mount: according to mtab, %s is already mounted on %s", 1381}, - {"mount: according to mtab, %s is mounted on %s", 1382}, - {"mount: can't open %s for writing: %s", 1383}, - {"mount: error writing %s: %s", 1384}, - {"mount: error changing mode of %s: %s", 1385}, - {"%s looks like swapspace - not mounted", 1386}, - {"mount failed", 1387}, - {"mount: only root can mount %s on %s", 1388}, - {"mount: loop device specified twice", 1389}, - {"mount: type specified twice", 1390}, - {"mount: skipping the setup of a loop device\n", 1391}, - {"mount: going to use the loop device %s\n", 1392}, - {"mount: failed setting up loop device\n", 1393}, - {"mount: setup loop device successfully\n", 1394}, - {"mount: this version was compiled without support for the type `nfs'", 1395}, - {"mount: cannot fork: %s", 1396}, - {"mount: can't open %s: %s", 1397}, - {"\ -mount: I could not determine the filesystem type, and none was specified", 1398}, - {"mount: you must specify the filesystem type", 1399}, - {"mount: mount failed", 1400}, - {"mount: mount point %s is not a directory", 1401}, - {"mount: permission denied", 1402}, - {"mount: must be superuser to use mount", 1403}, - {"mount: %s is busy", 1404}, - {"mount: proc already mounted", 1405}, - {"mount: %s already mounted or %s busy", 1406}, - {"mount: mount point %s does not exist", 1407}, - {"mount: mount point %s is a symbolic link to nowhere", 1408}, - {"mount: special device %s does not exist", 1409}, + %s [ -e encryption ] [ -o offset ] loop_device file # setup\n", 1388}, + {"not enough memory", 1389}, + {"No loop support was available at compile time. Please recompile.\n", 1390}, + {"[mntent]: warning: no final newline at the end of %s\n", 1391}, + {"[mntent]: line %d in %s is bad%s\n", 1392}, + {"; rest of file ignored", 1393}, + {"mount: according to mtab, %s is already mounted on %s", 1394}, + {"mount: according to mtab, %s is mounted on %s", 1395}, + {"mount: can't open %s for writing: %s", 1396}, + {"mount: error writing %s: %s", 1397}, + {"mount: error changing mode of %s: %s", 1398}, + {"%s looks like swapspace - not mounted", 1399}, + {"mount failed", 1400}, + {"mount: only root can mount %s on %s", 1401}, + {"mount: loop device specified twice", 1402}, + {"mount: type specified twice", 1403}, + {"mount: skipping the setup of a loop device\n", 1404}, + {"mount: going to use the loop device %s\n", 1405}, + {"mount: failed setting up loop device\n", 1406}, + {"mount: setup loop device successfully\n", 1407}, + {"mount: can't open %s: %s", 1408}, + {"mount: cannot not open %s for setting speed", 1409}, + {"mount: cannot set speed: %s", 1410}, + {"mount: cannot fork: %s", 1411}, + {"mount: this version was compiled without support for the type `nfs'", 1412}, + {"mount: failed with nfs mount version 4, trying 3..\n", 1413}, + {"\ +mount: I could not determine the filesystem type, and none was specified", 1414}, + {"mount: you must specify the filesystem type", 1415}, + {"mount: mount failed", 1416}, + {"mount: mount point %s is not a directory", 1417}, + {"mount: permission denied", 1418}, + {"mount: must be superuser to use mount", 1419}, + {"mount: %s is busy", 1420}, + {"mount: proc already mounted", 1421}, + {"mount: %s already mounted or %s busy", 1422}, + {"mount: mount point %s does not exist", 1423}, + {"mount: mount point %s is a symbolic link to nowhere", 1424}, + {"mount: special device %s does not exist", 1425}, {"\ mount: special device %s does not exist\n\ - (a path prefix is not a directory)\n", 1410}, - {"mount: %s not mounted already, or bad option", 1411}, + (a path prefix is not a directory)\n", 1426}, + {"mount: %s not mounted already, or bad option", 1427}, {"\ mount: wrong fs type, bad option, bad superblock on %s,\n\ - or too many mounted file systems", 1412}, - {"mount table full", 1413}, - {"mount: %s: can't read superblock", 1414}, - {"mount: %s has wrong major or minor number", 1415}, - {"mount: fs type %s not supported by kernel", 1416}, - {"mount: probably you meant %s", 1417}, - {"mount: maybe you meant iso9660 ?", 1418}, - {"mount: %s has wrong device number or fs type %s not supported", 1419}, - {"mount: %s is not a block device, and stat fails?", 1420}, + or too many mounted file systems", 1428}, + {"mount table full", 1429}, + {"mount: %s: can't read superblock", 1430}, + {"mount: %s has wrong major or minor number", 1431}, + {"mount: fs type %s not supported by kernel", 1432}, + {"mount: probably you meant %s", 1433}, + {"mount: maybe you meant iso9660 ?", 1434}, + {"mount: %s has wrong device number or fs type %s not supported", 1435}, + {"mount: %s is not a block device, and stat fails?", 1436}, {"\ mount: the kernel does not recognize %s as a block device\n\ - (maybe `insmod driver'?)", 1421}, - {"mount: %s is not a block device (maybe try `-o loop'?)", 1422}, - {"mount: %s is not a block device", 1423}, - {"mount: %s is not a valid block device", 1424}, - {"mount: block device %s is not permitted on its filesystem", 1425}, - {"mount: %s%s is write-protected, mounting read-only", 1426}, - {"block device ", 1427}, - {"mount: consider mounting %s by %s\n", 1428}, - {"UUID", 1429}, - {"label", 1430}, - {"mount: no such partition found", 1431}, - {"mount: no type was given - I'll assume nfs because of the colon\n", 1432}, - {"mount: backgrounding \"%s\"\n", 1433}, - {"mount: giving up \"%s\"\n", 1434}, - {"mount: %s already mounted on %s\n", 1435}, - {"\ -Usage: mount [-hV]\n\ + (maybe `insmod driver'?)", 1437}, + {"mount: %s is not a block device (maybe try `-o loop'?)", 1438}, + {"mount: %s is not a block device", 1439}, + {"mount: %s is not a valid block device", 1440}, + {"block device ", 1441}, + {"mount: %s%s is not permitted on its filesystem", 1442}, + {"mount: %s%s is write-protected but explicit `-w' flag given", 1443}, + {"mount: %s%s is write-protected, mounting read-only", 1444}, + {"mount: consider mounting %s by %s\n", 1445}, + {"UUID", 1446}, + {"label", 1447}, + {"mount: no such partition found", 1448}, + {"mount: no type was given - I'll assume nfs because of the colon\n", 1449}, + {"mount: backgrounding \"%s\"\n", 1450}, + {"mount: giving up \"%s\"\n", 1451}, + {"mount: %s already mounted on %s\n", 1452}, + {"\ +Usage: mount [-lhV]\n\ mount -a [-nfFrsvw] [-t vfstypes]\n\ mount [-nfrsvw] [-o options] special | node\n\ mount [-nfrsvw] [-t vfstype] [-o options] special node\n\ - A special device can be indicated by -L label or -U uuid .\n", 1436}, - {"mount: only root can do that", 1437}, - {"mount: no %s found - creating it..\n", 1438}, - {"mount: mounting %s\n", 1439}, - {"not mounted anything", 1440}, - {"mount: cannot find %s in %s", 1441}, - {"mount: can't find %s in %s or %s", 1442}, - {"mount: bad UUID", 1443}, - {"mount: you didn't specify a filesystem type for %s\n", 1444}, - {" I will try all types mentioned in %s or %s\n", 1445}, - {" and it looks like this is swapspace\n", 1446}, - {" I will try type %s\n", 1447}, - {"Trying %s\n", 1448}, - {"mount: excessively long host:dir argument\n", 1449}, - {"mount: warning: multiple hostnames not supported\n", 1450}, - {"mount: directory to mount not in host:dir format\n", 1451}, - {"mount: can't get address for %s\n", 1452}, - {"mount: got bad hp->h_length\n", 1453}, - {"mount: excessively long option argument\n", 1454}, - {"Warning: Unrecognized proto= option.\n", 1455}, - {"Warning: Option namlen is not supported.\n", 1456}, - {"unknown nfs mount parameter: %s=%d\n", 1457}, - {"Warning: option nolock is not supported.\n", 1458}, - {"unknown nfs mount option: %s%s\n", 1459}, - {"mount: got bad hp->h_length?\n", 1460}, - {"mount: %s:%s failed, reason given by server: %s\n", 1461}, - {"NFS over TCP is not supported.\n", 1462}, - {"nfs socket", 1463}, - {"nfs bindresvport", 1464}, - {"used portmapper to find NFS port\n", 1465}, - {"using port %d for nfs deamon\n", 1466}, - {"nfs connect", 1467}, - {"unknown nfs status return value: %d", 1468}, - {"not enough memory", 1469}, - {"bug in xstrndup call", 1470}, + A special device can be indicated by -L label or -U uuid .\n", 1453}, + {"mount: only root can do that", 1454}, + {"mount: no %s found - creating it..\n", 1455}, + {"mount: mounting %s\n", 1456}, + {"not mounted anything", 1457}, + {"mount: cannot find %s in %s", 1458}, + {"mount: can't find %s in %s or %s", 1459}, + {"mount: bad UUID", 1460}, + {"mount: you didn't specify a filesystem type for %s\n", 1461}, + {" I will try all types mentioned in %s or %s\n", 1462}, + {" and it looks like this is swapspace\n", 1463}, + {" I will try type %s\n", 1464}, + {"Trying %s\n", 1465}, + {"mount: excessively long host:dir argument\n", 1466}, + {"mount: warning: multiple hostnames not supported\n", 1467}, + {"mount: directory to mount not in host:dir format\n", 1468}, + {"mount: can't get address for %s\n", 1469}, + {"mount: got bad hp->h_length\n", 1470}, + {"mount: excessively long option argument\n", 1471}, + {"Warning: Unrecognized proto= option.\n", 1472}, + {"Warning: Option namlen is not supported.\n", 1473}, + {"unknown nfs mount parameter: %s=%d\n", 1474}, + {"Warning: option nolock is not supported.\n", 1475}, + {"unknown nfs mount option: %s%s\n", 1476}, + {"mount: got bad hp->h_length?\n", 1477}, + {"NFS over TCP is not supported.\n", 1478}, + {"nfs socket", 1479}, + {"nfs bindresvport", 1480}, + {"used portmapper to find NFS port\n", 1481}, + {"using port %d for nfs deamon\n", 1482}, + {"nfs connect", 1483}, + {"unknown nfs status return value: %d", 1484}, + {"bug in xstrndup call", 1485}, {"\ usage: %s [-hV]\n\ %s -a [-v]\n\ %s [-v] [-p priority] special ...\n\ - %s [-s]\n", 1471}, - {"%s on %s\n", 1472}, - {"swapon: cannot stat %s: %s\n", 1473}, - {"swapon: warning: %s has insecure permissions %04o, 0600 suggested\n", 1474}, - {"swapon: Skipping file %s - it appears to have holes.\n", 1475}, - {"%s: cannot open %s: %s\n", 1476}, - {"umount: compiled without support for -f\n", 1477}, - {"host: %s, directory: %s\n", 1478}, - {"umount: can't get address for %s\n", 1479}, - {"umount: got bad hostp->h_length\n", 1480}, - {"umount: %s: invalid block device", 1481}, - {"umount: %s: not mounted", 1482}, - {"umount: %s: can't write superblock", 1483}, - {"umount: %s: device is busy", 1484}, - {"umount: %s: not found", 1485}, - {"umount: %s: must be superuser to umount", 1486}, - {"umount: %s: block devices not permitted on fs", 1487}, - {"umount: %s: %s", 1488}, - {"no umount2, trying umount...\n", 1489}, - {"could not umount %s - trying %s instead\n", 1490}, - {"umount: %s busy - remounted read-only\n", 1491}, - {"umount: could not remount %s read-only\n", 1492}, - {"%s umounted\n", 1493}, - {"umount: cannot find list of filesystems to unmount", 1494}, + %s [-s]\n", 1486}, + {"%s on %s\n", 1487}, + {"swapon: cannot stat %s: %s\n", 1488}, + {"swapon: warning: %s has insecure permissions %04o, 0600 suggested\n", 1489}, + {"swapon: Skipping file %s - it appears to have holes.\n", 1490}, + {"%s: cannot open %s: %s\n", 1491}, + {"umount: compiled without support for -f\n", 1492}, + {"host: %s, directory: %s\n", 1493}, + {"umount: can't get address for %s\n", 1494}, + {"umount: got bad hostp->h_length\n", 1495}, + {"umount: %s: invalid block device", 1496}, + {"umount: %s: not mounted", 1497}, + {"umount: %s: can't write superblock", 1498}, + {"umount: %s: device is busy", 1499}, + {"umount: %s: not found", 1500}, + {"umount: %s: must be superuser to umount", 1501}, + {"umount: %s: block devices not permitted on fs", 1502}, + {"umount: %s: %s", 1503}, + {"no umount2, trying umount...\n", 1504}, + {"could not umount %s - trying %s instead\n", 1505}, + {"umount: %s busy - remounted read-only\n", 1506}, + {"umount: could not remount %s read-only\n", 1507}, + {"%s umounted\n", 1508}, + {"umount: cannot find list of filesystems to unmount", 1509}, {"\ Usage: umount [-hV]\n\ umount -a [-f] [-r] [-n] [-v] [-t vfstypes]\n\ - umount [-f] [-r] [-n] [-v] special | node...\n", 1495}, - {"umount: only root can do that", 1496}, - {"Trying to umount %s\n", 1497}, - {"Could not find %s in mtab\n", 1498}, - {"umount: %s is not mounted (according to mtab)", 1499}, - {"umount: it seems %s is mounted multiple times", 1500}, - {"umount: %s is not in the fstab (and you are not root)", 1501}, - {"umount: %s mount disagrees with the fstab", 1502}, - {"umount: only root can unmount %s from %s", 1503}, - {"umount: only %s can unmount %s from %s", 1504}, - {"You must be root to set the Ctrl-Alt-Del behaviour.\n", 1505}, - {"Usage: ctrlaltdel hard|soft\n", 1506}, + umount [-f] [-r] [-n] [-v] special | node...\n", 1510}, + {"umount: only root can do that", 1511}, + {"Trying to umount %s\n", 1512}, + {"Could not find %s in mtab\n", 1513}, + {"umount: %s is not mounted (according to mtab)", 1514}, + {"umount: it seems %s is mounted multiple times", 1515}, + {"umount: %s is not in the fstab (and you are not root)", 1516}, + {"umount: %s mount disagrees with the fstab", 1517}, + {"umount: only root can unmount %s from %s", 1518}, + {"umount: only %s can unmount %s from %s", 1519}, + {"You must be root to set the Ctrl-Alt-Del behaviour.\n", 1520}, + {"Usage: ctrlaltdel hard|soft\n", 1521}, {"\ File %s, For threshold value %lu, Maximum characters in fifo were %d,\n\ -and the maximum transfer rate in characters/second was %f\n", 1507}, +and the maximum transfer rate in characters/second was %f\n", 1522}, {"\ File %s, For threshold value %lu and timrout value %lu, Maximum characters \ in fifo were %d,\n\ -and the maximum transfer rate in characters/second was %f\n", 1508}, - {"Invalid interval value: %s\n", 1509}, - {"Invalid set value: %s\n", 1510}, - {"Invalid default value: %s\n", 1511}, - {"Invalid set time value: %s\n", 1512}, - {"Invalid default time value: %s\n", 1513}, +and the maximum transfer rate in characters/second was %f\n", 1523}, + {"Invalid interval value: %s\n", 1524}, + {"Invalid set value: %s\n", 1525}, + {"Invalid default value: %s\n", 1526}, + {"Invalid set time value: %s\n", 1527}, + {"Invalid default time value: %s\n", 1528}, {"\ Usage: %s [-q [-i interval]] ([-s value]|[-S value]) ([-t value]|[-T value]) \ -[-g|-G] file [file...]\n", 1514}, - {"Can't open %s: %s\n", 1515}, - {"Can't set %s to threshold %d: %s\n", 1516}, - {"Can't set %s to time threshold %d: %s\n", 1517}, - {"Can't get threshold for %s: %s\n", 1518}, - {"Can't get timeout for %s: %s\n", 1519}, - {"%s: %ld %s threshold and %ld %s timeout\n", 1520}, - {"current", 1521}, - {"default", 1522}, - {"Can't set signal handler", 1523}, - {"gettimeofday failed", 1524}, - {"Can't issue CYGETMON on %s: %s\n", 1525}, - {"%s: %lu ints, %lu/%lu chars; ", 1526}, - {"fifo: %lu thresh, %lu tmout, ", 1527}, - {"%lu max, %lu now\n", 1528}, - {" %f int/sec; %f rec, %f send (char/sec)\n", 1529}, - {"\ -%s: %lu ints, %lu chars; fifo: %lu thresh, %lu tmout, %lu max, %lu now\n", 1530}, - {" %f int/sec; %f rec (char/sec)\n", 1531}, - {"Usage: %s [-c] [-n level] [-s bufsize]\n", 1532}, - {"usage: %s [shm | msg | sem] id\n", 1533}, - {"usage: %s [-shm | -msg | -sem] id\n", 1534}, - {"resource deleted\n", 1535}, - {"usage : %s -asmq -tclup \n", 1536}, - {"\t%s [-s -m -q] -i id\n", 1537}, - {"\t%s -h for help.\n", 1538}, - {"%s provides information on ipc facilities for", 1539}, - {" which you have read access.\n", 1540}, +[-g|-G] file [file...]\n", 1529}, + {"Can't open %s: %s\n", 1530}, + {"Can't set %s to threshold %d: %s\n", 1531}, + {"Can't set %s to time threshold %d: %s\n", 1532}, + {"Can't get threshold for %s: %s\n", 1533}, + {"Can't get timeout for %s: %s\n", 1534}, + {"%s: %ld %s threshold and %ld %s timeout\n", 1535}, + {"current", 1536}, + {"default", 1537}, + {"Can't set signal handler", 1538}, + {"gettimeofday failed", 1539}, + {"Can't issue CYGETMON on %s: %s\n", 1540}, + {"%s: %lu ints, %lu/%lu chars; ", 1541}, + {"fifo: %lu thresh, %lu tmout, ", 1542}, + {"%lu max, %lu now\n", 1543}, + {" %f int/sec; %f rec, %f send (char/sec)\n", 1544}, + {"\ +%s: %lu ints, %lu chars; fifo: %lu thresh, %lu tmout, %lu max, %lu now\n", 1545}, + {" %f int/sec; %f rec (char/sec)\n", 1546}, + {"Usage: %s [-c] [-n level] [-s bufsize]\n", 1547}, + {"invalid id: %s\n", 1548}, + {"cannot remove id %s (%s)\n", 1549}, + {"usage: %s {shm | msg | sem} id ...\n", 1550}, + {"unknown resource type: %s\n", 1551}, + {"resource(s) deleted\n", 1552}, + {"usage : %s -asmq -tclup \n", 1553}, + {"\t%s [-s -m -q] -i id\n", 1554}, + {"\t%s -h for help.\n", 1555}, + {"%s provides information on ipc facilities for", 1556}, + {" which you have read access.\n", 1557}, {"\ Resource Specification:\n\ \t-m : shared_mem\n\ -\t-q : messages\n", 1541}, +\t-q : messages\n", 1558}, {"\ \t-s : semaphores\n\ -\t-a : all (default)\n", 1542}, +\t-a : all (default)\n", 1559}, {"\ Output Format:\n\ \t-t : time\n\ \t-p : pid\n\ -\t-c : creator\n", 1543}, +\t-c : creator\n", 1560}, {"\ \t-l : limits\n\ -\t-u : summary\n", 1544}, - {"-i id [-s -q -m] : details on resource identified by id\n", 1545}, - {"kernel not configured for shared memory\n", 1546}, - {"------ Shared Memory Limits --------\n", 1547}, - {"max number of segments = %d\n", 1548}, - {"max seg size (kbytes) = %d\n", 1549}, - {"max total shared memory (kbytes) = %d\n", 1550}, - {"min seg size (bytes) = %d\n", 1551}, - {"------ Shared Memory Status --------\n", 1552}, - {"segments allocated %d\n", 1553}, - {"pages allocated %ld\n", 1554}, - {"pages resident %ld\n", 1555}, - {"pages swapped %ld\n", 1556}, - {"Swap performance: %ld attempts\t %ld successes\n", 1557}, - {"------ Shared Memory Segment Creators/Owners --------\n", 1558}, - {"%-10s%-10s%-10s%-10s%-10s%-10s\n", 1559}, - {"shmid", 1560}, - {"perms", 1561}, - {"cuid", 1562}, - {"cgid", 1563}, - {"uid", 1564}, - {"gid", 1565}, - {"------ Shared Memory Attach/Detach/Change Times --------\n", 1566}, - {"%-10s%-10s %-20s%-20s%-20s\n", 1567}, - {"owner", 1568}, - {"attached", 1569}, - {"detached", 1570}, - {"changed", 1571}, - {"------ Shared Memory Creator/Last-op --------\n", 1572}, - {"%-10s%-10s%-10s%-10s\n", 1573}, - {"cpid", 1574}, - {"lpid", 1575}, - {"------ Shared Memory Segments --------\n", 1576}, - {"%-10s%-10s%-10s%-10s%-10s%-10s%-12s\n", 1577}, - {"key", 1578}, - {"bytes", 1579}, - {"nattch", 1580}, - {"status", 1581}, - {"Not set", 1582}, - {"dest", 1583}, - {"locked", 1584}, - {"kernel not configured for semaphores\n", 1585}, - {"------ Semaphore Limits --------\n", 1586}, - {"max number of arrays = %d\n", 1587}, - {"max semaphores per array = %d\n", 1588}, - {"max semaphores system wide = %d\n", 1589}, - {"max ops per semop call = %d\n", 1590}, - {"semaphore max value = %d\n", 1591}, - {"------ Semaphore Status --------\n", 1592}, - {"used arrays = %d\n", 1593}, - {"allocated semaphores = %d\n", 1594}, - {"------ Semaphore Arrays Creators/Owners --------\n", 1595}, - {"semid", 1596}, - {"------ Shared Memory Operation/Change Times --------\n", 1597}, - {"%-8s%-10s %-26.24s %-26.24s\n", 1598}, - {"last-op", 1599}, - {"last-changed", 1600}, - {"------ Semaphore Arrays --------\n", 1601}, - {"%-10s%-10s%-10s%-10s%-10s%-12s\n", 1602}, - {"nsems", 1603}, - {"------ Messages: Limits --------\n", 1604}, - {"max queues system wide = %d\n", 1605}, - {"max size of message (bytes) = %d\n", 1606}, - {"default max size of queue (bytes) = %d\n", 1607}, - {"------ Messages: Status --------\n", 1608}, - {"allocated queues = %d\n", 1609}, - {"used headers = %d\n", 1610}, - {"used space = %d bytes\n", 1611}, - {"------ Message Queues: Creators/Owners --------\n", 1612}, - {"msqid", 1613}, - {"------ Message Queues Send/Recv/Change Times --------\n", 1614}, - {"%-8s%-10s %-20s%-20s%-20s\n", 1615}, - {"send", 1616}, - {"recv", 1617}, - {"change", 1618}, - {"------ Message Queues PIDs --------\n", 1619}, - {"lspid", 1620}, - {"lrpid", 1621}, - {"------ Message Queues --------\n", 1622}, - {"%-10s%-10s%-10s%-10s%-12s%-12s\n", 1623}, - {"used-bytes", 1624}, - {"messages", 1625}, +\t-u : summary\n", 1561}, + {"-i id [-s -q -m] : details on resource identified by id\n", 1562}, + {"kernel not configured for shared memory\n", 1563}, + {"------ Shared Memory Limits --------\n", 1564}, + {"max number of segments = %d\n", 1565}, + {"max seg size (kbytes) = %d\n", 1566}, + {"max total shared memory (kbytes) = %d\n", 1567}, + {"min seg size (bytes) = %d\n", 1568}, + {"------ Shared Memory Status --------\n", 1569}, + {"segments allocated %d\n", 1570}, + {"pages allocated %ld\n", 1571}, + {"pages resident %ld\n", 1572}, + {"pages swapped %ld\n", 1573}, + {"Swap performance: %ld attempts\t %ld successes\n", 1574}, + {"------ Shared Memory Segment Creators/Owners --------\n", 1575}, + {"%-10s%-10s%-10s%-10s%-10s%-10s\n", 1576}, + {"shmid", 1577}, + {"perms", 1578}, + {"cuid", 1579}, + {"cgid", 1580}, + {"uid", 1581}, + {"gid", 1582}, + {"------ Shared Memory Attach/Detach/Change Times --------\n", 1583}, + {"%-10s%-10s %-20s%-20s%-20s\n", 1584}, + {"owner", 1585}, + {"attached", 1586}, + {"detached", 1587}, + {"changed", 1588}, + {"------ Shared Memory Creator/Last-op --------\n", 1589}, + {"%-10s%-10s%-10s%-10s\n", 1590}, + {"cpid", 1591}, + {"lpid", 1592}, + {"------ Shared Memory Segments --------\n", 1593}, + {"%-10s%-10s%-10s%-10s%-10s%-10s%-12s\n", 1594}, + {"key", 1595}, + {"bytes", 1596}, + {"nattch", 1597}, + {"status", 1598}, + {"Not set", 1599}, + {"dest", 1600}, + {"locked", 1601}, + {"kernel not configured for semaphores\n", 1602}, + {"------ Semaphore Limits --------\n", 1603}, + {"max number of arrays = %d\n", 1604}, + {"max semaphores per array = %d\n", 1605}, + {"max semaphores system wide = %d\n", 1606}, + {"max ops per semop call = %d\n", 1607}, + {"semaphore max value = %d\n", 1608}, + {"------ Semaphore Status --------\n", 1609}, + {"used arrays = %d\n", 1610}, + {"allocated semaphores = %d\n", 1611}, + {"------ Semaphore Arrays Creators/Owners --------\n", 1612}, + {"semid", 1613}, + {"------ Shared Memory Operation/Change Times --------\n", 1614}, + {"%-8s%-10s %-26.24s %-26.24s\n", 1615}, + {"last-op", 1616}, + {"last-changed", 1617}, + {"------ Semaphore Arrays --------\n", 1618}, + {"%-10s%-10s%-10s%-10s%-10s%-12s\n", 1619}, + {"nsems", 1620}, + {"------ Messages: Limits --------\n", 1621}, + {"max queues system wide = %d\n", 1622}, + {"max size of message (bytes) = %d\n", 1623}, + {"default max size of queue (bytes) = %d\n", 1624}, + {"------ Messages: Status --------\n", 1625}, + {"allocated queues = %d\n", 1626}, + {"used headers = %d\n", 1627}, + {"used space = %d bytes\n", 1628}, + {"------ Message Queues: Creators/Owners --------\n", 1629}, + {"msqid", 1630}, + {"------ Message Queues Send/Recv/Change Times --------\n", 1631}, + {"%-8s%-10s %-20s%-20s%-20s\n", 1632}, + {"send", 1633}, + {"recv", 1634}, + {"change", 1635}, + {"------ Message Queues PIDs --------\n", 1636}, + {"lspid", 1637}, + {"lrpid", 1638}, + {"------ Message Queues --------\n", 1639}, + {"%-10s%-10s%-10s%-10s%-12s%-12s\n", 1640}, + {"used-bytes", 1641}, + {"messages", 1642}, {"\ \n\ -Shared memory Segment shmid=%d\n", 1626}, - {"uid=%d\tgid=%d\tcuid=%d\tcgid=%d\n", 1627}, - {"mode=%#o\taccess_perms=%#o\n", 1628}, - {"bytes=%d\tlpid=%d\tcpid=%d\tnattch=%d\n", 1629}, - {"att_time=%s", 1630}, - {"Not set\n", 1631}, - {"det_time=%s", 1632}, - {"change_time=%s", 1633}, +Shared memory Segment shmid=%d\n", 1643}, + {"uid=%d\tgid=%d\tcuid=%d\tcgid=%d\n", 1644}, + {"mode=%#o\taccess_perms=%#o\n", 1645}, + {"bytes=%d\tlpid=%d\tcpid=%d\tnattch=%d\n", 1646}, + {"att_time=%s", 1647}, + {"Not set\n", 1648}, + {"det_time=%s", 1649}, + {"change_time=%s", 1650}, {"\ \n\ -Message Queue msqid=%d\n", 1634}, - {"uid=%d\tgid=%d\tcuid=%d\tcgid=%d\tmode=%#o\n", 1635}, - {"cbytes=%d\tqbytes=%d\tqnum=%d\tlspid=%d\tlrpid=%d\n", 1636}, - {"send_time=%srcv_time=%schange_time=%s", 1637}, - {"Not Set\n", 1638}, +Message Queue msqid=%d\n", 1651}, + {"uid=%d\tgid=%d\tcuid=%d\tcgid=%d\tmode=%#o\n", 1652}, + {"cbytes=%d\tqbytes=%d\tqnum=%d\tlspid=%d\tlrpid=%d\n", 1653}, + {"send_time=%srcv_time=%schange_time=%s", 1654}, + {"Not Set\n", 1655}, {"\ \n\ -Semaphore Array semid=%d\n", 1639}, - {"uid=%d\t gid=%d\t cuid=%d\t cgid=%d\n", 1640}, - {"mode=%#o, access_perms=%#o\n", 1641}, - {"nsems = %d\n", 1642}, - {"otime = %s", 1643}, - {"ctime = %s", 1644}, - {"%-10s%-10s%-10s%-10s%-10s\n", 1645}, - {"semnum", 1646}, - {"value", 1647}, - {"ncount", 1648}, - {"zcount", 1649}, - {"pid", 1650}, - {"usage: rdev [ -rsv ] [ -o OFFSET ] [ IMAGE [ VALUE [ OFFSET ] ] ]", 1651}, - {"\ - rdev /dev/fd0 (or rdev /linux, etc.) displays the current ROOT device", 1652}, - {" rdev /dev/fd0 /dev/hda2 sets ROOT to /dev/hda2", 1653}, - {" rdev -R /dev/fd0 1 set the ROOTFLAGS (readonly status)", 1654}, - {" rdev -s /dev/fd0 /dev/hda2 set the SWAP device", 1655}, - {" rdev -r /dev/fd0 627 set the RAMDISK size", 1656}, - {" rdev -v /dev/fd0 1 set the bootup VIDEOMODE", 1657}, - {" rdev -o N ... use the byte offset N", 1658}, - {" rootflags ... same as rdev -R", 1659}, - {" swapdev ... same as rdev -s", 1660}, - {" ramsize ... same as rdev -r", 1661}, - {" vidmode ... same as rdev -v", 1662}, - {"\ -Note: video modes are: -3=Ask, -2=Extended, -1=NormalVga, 1=key1, 2=key2,...", 1663}, - {" use -R 1 to mount root readonly, -R 0 for read/write.", 1664}, +Semaphore Array semid=%d\n", 1656}, + {"uid=%d\t gid=%d\t cuid=%d\t cgid=%d\n", 1657}, + {"mode=%#o, access_perms=%#o\n", 1658}, + {"nsems = %d\n", 1659}, + {"otime = %s", 1660}, + {"ctime = %s", 1661}, + {"%-10s%-10s%-10s%-10s%-10s\n", 1662}, + {"semnum", 1663}, + {"value", 1664}, + {"ncount", 1665}, + {"zcount", 1666}, + {"pid", 1667}, + {"usage: rdev [ -rsv ] [ -o OFFSET ] [ IMAGE [ VALUE [ OFFSET ] ] ]", 1668}, + {"\ + rdev /dev/fd0 (or rdev /linux, etc.) displays the current ROOT device", 1669}, + {" rdev /dev/fd0 /dev/hda2 sets ROOT to /dev/hda2", 1670}, + {" rdev -R /dev/fd0 1 set the ROOTFLAGS (readonly status)", 1671}, + {" rdev -s /dev/fd0 /dev/hda2 set the SWAP device", 1672}, + {" rdev -r /dev/fd0 627 set the RAMDISK size", 1673}, + {" rdev -v /dev/fd0 1 set the bootup VIDEOMODE", 1674}, + {" rdev -o N ... use the byte offset N", 1675}, + {" rootflags ... same as rdev -R", 1676}, + {" swapdev ... same as rdev -s", 1677}, + {" ramsize ... same as rdev -r", 1678}, + {" vidmode ... same as rdev -v", 1679}, + {"\ +Note: video modes are: -3=Ask, -2=Extended, -1=NormalVga, 1=key1, 2=key2,...", 1680}, + {" use -R 1 to mount root readonly, -R 0 for read/write.", 1681}, {"\ %s: Usage: \"%s [options]\n\ \t -m (default = \"%s\")\n\ @@ -2124,110 +2147,110 @@ Note: video modes are: -3=Ask, -2=Extended, -1=NormalVga, 1=key1, 2=key2,...", 1 \t -v print verbose data\n\ \t -a print all symbols, even if count is 0\n\ \t -r reset all the counters (root only)\n\ -\t -V print version and exit\n", 1665}, - {"%s Version %s\n", 1666}, - {"anything\n", 1667}, - {"Sampling_step: %i\n", 1668}, - {"%s: %s(%i): wrong map line\n", 1669}, - {"%s: can't find \"_stext\" in %s\n", 1670}, - {"total", 1671}, - {"\ -usage: renice priority [ [ -p ] pids ] [ [ -g ] pgrps ] [ [ -u ] users ]\n", 1672}, - {"renice: %s: unknown user\n", 1673}, - {"renice: %s: bad value\n", 1674}, - {"getpriority", 1675}, - {"setpriority", 1676}, - {"%d: old priority %d, new priority %d\n", 1677}, - {"usage: %s program [arg ...]\n", 1678}, +\t -V print version and exit\n", 1682}, + {"%s Version %s\n", 1683}, + {"anything\n", 1684}, + {"Sampling_step: %i\n", 1685}, + {"%s: %s(%i): wrong map line\n", 1686}, + {"%s: can't find \"_stext\" in %s\n", 1687}, + {"total", 1688}, + {"\ +usage: renice priority [ [ -p ] pids ] [ [ -g ] pgrps ] [ [ -u ] users ]\n", 1689}, + {"renice: %s: unknown user\n", 1690}, + {"renice: %s: bad value\n", 1691}, + {"getpriority", 1692}, + {"setpriority", 1693}, + {"%d: old priority %d, new priority %d\n", 1694}, + {"usage: %s program [arg ...]\n", 1695}, {"\ Usage: %s [ -i | -t