diff options
author | Karel Zak | 2006-12-07 00:25:48 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:25:48 +0100 |
commit | 364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed (patch) | |
tree | c60dfad813ca42bf619fe2ac8ce893d2331e508f /sys-utils | |
parent | Imported from util-linux-2.11b tarball. (diff) | |
download | kernel-qcow2-util-linux-364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed.tar.gz kernel-qcow2-util-linux-364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed.tar.xz kernel-qcow2-util-linux-364cda4857f7dd5e2b4e2eb7583a2eaa279ef4ed.zip |
Imported from util-linux-2.11f tarball.
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/Makefile | 3 | ||||
-rw-r--r-- | sys-utils/dmesg.8 | 15 | ||||
-rw-r--r-- | sys-utils/dmesg.c | 2 | ||||
-rw-r--r-- | sys-utils/ipc.texi | 5 | ||||
-rw-r--r-- | sys-utils/ipcs.c | 173 | ||||
-rw-r--r-- | sys-utils/rdev.8 | 61 | ||||
-rw-r--r-- | sys-utils/rdev.c | 119 | ||||
-rw-r--r-- | sys-utils/readprofile.c | 6 | ||||
-rw-r--r-- | sys-utils/swapdev.8 | 1 |
9 files changed, 199 insertions, 186 deletions
diff --git a/sys-utils/Makefile b/sys-utils/Makefile index 66f913a62..b11517428 100644 --- a/sys-utils/Makefile +++ b/sys-utils/Makefile @@ -38,7 +38,7 @@ endif endif ifeq "$(ARCH)" "intel" -MAN8:=$(MAN8) rdev.8 ramsize.8 rootflags.8 swapdev.8 vidmode.8 +MAN8:=$(MAN8) rdev.8 ramsize.8 rootflags.8 vidmode.8 USRSBIN:=$(USRSBIN) rdev endif @@ -84,7 +84,6 @@ install: all $(INSTALLBIN) $(USRBIN) $(USRBINDIR) $(INSTALLBIN) $(USRSBIN) $(USRSBINDIR) ifeq "$(ARCH)" "intel" - (cd $(USRSBINDIR); ln -sf rdev swapdev) (cd $(USRSBINDIR); ln -sf rdev ramsize) (cd $(USRSBINDIR); ln -sf rdev vidmode) (cd $(USRSBINDIR); ln -sf rdev rootflags) diff --git a/sys-utils/dmesg.8 b/sys-utils/dmesg.8 index f453d7145..8064b1d0e 100644 --- a/sys-utils/dmesg.8 +++ b/sys-utils/dmesg.8 @@ -20,16 +20,19 @@ file to whoever can debug their problem. .SH OPTIONS .TP .B \-c -clear the ring buffer contents after printing. +Clear the ring buffer contents after printing. .TP .BI \-s bufsize -use a buffer of bufsize to query the kernel ring buffer. This is -8196 by default (this matches the default kernel syslog buffer size in -2.0.33 and 2.1.103). If you have set the kernel buffer to larger than -the default then this option can be used to view the entire buffer. +Use a buffer of size +.I bufsize +to query the kernel ring buffer. This is 16392 by default. +(The default kernel syslog buffer size was 4096 +at first, 8192 since 1.3.54, 16384 since 2.1.113.) +If you have set the kernel buffer to be larger than the default +then this option can be used to view the entire buffer. .TP .BI \-n level -set the +Set the .I level at which logging of messages is done to the console. For example, .B \-n 1 diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index f9d1e282e..a172fc1f4 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -40,7 +40,7 @@ usage(void) { int main( int argc, char *argv[] ) { char *buf; - int bufsize=16392; + int bufsize = 16392; int i; int n; int c; diff --git a/sys-utils/ipc.texi b/sys-utils/ipc.texi index cd9127167..53c4e4e57 100644 --- a/sys-utils/ipc.texi +++ b/sys-utils/ipc.texi @@ -30,7 +30,10 @@ Permission is granted to use this material and the accompanying programs within the terms of the GNU GPL. @end titlepage - +@dircategory Miscellaneous +@direntry +* ipc: (ipc). System V style inter process communication +@end direntry @node top, Overview, Notes, (dir) @chapter System V IPC. diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c index eec8bce9c..60dcb319d 100644 --- a/sys-utils/ipcs.c +++ b/sys-utils/ipcs.c @@ -232,25 +232,25 @@ print_perms (int id, struct ipc_perm *ipcp) { struct passwd *pw; struct group *gr; - printf ("%-10d%-10o", id, ipcp->mode & 0777); + printf ("%-10d %-10o", id, ipcp->mode & 0777); if ((pw = getpwuid(ipcp->cuid))) - printf("%-10s", pw->pw_name); + printf(" %-10s", pw->pw_name); else - printf("%-10d", ipcp->cuid); + printf(" %-10d", ipcp->cuid); if ((gr = getgrgid(ipcp->cgid))) - printf("%-10s", gr->gr_name); + printf(" %-10s", gr->gr_name); else - printf("%-10d", ipcp->cgid); + printf(" %-10d", ipcp->cgid); if ((pw = getpwuid(ipcp->uid))) - printf("%-10s", pw->pw_name); + printf(" %-10s", pw->pw_name); else - printf("%-10d", ipcp->uid); + printf(" %-10d", ipcp->uid); if ((gr = getgrgid(ipcp->gid))) - printf("%-10s\n", gr->gr_name); + printf(" %-10s\n", gr->gr_name); else - printf("%-10d\n", ipcp->gid); + printf(" %-10d\n", ipcp->gid); } @@ -298,31 +298,34 @@ void do_shm (char format) case CREATOR: printf (_("------ Shared Memory Segment Creators/Owners --------\n")); - printf (_("%-10s%-10s%-10s%-10s%-10s%-10s\n"), + printf (_("%-10s %-10s %-10s %-10s %-10s %-10s\n"), _("shmid"),_("perms"),_("cuid"),_("cgid"),_("uid"),_("gid")); break; case TIME: printf (_("------ Shared Memory Attach/Detach/Change Times --------\n")); - printf (_("%-10s%-10s %-20s%-20s%-20s\n"), - _("shmid"),_("owner"),_("attached"),_("detached"),_("changed")); + printf (_("%-10s %-10s %-20s %-20s %-20s\n"), + _("shmid"),_("owner"),_("attached"),_("detached"), + _("changed")); break; case PID: printf (_("------ Shared Memory Creator/Last-op --------\n")); - printf (_("%-10s%-10s%-10s%-10s\n"),_("shmid"),_("owner"),_("cpid"),_("lpid")); + printf (_("%-10s %-10s %-10s %-10s\n"), + _("shmid"),_("owner"),_("cpid"),_("lpid")); break; default: printf (_("------ Shared Memory Segments --------\n")); - printf (_("%-10s%-10s%-10s%-10s%-10s%-10s%-12s\n"), _("key"),_("shmid"), - _("owner"),_("perms"),_("bytes"),_("nattch"),_("status")); + printf (_("%-10s %-10s %-10s %-10s %-10s %-10s %-12s\n"), + _("key"),_("shmid"),_("owner"),_("perms"),_("bytes"), + _("nattch"),_("status")); break; } for (id = 0; id <= maxid; id++) { shmid = shmctl (id, SHM_STAT, &shmseg); - if (shmid < 0) + if (shmid < 0) continue; if (format == CREATOR) { print_perms (shmid, ipcp); @@ -332,33 +335,33 @@ void do_shm (char format) switch (format) { case TIME: if (pw) - printf ("%-10d%-10.10s", shmid, pw->pw_name); + printf ("%-10d %-10.10s", shmid, pw->pw_name); else - printf ("%-10d%-10d", shmid, ipcp->uid); + printf ("%-10d %-10d", shmid, ipcp->uid); /* ctime uses static buffer: use separate calls */ printf(" %-20.16s", shmseg.shm_atime - ? ctime(&shmseg.shm_atime) + 4 : _("Not set\n")); - printf("%-20.16s", shmseg.shm_dtime - ? ctime(&shmseg.shm_dtime) + 4 : _("Not set\n")); - printf("%-20.16s\n", shmseg.shm_ctime - ? ctime(&shmseg.shm_ctime) + 4 : _("Not set\n")); + ? ctime(&shmseg.shm_atime) + 4 : _("Not set")); + printf(" %-20.16s", shmseg.shm_dtime + ? ctime(&shmseg.shm_dtime) + 4 : _("Not set")); + printf(" %-20.16s\n", shmseg.shm_ctime + ? ctime(&shmseg.shm_ctime) + 4 : _("Not set")); break; case PID: if (pw) - printf ("%-10d%-10.10s", shmid, pw->pw_name); + printf ("%-10d %-10.10s", shmid, pw->pw_name); else - printf ("%-10d%-10d", shmid, ipcp->uid); - printf ("%-10d%-10d\n", + printf ("%-10d %-10d", shmid, ipcp->uid); + printf (" %-10d %-10d\n", shmseg.shm_cpid, shmseg.shm_lpid); break; default: - printf( "0x%08x ",ipcp->KEY ); + printf("0x%08x ",ipcp->KEY ); if (pw) - printf ("%-10d%-10.10s", shmid, pw->pw_name); + printf ("%-10d %-10.10s", shmid, pw->pw_name); else - printf ("%-10d%-10d", shmid, ipcp->uid); - printf ("%-10o%-10d%-10ld%-6s%-6s\n", + printf ("%-10d %-10d", shmid, ipcp->uid); + printf ("%-10o %-10d %-10ld %-6s %-6s\n", ipcp->mode & 0777, shmseg.shm_segsz, /* @@ -412,13 +415,13 @@ void do_sem (char format) case CREATOR: printf (_("------ Semaphore Arrays Creators/Owners --------\n")); - printf (_("%-10s%-10s%-10s%-10s%-10s%-10s\n"), + printf (_("%-10s %-10s %-10s %-10s %-10s %-10s\n"), _("semid"),_("perms"),_("cuid"),_("cgid"),_("uid"),("gid")); break; case TIME: printf (_("------ Shared Memory Operation/Change Times --------\n")); - printf (_("%-8s%-10s %-26.24s %-26.24s\n"), + printf (_("%-8s %-10s %-26.24s %-26.24s\n"), _("shmid"),_("owner"),_("last-op"),_("last-changed")); break; @@ -427,15 +430,16 @@ void do_sem (char format) default: printf (_("------ Semaphore Arrays --------\n")); - printf (_("%-10s%-10s%-10s%-10s%-10s%-12s\n"), - _("key"),_("semid"),_("owner"),_("perms"),_("nsems"),_("status")); + printf (_("%-10s %-10s %-10s %-10s %-10s %-12s\n"), + _("key"),_("semid"),_("owner"),_("perms"), + _("nsems"),_("status")); break; } for (id = 0; id <= maxid; id++) { arg.buf = (struct semid_ds *) &semary; semid = semctl (id, 0, SEM_STAT, arg); - if (semid < 0) + if (semid < 0) continue; if (format == CREATOR) { print_perms (semid, ipcp); @@ -445,13 +449,13 @@ void do_sem (char format) switch (format) { case TIME: if (pw) - printf ("%-8d%-10.10s", semid, pw->pw_name); + printf ("%-8d %-10.10s", semid, pw->pw_name); else - printf ("%-8d%-10d", semid, ipcp->uid); + printf ("%-8d %-10d", semid, ipcp->uid); printf (" %-26.24s", semary.sem_otime - ? ctime(&semary.sem_otime) : _("Not set\n")); + ? ctime(&semary.sem_otime) : _("Not set")); printf (" %-26.24s\n", semary.sem_ctime - ? ctime(&semary.sem_ctime) : _("Not set\n")); + ? ctime(&semary.sem_ctime) : _("Not set")); break; case PID: break; @@ -459,10 +463,10 @@ void do_sem (char format) default: printf( "0x%08x ",ipcp->KEY ); if (pw) - printf ("%-10d%-10.9s", semid, pw->pw_name); + printf ("%-10d %-10.9s", semid, pw->pw_name); else - printf ("%-10d%-9d", semid, ipcp->uid); - printf ("%-10o%-10ld\n", + printf ("%-10d %-9d", semid, ipcp->uid); + printf ("%-10o %-10ld\n", ipcp->mode & 0777, /* * glibc-2.1.3 and earlier has unsigned short; @@ -488,7 +492,7 @@ void do_msg (char format) maxid = msgctl (0, MSG_INFO, (struct msqid_ds *) &msginfo); if (maxid < 0) { - printf (_("kernel not configured for shared memory\n")); + printf (_("kernel not configured for message queues\n")); return; } @@ -511,31 +515,33 @@ void do_msg (char format) case CREATOR: printf (_("------ Message Queues: Creators/Owners --------\n")); - printf (_("%-10s%-10s%-10s%-10s%-10s%-10s\n"), + printf (_("%-10s %-10s %-10s %-10s %-10s %-10s\n"), _("msqid"),_("perms"),_("cuid"),_("cgid"),_("uid"),_("gid")); break; case TIME: printf (_("------ Message Queues Send/Recv/Change Times --------\n")); - printf (_("%-8s%-10s %-20s%-20s%-20s\n"), + printf (_("%-8s %-10s %-20s %-20s %-20s\n"), _("msqid"),_("owner"),_("send"),_("recv"),_("change")); break; case PID: printf (_("------ Message Queues PIDs --------\n")); - printf (_("%-10s%-10s%-10s%-10s\n"),_("msqid"),_("owner"),_("lspid"),_("lrpid")); + printf (_("%-10s %-10s %-10s %-10s\n"), + _("msqid"),_("owner"),_("lspid"),_("lrpid")); break; default: printf (_("------ Message Queues --------\n")); - printf (_("%-10s%-10s%-10s%-10s%-12s%-12s\n"), _("key"),_("msqid"), - _("owner"), _("perms"), _("used-bytes"), _("messages")); + printf (_("%-10s %-10s %-10s %-10s %-12s %-12s\n"), + _("key"), _("msqid"), _("owner"), _("perms"), + _("used-bytes"), _("messages")); break; } for (id = 0; id <= maxid; id++) { msqid = msgctl (id, MSG_STAT, &msgque); - if (msqid < 0) + if (msqid < 0) continue; if (format == CREATOR) { print_perms (msqid, ipcp); @@ -543,34 +549,34 @@ void do_msg (char format) } pw = getpwuid(ipcp->uid); switch (format) { - case TIME: + case TIME: if (pw) - printf ("%-8d%-10.10s", msqid, pw->pw_name); + printf ("%-8d %-10.10s", msqid, pw->pw_name); else - printf ("%-8d%-10d", msqid, ipcp->uid); - printf (" %-20.16s", msgque.msg_stime - ? ctime(&msgque.msg_stime) + 4 : _("Not set\n")); - printf ("%-20.16s", msgque.msg_rtime - ? ctime(&msgque.msg_rtime) + 4 : _("Not set\n")); - printf ("%-20.16s\n", msgque.msg_ctime - ? ctime(&msgque.msg_ctime) + 4 : _("Not set\n")); + printf ("%-8d %-10d", msqid, ipcp->uid); + printf (" %-20.16s", msgque.msg_stime + ? ctime(&msgque.msg_stime) + 4 : _("Not set")); + printf (" %-20.16s", msgque.msg_rtime + ? ctime(&msgque.msg_rtime) + 4 : _("Not set")); + printf (" %-20.16s\n", msgque.msg_ctime + ? ctime(&msgque.msg_ctime) + 4 : _("Not set")); break; case PID: if (pw) - printf ("%-8d%-10.10s", msqid, pw->pw_name); + printf ("%-8d %-10.10s", msqid, pw->pw_name); else - printf ("%-8d%-10d", msqid, ipcp->uid); + printf ("%-8d %-10d", msqid, ipcp->uid); printf (" %5d %5d\n", - msgque.msg_lspid, msgque.msg_lrpid); + msgque.msg_lspid, msgque.msg_lrpid); break; default: printf( "0x%08x ",ipcp->KEY ); if (pw) - printf ("%-10d%-10.10s", msqid, pw->pw_name); + printf ("%-10d %-10.10s", msqid, pw->pw_name); else - printf ("%-10d%-10d", msqid, ipcp->uid); - printf ("%-10o%-12ld%-12ld\n", + printf ("%-10d %-10d", msqid, ipcp->uid); + printf (" %-10o %-12ld %-12ld\n", ipcp->mode & 0777, /* * glibc-2.1.3 and earlier has unsigned short; @@ -602,19 +608,18 @@ void print_shm (int shmid) ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid); printf (_("mode=%#o\taccess_perms=%#o\n"), ipcp->mode, ipcp->mode & 0777); - printf (_("bytes=%d\tlpid=%d\tcpid=%d\tnattch=%ld\n"), - shmds.shm_segsz, shmds.shm_lpid, shmds.shm_cpid, + printf (_("bytes=%d\tlpid=%d\tcpid=%d\tnattch=%ld\n"), + shmds.shm_segsz, shmds.shm_lpid, shmds.shm_cpid, (long) shmds.shm_nattch); - printf (_("att_time=%s"), shmds.shm_atime ? ctime (&shmds.shm_atime) : - _("Not set\n")); - printf (_("det_time=%s"), shmds.shm_dtime ? ctime (&shmds.shm_dtime) : - _("Not set\n")); - printf (_("change_time=%s"), ctime (&shmds.shm_ctime)); + printf (_("att_time=%-26.24s\n"), + shmds.shm_atime ? ctime (&shmds.shm_atime) : _("Not set")); + printf (_("det_time=%-26.24s\n"), + shmds.shm_dtime ? ctime (&shmds.shm_dtime) : _("Not set")); + printf (_("change_time=%-26.24s\n"), ctime (&shmds.shm_ctime)); printf ("\n"); return; } - void print_msg (int msqid) { @@ -637,12 +642,12 @@ void print_msg (int msqid) */ (long) buf.msg_cbytes, (long) buf.msg_qbytes, (long) buf.msg_qnum, buf.msg_lspid, buf.msg_lrpid); - printf (_("send_time=%s"), - buf.msg_stime? ctime (&buf.msg_stime) : _("Not set\n")); - printf (_("rcv_time=%s"), - buf.msg_rtime? ctime (&buf.msg_rtime) : _("Not set\n")); - printf (_("change_time=%s"), - buf.msg_ctime? ctime (&buf.msg_ctime) : _("Not set\n")); + printf (_("send_time=%-26.24s\n"), + buf.msg_stime ? ctime (&buf.msg_stime) : _("Not set")); + printf (_("rcv_time=%-26.24s\n"), + buf.msg_rtime ? ctime (&buf.msg_rtime) : _("Not set")); + printf (_("change_time=%-26.24s\n"), + buf.msg_ctime ? ctime (&buf.msg_ctime) : _("Not set")); printf ("\n"); return; } @@ -665,11 +670,11 @@ void print_sem (int semid) printf (_("mode=%#o, access_perms=%#o\n"), ipcp->mode, ipcp->mode & 0777); printf (_("nsems = %ld\n"), (long) semds.sem_nsems); - printf (_("otime = %s"), semds.sem_otime ? ctime (&semds.sem_otime) : - _("Not set\n")); - printf (_("ctime = %s"), ctime (&semds.sem_ctime)); + printf (_("otime = %-26.24s\n"), + semds.sem_otime ? ctime (&semds.sem_otime) : _("Not set")); + printf (_("ctime = %-26.24s\n"), ctime (&semds.sem_ctime)); - printf (_("%-10s%-10s%-10s%-10s%-10s\n"), + printf (_("%-10s %-10s %-10s %-10s %-10s\n"), _("semnum"),_("value"),_("ncount"),_("zcount"),_("pid")); arg.val = 0; for (i=0; i< semds.sem_nsems; i++) { @@ -682,9 +687,9 @@ void print_sem (int semid) perror ("semctl "); exit (1); } - printf ("%-10d%-10d%-10d%-10d%-10d\n", i, val, ncnt, zcnt, pid); + printf ("%-10d %-10d %-10d %-10d %-10d\n", + i, val, ncnt, zcnt, pid); } printf ("\n"); return; } - diff --git a/sys-utils/rdev.8 b/sys-utils/rdev.8 index 0cf83d365..98dce2b7f 100644 --- a/sys-utils/rdev.8 +++ b/sys-utils/rdev.8 @@ -3,31 +3,29 @@ .\" Changes from sct@dcs.ed.ac.uk added Sat Oct 9 09:54:00 1993. .TH RDEV 8 "20 November 1993" "Linux 0.99" "Linux Programmer's Manual" .SH NAME -rdev \- query/set image root device, swap device, RAM disk size, or video mode +rdev \- query/set image root device, RAM disk size, or video mode .SH SYNOPSIS .nf -.BR "rdev [ \-rsvh ] [ \-o " offset " ] [ " image " [ " value " [ " offset " ] ] ]" +.BR "rdev [ \-rvh ] [ \-o " offset " ] [ " image " [ " value " [ " offset " ] ] ]" .BR "rdev [ \-o " offset " ] [ " image " [ " root_device " [ " offset " ] ] ]" -.BR "swapdev [ \-o " offset " ] [ " image " [ " swap_device " [ " offset " ] ] ]" .BR "ramsize [ \-o " offset " ] [ " image " [ " size " [ " offset " ] ] ]" .BR "vidmode [ \-o " offset " ] [ " image " [ " mode " [ " offset " ] ] ]" .BR "rootflags [ \-o " offset " ] [ " image " [ " flags " [ " offset " ] ] ]" .fi .SH DESCRIPTION -.\" " for emacs hilit19 With no arguments, .B rdev outputs an .I /etc/mtab line for the current root file system. With no arguments, -.BR swapdev ", " ramsize ", " vidmode ", and " rootflags +.BR ramsize ", " vidmode ", and " rootflags print usage information. -In a bootable image for the Linux kernel, there are several pairs of bytes -which specify the root device, the video mode, the size of the RAM disk, -and the swap device. These pairs of bytes, by default, begin at offset 504 -(decimal) in the kernel image: +In a bootable image for the Linux kernel on i386, there are several pairs +of bytes which specify the root device, the video mode, and the size of +the RAM disk. These pairs of bytes, by default, begin +at offset 504 (decimal) in the kernel image: .nf .RS @@ -58,9 +56,9 @@ parameter, which is a bootable Linux kernel image, might be: .fi When using the -.BR rdev ", or " swapdev -commands, the -.IR root_device " or " swap_device +.B rdev +command, the +.I root_device parameter might be something like: .nf @@ -73,6 +71,10 @@ parameter might be something like: .RE .fi +One may also specify the device by a comma-separated pair +of decimal integers +.IR major , minor . + For the .B ramsize command, the @@ -114,12 +116,6 @@ is not specified, the will be examined to determine the current settings. .SH OPTIONS .TP -.B \-s -Causes -.B rdev -to act like -.BR swapdev . -.TP .B \-r Causes .B rdev @@ -141,23 +137,20 @@ to act like .B \-h Provides help. .SH BUGS -For historical reasons, there are two methods for specifying alternative -values for the offset. -.sp -The user interface is cumbersome, non-intuitive, and should probably be -re-written from scratch, allowing multiple kernel image parameters to be -changed or examined with a single command. -.sp -If LILO is used, -.B rdev -is no longer needed for setting the root device and the VGA mode, since -these parameters that -.B rdev -modifies can be set from the LILO prompt during a boot. However, +The .B rdev -is still needed at this time for setting the RAM disk size. Users are -encouraged to find the LILO documentation for more information, and to use -LILO when booting their systems. +utility, when used other than to find a name for the current root device, +is an ancient hack that works by patching a kernel image at a magic offset +with magic numbers. It does not work on architectures other than i386. +Its use is strongly discouraged. Use a boot loader like SysLinux or LILO +instead. +.SH HISTORY +At offset 502 there used to be the device number of the swap device +(in Linux 0.12), and "rdev -s" or "swapdev" would set this. +However, since Linux 0.95 this constant is not used any longer, +and the swap device is specified using the +.IR swapon () +system call. .SH AUTHORS .nf Originally by Werner Almesberger (almesber@nessie.cs.id.ethz.ch) diff --git a/sys-utils/rdev.c b/sys-utils/rdev.c index 54ccd99f4..e2b23aee0 100644 --- a/sys-utils/rdev.c +++ b/sys-utils/rdev.c @@ -58,6 +58,7 @@ Wed Jun 22 21:12:29 1994: Applied patches from Dave #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "nls.h" /* rdev.c - query/set root device. */ @@ -65,16 +66,14 @@ Wed Jun 22 21:12:29 1994: Applied patches from Dave static void usage(void) { - puts(_("usage: rdev [ -rsv ] [ -o OFFSET ] [ IMAGE [ VALUE [ OFFSET ] ] ]")); + puts(_("usage: rdev [ -rv ] [ -o OFFSET ] [ IMAGE [ VALUE [ OFFSET ] ] ]")); puts(_(" rdev /dev/fd0 (or rdev /linux, etc.) displays the current ROOT device")); puts(_(" rdev /dev/fd0 /dev/hda2 sets ROOT to /dev/hda2")); puts(_(" rdev -R /dev/fd0 1 set the ROOTFLAGS (readonly status)")); - puts(_(" rdev -s /dev/fd0 /dev/hda2 set the SWAP device")); puts(_(" rdev -r /dev/fd0 627 set the RAMDISK size")); puts(_(" rdev -v /dev/fd0 1 set the bootup VIDEOMODE")); puts(_(" rdev -o N ... use the byte offset N")); puts(_(" rootflags ... same as rdev -R")); - puts(_(" swapdev ... same as rdev -s")); puts(_(" ramsize ... same as rdev -r")); puts(_(" vidmode ... same as rdev -v")); puts(_("Note: video modes are: -3=Ask, -2=Extended, -1=NormalVga, 1=key1, 2=key2,...")); @@ -103,19 +102,16 @@ die(char *msg) { } /* Earlier rdev fails on /dev/ida/c0d0p1 so we allow for - (limited) recursion in /dev. -- Paul Clements */ - -#define MAX_DEPTH 1 + recursion in /dev. -- Paul Clements */ +/* In fact devfs needs deep recursion. */ static int -find_dev_recursive(char *dirnamebuf, int number, int depth) { +find_dev_recursive(char *dirnamebuf, int number) { DIR *dp; struct dirent *dir; struct stat s; int dirnamelen = 0; - if (depth < 0) - return 0; if ((dp = opendir(dirnamebuf)) == NULL) die("opendir"); dirnamelen = strlen(dirnamebuf); @@ -131,7 +127,7 @@ find_dev_recursive(char *dirnamebuf, int number, int depth) { if ((s.st_mode & S_IFMT) == S_IFBLK && s.st_rdev == number) return 1; if ((s.st_mode & S_IFMT) == S_IFDIR && - find_dev_recursive(dirnamebuf, number, depth-1)) + find_dev_recursive(dirnamebuf, number)) return 1; } dirnamebuf[dirnamelen] = 0; @@ -145,44 +141,45 @@ find_dev(int number) { if (!number) return "Boot device"; strcpy(name, "/dev"); - if (find_dev_recursive(name, number, MAX_DEPTH)) + if (find_dev_recursive(name, number)) return name; sprintf(name, "0x%04x", number); return name; } -/* enum { RDEV, SDEV, RAMSIZE, VIDMODE }; */ -enum { RDEV, VIDMODE, RAMSIZE, SDEV, __syssize__, ROOTFLAGS }; -char *cmdnames[6] = { "rdev", "vidmode", "ramsize", "swapdev", +/* The enum values are significant, things are stored in this order, + see bootsect.S */ +enum { RDEV, VIDMODE, RAMSIZE, __swapdev__, __syssize__, ROOTFLAGS }; +char *cmdnames[6] = { "rdev", "vidmode", "ramsize", "", "", "rootflags"}; -char *desc[6] = { "Root device", "Video mode", "Ramsize", "Swap device", +char *desc[6] = { "Root device", "Video mode", "Ramsize", "", "", "Root flags"}; #define shift(n) argv+=n,argc-=n int main(int argc, char **argv) { int image, offset, dev_nr, i, newoffset=-1; - char *device, *ptr; + char *ptr; + unsigned short val, have_val; struct stat s; - int cmd = 0; + int cmd; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - device = NULL; - /* use the command name to figure out what we have to do - ugly */ cmd = RDEV; if ((ptr = strrchr(argv[0],'/')) != NULL) ptr++; else ptr = argv[0]; - for (i=0; i<=5; i++) + for (i=0; i<=5; i++) { if (!strcmp(ptr,cmdnames[i])) { cmd = i; break; } + } while (argc > 1) { if (argv[1][0] != '-') @@ -200,17 +197,13 @@ main(int argc, char **argv) { cmd = VIDMODE; shift(1); break; - case 's': - cmd = SDEV; - shift(1); - break; case 'o': if (argv[1][2]) { - newoffset=atoi(argv[1]+2); + newoffset = atoi(argv[1]+2); shift(1); break; } else if (argc > 2) { - newoffset=atoi(argv[2]); + newoffset = atoi(argv[2]); shift(2); break; } @@ -220,44 +213,56 @@ main(int argc, char **argv) { } } - offset = DEFAULT_OFFSET-cmd*2; - if (newoffset >= 0) - offset = newoffset; + /* Here the only sensible way of using rdev */ + if (argc == 1) { + if (cmd == RDEV) { + if (stat("/",&s) < 0) die("/"); + printf("%s /\n", find_dev(s.st_dev)); + exit(0); + } + usage(); + } - if ((cmd == RDEV) && (argc == 1 || argc > 4)) { - if (stat("/",&s) < 0) die("/"); - printf("%s /\n", find_dev(s.st_dev)); - exit(0); - } else if ((cmd != RDEV) && (argc == 1 || argc > 4)) + if (argc > 4) usage(); - if ((cmd == RDEV) || (cmd == SDEV)) { - if (argc == 4) { - device = argv[2]; - offset = atoi(argv[3]); - } else { - if (argc == 3) { - if (isdigit(*argv[2])) - offset = atoi(argv[2]); - else - device = argv[2]; + /* Ancient garbage.. */ + offset = DEFAULT_OFFSET-cmd*2; + if (newoffset >= 0) + offset = newoffset; + if (argc == 4) + offset = atoi(argv[3]); + + have_val = 0; + + if (argc >= 3) { + if (cmd == RDEV) { + if (isdigit(*argv[2])) { + /* earlier: specify offset */ + /* now: specify major,minor */ + char *p; + unsigned int ma,mi; + if ((p = strchr(argv[2], ',')) == NULL) + die(_("missing comma")); + ma = atoi(argv[2]); + mi = atoi(p+1); + val = ((ma<<8) | mi); + } else { + char *device = argv[2]; + if (stat(device,&s) < 0) + die(device); + val = s.st_rdev; } + } else { + val = atoi(argv[2]); } - } else { - if (argc>=3) - device = argv[2]; - if (argc==4) - offset = atoi(argv[3]); + have_val = 1; } - if (device) { - if ((cmd == SDEV) || (cmd == RDEV)) { - if (stat(device,&s) < 0) - die(device); - } else - s.st_rdev=atoi(device); + + if (have_val) { if ((image = open(argv[1],O_WRONLY)) < 0) die(argv[1]); if (lseek(image,offset,0) < 0) die("lseek"); - if (write(image,(char *)&s.st_rdev,2) != 2) die(argv[1]); + if (write(image,(char *)&val,2) != 2) die(argv[1]); if (close(image) < 0) die("close"); } else { if ((image = open(argv[1],O_RDONLY)) < 0) die(argv[1]); @@ -266,7 +271,7 @@ main(int argc, char **argv) { if (read(image,(char *)&dev_nr,2) != 2) die(argv[1]); if (close(image) < 0) die("close"); fputs(desc[cmd], stdout); - if ((cmd == SDEV) || (cmd == RDEV)) + if (cmd == RDEV) printf(" %s\n", find_dev(dev_nr)); else printf(" %d\n", dev_nr); diff --git a/sys-utils/readprofile.c b/sys-utils/readprofile.c index 189322623..eee8634fe 100644 --- a/sys-utils/readprofile.c +++ b/sys-utils/readprofile.c @@ -218,6 +218,12 @@ main (int argc, char **argv) { if (*mode == 'A' && total == 0) continue; if (*mode!='T' && *mode!='t') break;/* only text is profiled */ + if (indx >= len / sizeof(*buf)) { + fprintf(stderr, _("%s: profile address out of range. " + "Wrong map file?\n"), prgname); + exit(1); + } + while (indx < (next_add-add0)/step) this += buf[indx++]; total += this; diff --git a/sys-utils/swapdev.8 b/sys-utils/swapdev.8 deleted file mode 100644 index 901bd7591..000000000 --- a/sys-utils/swapdev.8 +++ /dev/null @@ -1 +0,0 @@ -.so man8/rdev.8 |