summaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:44 +0100
committerKarel Zak2006-12-07 00:25:44 +0100
commit66ee8158b69525e12060ef558cb5d77feadab1dc (patch)
tree08b30f2d07df9213f5647bc6f60b5090a263ef43 /sys-utils
parentImported from util-linux-2.10m tarball. (diff)
downloadkernel-qcow2-util-linux-66ee8158b69525e12060ef558cb5d77feadab1dc.tar.gz
kernel-qcow2-util-linux-66ee8158b69525e12060ef558cb5d77feadab1dc.tar.xz
kernel-qcow2-util-linux-66ee8158b69525e12060ef558cb5d77feadab1dc.zip
Imported from util-linux-2.10s tarball.
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/Makefile4
-rw-r--r--sys-utils/ctrlaltdel.c1
-rw-r--r--sys-utils/cytune.c18
-rw-r--r--sys-utils/ipcs.c76
-rw-r--r--sys-utils/rdev.816
-rw-r--r--sys-utils/rdev.c266
-rw-r--r--sys-utils/readprofile.c6
-rw-r--r--sys-utils/renice.c1
-rw-r--r--sys-utils/tunelp.c1
9 files changed, 221 insertions, 168 deletions
diff --git a/sys-utils/Makefile b/sys-utils/Makefile
index 837ecd30e..66f913a62 100644
--- a/sys-utils/Makefile
+++ b/sys-utils/Makefile
@@ -37,7 +37,7 @@ SBIN:=$(SBIN) sln
endif
endif
-ifeq "$(CPU)" "intel"
+ifeq "$(ARCH)" "intel"
MAN8:=$(MAN8) rdev.8 ramsize.8 rootflags.8 swapdev.8 vidmode.8
USRSBIN:=$(USRSBIN) rdev
endif
@@ -83,7 +83,7 @@ install: all
$(INSTALLBIN) $(BIN) $(BINDIR)
$(INSTALLBIN) $(USRBIN) $(USRBINDIR)
$(INSTALLBIN) $(USRSBIN) $(USRSBINDIR)
-ifeq "$(CPU)" "intel"
+ifeq "$(ARCH)" "intel"
(cd $(USRSBINDIR); ln -sf rdev swapdev)
(cd $(USRSBINDIR); ln -sf rdev ramsize)
(cd $(USRSBINDIR); ln -sf rdev vidmode)
diff --git a/sys-utils/ctrlaltdel.c b/sys-utils/ctrlaltdel.c
index 5a0ac9ffb..91b67bc8b 100644
--- a/sys-utils/ctrlaltdel.c
+++ b/sys-utils/ctrlaltdel.c
@@ -9,6 +9,7 @@
#include <stdio.h>
#include <unistd.h>
+#include <stdlib.h>
#include <string.h>
#include "linux_reboot.h"
#include "nls.h"
diff --git a/sys-utils/cytune.c b/sys-utils/cytune.c
index 0bc0c5cb1..63ca0e4e2 100644
--- a/sys-utils/cytune.c
+++ b/sys-utils/cytune.c
@@ -101,21 +101,21 @@ static int global_argc, global_optind;
static char ***global_argv;
static void
-summary(int signal) {
+summary(int sig) {
struct cyclades_control *cc;
- int argc, optind;
+ int argc, local_optind;
char **argv;
int i,j;
argc = global_argc;
argv = *global_argv;
- optind = global_optind;
+ local_optind = global_optind;
- if (signal > 0) {
- for(i = optind; i < argc; i ++) {
- j = i - optind;
+ if (sig > 0) {
+ for(i = local_optind; i < argc; i ++) {
+ j = i - local_optind;
cc = &cmon[cmon_index];
fprintf(stderr, _("File %s, For threshold value %lu, Maximum characters in fifo were %d,\nand the maximum transfer rate in characters/second was %f\n"),
argv[i],
@@ -127,9 +127,9 @@ summary(int signal) {
exit(0);
}
cc = &cmon[cmon_index];
- if (cc->threshold_value > 0 && signal != -1) {
+ if (cc->threshold_value > 0 && sig != -1) {
fprintf(stderr, _("File %s, For threshold value %lu and timrout value %lu, Maximum characters in fifo were %d,\nand the maximum transfer rate in characters/second was %f\n"),
- argv[cmon_index+optind],
+ argv[cmon_index+local_optind],
cc->threshold_value,
cc->timeout_value,
cc->maxmax,
@@ -170,8 +170,6 @@ int main(int argc, char *argv[]) {
struct cyclades_monitor cywork;
int i;
- extern char *optarg;
- extern int optind;
unsigned long threshold_value;
unsigned long timeout_value;
double xfer_rate;
diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c
index 3990ad3fa..d74fa359e 100644
--- a/sys-utils/ipcs.c
+++ b/sys-utils/ipcs.c
@@ -274,10 +274,16 @@ void do_shm (char format)
printf (_("------ Shared Memory Limits --------\n"));
if ((shmctl (0, IPC_INFO, (struct shmid_ds *) &shminfo)) < 0 )
return;
- printf (_("max number of segments = %d\n"), shminfo.shmmni);
- printf (_("max seg size (kbytes) = %d\n"), shminfo.shmmax >> 10);
- printf (_("max total shared memory (kbytes) = %d\n"), shminfo.shmall << 2);
- printf (_("min seg size (bytes) = %d\n"), shminfo.shmmin);
+ /* glibc 2.1.3 and all earlier libc's have ints as fields
+ of struct shminfo; glibc 2.1.91 has unsigned long; ach */
+ printf (_("max number of segments = %ld\n"),
+ (long) shminfo.shmmni);
+ printf (_("max seg size (kbytes) = %ld\n"),
+ (long) (shminfo.shmmax >> 10));
+ printf (_("max total shared memory (kbytes) = %ld\n"),
+ (long) shminfo.shmall << 2);
+ printf (_("min seg size (bytes) = %ld\n"),
+ (long) shminfo.shmmin);
return;
case STATUS:
@@ -349,9 +355,14 @@ void do_shm (char format)
printf ("%-10d%-10.10s", shmid, pw->pw_name);
else
printf ("%-10d%-10d", shmid, ipcp->uid);
- printf ("%-10o%-10d%-10d%-6s%-6s\n",
- ipcp->mode & 0777,
- shmseg.shm_segsz, shmseg.shm_nattch,
+ printf ("%-10o%-10d%-10ld%-6s%-6s\n",
+ ipcp->mode & 0777,
+ shmseg.shm_segsz,
+ /*
+ * glibc-2.1.3 and earlier has unsigned short;
+ * Austin has shmatt_t
+ */
+ (long) shmseg.shm_nattch,
ipcp->mode & SHM_DEST ? _("dest") : " ",
ipcp->mode & SHM_LOCKED ? _("locked") : " ");
break;
@@ -447,9 +458,15 @@ void do_sem (char format)
printf ("%-10d%-10.9s", semid, pw->pw_name);
else
printf ("%-10d%-9d", semid, ipcp->uid);
- printf ("%-10o%-10d\n",
+ printf ("%-10o%-10ld\n",
ipcp->mode & 0777,
- semary.sem_nsems);
+ /*
+ * glibc-2.1.3 and earlier has unsigned short;
+ * glibc-2.1.91 has variation between
+ * unsigned short and unsigned long
+ * Austin prescribes unsigned short.
+ */
+ (long) semary.sem_nsems);
break;
}
}
@@ -547,9 +564,16 @@ void do_msg (char format)
printf ("%-10d%-10.10s", msqid, pw->pw_name);
else
printf ("%-10d%-10d", msqid, ipcp->uid);
- printf ("%-10o%-12d%-12d\n",
- ipcp->mode & 0777, msgque.msg_cbytes,
- msgque.msg_qnum);
+ printf ("%-10o%-12ld%-12ld\n",
+ ipcp->mode & 0777,
+ /*
+ * glibc-2.1.3 and earlier has unsigned short;
+ * glibc-2.1.91 has variation between
+ * unsigned short, unsigned long
+ * Austin has msgqnum_t
+ */
+ (long) msgque.msg_cbytes,
+ (long) msgque.msg_qnum);
break;
}
}
@@ -570,10 +594,11 @@ void print_shm (int shmid)
printf (_("\nShared memory Segment shmid=%d\n"), shmid);
printf (_("uid=%d\tgid=%d\tcuid=%d\tcgid=%d\n"),
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=%d\n"),
+ 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,
- shmds.shm_nattch);
+ (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) :
@@ -597,9 +622,15 @@ void print_msg (int msqid)
printf (_("\nMessage Queue msqid=%d\n"), msqid);
printf (_("uid=%d\tgid=%d\tcuid=%d\tcgid=%d\tmode=%#o\n"),
ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid, ipcp->mode);
- printf (_("cbytes=%d\tqbytes=%d\tqnum=%d\tlspid=%d\tlrpid=%d\n"),
- buf.msg_cbytes, buf.msg_qbytes, buf.msg_qnum, buf.msg_lspid,
- buf.msg_lrpid);
+ printf (_("cbytes=%ld\tqbytes=%ld\tqnum=%ld\tlspid=%d\tlrpid=%d\n"),
+ /*
+ * glibc-2.1.3 and earlier has unsigned short;
+ * glibc-2.1.91 has variation between
+ * unsigned short, unsigned long
+ * Austin has msgqnum_t (for msg_qbytes)
+ */
+ (long) buf.msg_cbytes, (long) buf.msg_qbytes,
+ (long) buf.msg_qnum, buf.msg_lspid, buf.msg_lrpid);
printf (_("send_time=%srcv_time=%schange_time=%s"),
buf.msg_rtime? ctime (&buf.msg_rtime) : _("Not Set\n"),
buf.msg_stime? ctime (&buf.msg_stime) : _("Not Set\n"),
@@ -623,14 +654,15 @@ void print_sem (int semid)
printf (_("\nSemaphore Array semid=%d\n"), semid);
printf (_("uid=%d\t gid=%d\t cuid=%d\t cgid=%d\n"),
ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid);
- printf (_("mode=%#o, access_perms=%#o\n"), ipcp->mode, ipcp->mode & 0777);
- printf (_("nsems = %d\n"), semds.sem_nsems);
+ 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 (_("%-10s%-10s%-10s%-10s%-10s\n"), _("semnum"),_("value"),_("ncount"),
- _("zcount"),_("pid"));
+ printf (_("%-10s%-10s%-10s%-10s%-10s\n"),
+ _("semnum"),_("value"),_("ncount"),_("zcount"),_("pid"));
arg.val = 0;
for (i=0; i< semds.sem_nsems; i++) {
int val, ncnt, zcnt, pid;
diff --git a/sys-utils/rdev.8 b/sys-utils/rdev.8
index 78a62355f..0cf83d365 100644
--- a/sys-utils/rdev.8
+++ b/sys-utils/rdev.8
@@ -45,14 +45,13 @@ will change these values.
Typical values for the
.I image
-parameter, which is a bootable Linux kernel image, are as follows:
+parameter, which is a bootable Linux kernel image, might be:
.nf
.RS
/vmlinux
-/vmlinux.test
/vmunix
-/vmunix.test
+/boot/bzImage-2.4.0
/dev/fd0
/dev/fd1
.RE
@@ -62,14 +61,15 @@ When using the
.BR rdev ", or " swapdev
commands, the
.IR root_device " or " swap_device
-parameter are as follows:
+parameter might be something like:
.nf
.RS
-/dev/hda[1-8]
-/dev/hdb[1-8]
-/dev/sda[1-8]
-/dev/sdb[1-8]
+/dev/hda1
+/dev/hdf13
+/dev/sda2
+/dev/sdc4
+/dev/ida/c0d0p1
.RE
.fi
diff --git a/sys-utils/rdev.c b/sys-utils/rdev.c
index 768d17c86..d49da823c 100644
--- a/sys-utils/rdev.c
+++ b/sys-utils/rdev.c
@@ -57,6 +57,7 @@ Wed Jun 22 21:12:29 1994: Applied patches from Dave
*/
#include <stdio.h>
+#include <stdlib.h>
#include "nls.h"
/* rdev.c - query/set root device. */
@@ -95,32 +96,59 @@ usage(void) {
#define DEFAULT_OFFSET 508
-static void die(char *msg)
-{
- perror(msg);
- exit(1);
+static void
+die(char *msg) {
+ perror(msg);
+ exit(1);
}
+/* Earlier rdev fails on /dev/ida/c0d0p1 so we allow for
+ (limited) recursion in /dev. -- Paul Clements */
+
+#define MAX_DEPTH 1
+
+static int
+find_dev_recursive(char *dirnamebuf, int number, int depth) {
+ 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);
+ while ((dir = readdir(dp)) != NULL) {
+ if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
+ continue;
+ if (dirnamelen + 1 + strlen(dir->d_name) > PATH_MAX)
+ continue;
+ dirnamebuf[dirnamelen] = '/';
+ strcpy(dirnamebuf+dirnamelen+1, dir->d_name);
+ if (lstat(dirnamebuf, &s) < 0)
+ continue;
+ 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))
+ return 1;
+ }
+ dirnamebuf[dirnamelen] = 0;
+ return 0;
+}
-static char *find_dev(int number)
-{
- DIR *dp;
- struct dirent *dir;
- static char name[PATH_MAX+1];
- struct stat s;
-
- if (!number) return "Boot device";
- if ((dp = opendir("/dev")) == NULL) die("opendir /dev");
- strcpy(name,"/dev/");
- while ((dir = readdir(dp)) != NULL) {
- strcpy(name+5,dir->d_name);
- if (stat(name,&s) < 0)
- continue;
- if ((s.st_mode & S_IFMT) == S_IFBLK && s.st_rdev == number)
- return name;
- }
- sprintf(name,"0x%04x",number);
- return name;
+static char *
+find_dev(int number) {
+ static char name[PATH_MAX+1];
+
+ if (!number)
+ return "Boot device";
+ strcpy(name, "/dev");
+ if (find_dev_recursive(name, number, MAX_DEPTH))
+ return name;
+ sprintf(name, "0x%04x", number);
+ return name;
}
/* enum { RDEV, SDEV, RAMSIZE, VIDMODE }; */
@@ -131,60 +159,53 @@ char *desc[6] = { "Root device", "Video mode", "Ramsize", "Swap device",
"", "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;
- struct stat s;
- int cmd = 0;
-
- setlocale(LC_ALL, "");
- bindtextdomain(PACKAGE, LOCALEDIR);
- textdomain(PACKAGE);
-
- device = NULL;
- if ((ptr = strrchr(argv[0],'/')) != NULL)
- ptr++;
- else
- ptr = argv[0];
- for (i=0; i<=5; i++)
- if (!strcmp(ptr,cmdnames[i]))
- break;
- cmd = i;
- if (cmd>5)
- cmd=RDEV;
- offset = DEFAULT_OFFSET-cmd*2;
-
- while (argc > 1)
- {
- if (argv[1][0] != '-')
- break;
+int
+main(int argc, char **argv) {
+ int image, offset, dev_nr, i, newoffset=-1;
+ char *device, *ptr;
+ struct stat s;
+ int cmd = 0;
+
+ 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
- switch (argv[1][1])
- {
+ ptr = argv[0];
+ for (i=0; i<=5; i++)
+ if (!strcmp(ptr,cmdnames[i])) {
+ cmd = i;
+ break;
+ }
+
+ while (argc > 1) {
+ if (argv[1][0] != '-')
+ break;
+ switch (argv[1][1]) {
case 'R':
- cmd=ROOTFLAGS;
- offset = DEFAULT_OFFSET-cmd*2;
- shift(1);
+ cmd = ROOTFLAGS;
+ shift(1);
break;
- case 'r':
- cmd=RAMSIZE;
- offset = DEFAULT_OFFSET-cmd*2;
- shift(1);
+ case 'r':
+ cmd = RAMSIZE;
+ shift(1);
break;
case 'v':
- cmd=VIDMODE;
- offset = DEFAULT_OFFSET-cmd*2;
- shift(1);
+ cmd = VIDMODE;
+ shift(1);
break;
case 's':
- cmd=SDEV;
- offset = DEFAULT_OFFSET-cmd*2;
- shift(1);
+ cmd = SDEV;
+ shift(1);
break;
case 'o':
- if (argv[1][2])
- {
+ if (argv[1][2]) {
newoffset=atoi(argv[1]+2);
shift(1);
break;
@@ -196,60 +217,59 @@ int main(int argc,char **argv)
/* Fall through. . . */
default:
usage();
- }
- }
- if (newoffset >= 0)
- offset = newoffset;
-
- 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)) 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];
}
- }
- }
- else
- {
- if (argc>=3)
- device = argv[2];
- if (argc==4)
- offset = atoi(argv[3]);
- }
- if (device) {
- if ((cmd==SDEV) || (cmd==RDEV))
- { if (stat(device,&s) < 0) die(device);
- } else
- s.st_rdev=atoi(device);
- 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 (close(image) < 0) die("close");
- }
- else {
- if ((image = open(argv[1],O_RDONLY)) < 0) die(argv[1]);
- if (lseek(image,offset,0) < 0) die("lseek");
- dev_nr = 0;
- if (read(image,(char *)&dev_nr,2) != 2) die(argv[1]);
- if (close(image) < 0) die("close");
- printf(desc[cmd]);
- if ((cmd==SDEV) || (cmd==RDEV))
- printf(" %s\n", find_dev(dev_nr));
- else
- printf(" %d\n", dev_nr);
- }
- return 0;
+ }
+
+ offset = DEFAULT_OFFSET-cmd*2;
+ if (newoffset >= 0)
+ offset = newoffset;
+
+ 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))
+ 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];
+ }
+ }
+ } else {
+ if (argc>=3)
+ device = argv[2];
+ if (argc==4)
+ offset = atoi(argv[3]);
+ }
+ if (device) {
+ if ((cmd == SDEV) || (cmd == RDEV)) {
+ if (stat(device,&s) < 0)
+ die(device);
+ } else
+ s.st_rdev=atoi(device);
+ 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 (close(image) < 0) die("close");
+ } else {
+ if ((image = open(argv[1],O_RDONLY)) < 0) die(argv[1]);
+ if (lseek(image,offset,0) < 0) die("lseek");
+ dev_nr = 0;
+ 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))
+ printf(" %s\n", find_dev(dev_nr));
+ else
+ printf(" %d\n", dev_nr);
+ }
+ return 0;
}
-
-
diff --git a/sys-utils/readprofile.c b/sys-utils/readprofile.c
index 551b2cbf4..b531fa90a 100644
--- a/sys-utils/readprofile.c
+++ b/sys-utils/readprofile.c
@@ -81,7 +81,7 @@ main (int argc, char **argv) {
FILE *map;
int proFd;
char *mapFile, *proFile;
- unsigned long len=0, add0=0, index=0;
+ unsigned long len=0, add0=0, indx=0;
unsigned int step;
unsigned int *buf, total, fn_len;
unsigned long fn_add, next_add; /* current and next address */
@@ -201,8 +201,8 @@ main (int argc, char **argv) {
if (*mode == 'A' && total == 0) continue;
if (*mode!='T' && *mode!='t') break; /* only text is profiled */
- while (index < (next_add-add0)/step)
- this += buf[index++];
+ while (indx < (next_add-add0)/step)
+ this += buf[indx++];
total += this;
fn_len = next_add-fn_add;
diff --git a/sys-utils/renice.c b/sys-utils/renice.c
index 6bc83f992..cd1fa87a0 100644
--- a/sys-utils/renice.c
+++ b/sys-utils/renice.c
@@ -42,6 +42,7 @@
#include <stdio.h>
#include <pwd.h>
#include <stdlib.h>
+#include <string.h>
#include <errno.h>
#include "nls.h"
diff --git a/sys-utils/tunelp.c b/sys-utils/tunelp.c
index b04d868b4..4453de748 100644
--- a/sys-utils/tunelp.c
+++ b/sys-utils/tunelp.c
@@ -57,6 +57,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <malloc.h>
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "lp.h"