summaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:43 +0100
committerKarel Zak2006-12-07 00:25:43 +0100
commit22853e4a82c6ef7b336527529acb94b14a0b0fd8 (patch)
treeee28e4598c8c449d7e811711d8ce8eb17caecfb6 /sys-utils
parentImported from util-linux-2.10f tarball. (diff)
downloadkernel-qcow2-util-linux-22853e4a82c6ef7b336527529acb94b14a0b0fd8.tar.gz
kernel-qcow2-util-linux-22853e4a82c6ef7b336527529acb94b14a0b0fd8.tar.xz
kernel-qcow2-util-linux-22853e4a82c6ef7b336527529acb94b14a0b0fd8.zip
Imported from util-linux-2.10m tarball.
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/Makefile13
-rw-r--r--sys-utils/cytune.c6
-rw-r--r--sys-utils/dmesg.c11
-rw-r--r--sys-utils/ipcrm.c113
-rw-r--r--sys-utils/ipcs.c21
-rw-r--r--sys-utils/rdev.c11
-rw-r--r--sys-utils/readprofile.c44
-rw-r--r--sys-utils/sln.c5
-rw-r--r--sys-utils/tunelp.c20
9 files changed, 160 insertions, 84 deletions
diff --git a/sys-utils/Makefile b/sys-utils/Makefile
index 85173658a..837ecd30e 100644
--- a/sys-utils/Makefile
+++ b/sys-utils/Makefile
@@ -27,6 +27,8 @@ SBIN= ctrlaltdel
NOTMADE=
+CWFLAGS := $(subst -Wmissing-prototypes,,$(CFLAGS))
+
ifeq "$(HAVE_SLN)" "no"
ifeq "$(CAN_DO_STATIC)" "no"
NOTMADE=nosln
@@ -46,6 +48,16 @@ USRINFO= ipc.info
all: $(SBIN) $(BIN) $(USRBIN) $(USRSBIN) $(NOTMADE)
+# Sometimes indirectly include <asm/bitops.h>
+cytune.o: cytune.c
+ $(CC) $(CWFLAGS) -c $< -o $@
+
+ipcs.o: ipcs.c
+ $(CC) $(CWFLAGS) -c $< -o $@
+
+ipcrm.o: ipcrm.c
+ $(CC) $(CWFLAGS) -c $< -o $@
+
sln: sln.c
$(CC) -static $(CFLAGS) $(LDFLAGS) $< -o $@
@@ -57,6 +69,7 @@ nosln:
arch: arch.o
ctrlaltdel.o: ctrlaltdel.c $(LIB)/linux_reboot.h
ctrlaltdel: ctrlaltdel.o $(LIB)/my_reboot.o
+cytune: cytune.o
ipcrm: ipcrm.o
ipcs: ipcs.o
rdev: rdev.o
diff --git a/sys-utils/cytune.c b/sys-utils/cytune.c
index a98b6a625..0bc0c5cb1 100644
--- a/sys-utils/cytune.c
+++ b/sys-utils/cytune.c
@@ -89,7 +89,8 @@ int cmon_index;
#define mvtime(tvpto, tvpfrom) (((tvpto)->tv_sec = (tvpfrom)->tv_sec),(tvpto)->tv_usec = (tvpfrom)->tv_usec)
-inline double dtime(struct timeval * tvpnew, struct timeval * tvpold) {
+static inline double
+dtime(struct timeval * tvpnew, struct timeval * tvpold) {
double diff;
diff = (double)tvpnew->tv_sec - (double)tvpold->tv_sec;
diff += ((double)tvpnew->tv_usec - (double)tvpold->tv_usec)/1000000;
@@ -99,7 +100,8 @@ inline double dtime(struct timeval * tvpnew, struct timeval * tvpold) {
static int global_argc, global_optind;
static char ***global_argv;
-void summary(int signal) {
+static void
+summary(int signal) {
struct cyclades_control *cc;
int argc, optind;
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index a1026af63..5cf1817aa 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -32,16 +32,15 @@
static char *progname;
-void
-usage()
-{
+static void
+usage(void) {
fprintf( stderr, _("Usage: %s [-c] [-n level] [-s bufsize]\n"), progname );
}
-int main( int argc, char *argv[] )
-{
+int
+main( int argc, char *argv[] ) {
char *buf;
- int bufsize=8196;
+ int bufsize=16392;
int i;
int n;
int c;
diff --git a/sys-utils/ipcrm.c b/sys-utils/ipcrm.c
index 4dcd081b4..2fc6ec47f 100644
--- a/sys-utils/ipcrm.c
+++ b/sys-utils/ipcrm.c
@@ -4,6 +4,9 @@
* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@misiek.eu.org>
* - added Native Language Support
*
+ * 1999-04-02 frank zago
+ * - can now remove several id's in the same call
+ *
*/
#include <stdio.h>
@@ -30,47 +33,99 @@ union semun {
};
#endif
+char *execname;
-int main(int argc, char **argv)
-{
+typedef enum type_id {
+ SHM,
+ SEM,
+ MSG
+} type_id;
+
+static int
+remove_ids(type_id type, int argc, char **argv) {
int id;
+ int ret = 0; /* for gcc */
+ char *end;
+ int nb_errors = 0;
union semun arg;
arg.val = 0;
+
+ while(argc) {
+
+ id = strtoul(argv[0], &end, 10);
+
+ if (*end != 0) {
+ printf (_("invalid id: %s\n"), argv[0]);
+ nb_errors ++;
+ } else {
+ switch(type) {
+ case SEM:
+ ret = semctl (id, 0, IPC_RMID, arg);
+ break;
+
+ case MSG:
+ ret = msgctl (id, IPC_RMID, NULL);
+ break;
+
+ case SHM:
+ ret = shmctl (id, IPC_RMID, NULL);
+ break;
+ }
+
+ if (ret) {
+ printf (_("cannot remove id %s (%s)\n"),
+ argv[0], strerror(errno));
+ nb_errors ++;
+ }
+ }
+ argc--;
+ argv++;
+ }
+ return(nb_errors);
+}
+
+static void display_usage(void)
+{
+ printf (_("usage: %s {shm | msg | sem} id ...\n"), execname);
+}
+
+int main(int argc, char **argv)
+{
+ execname = argv[0];
+
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- if (argc != 3 || strlen(argv[1]) < 3) {
- printf (_("usage: %s [shm | msg | sem] id\n"), argv[0]);
- exit (1);
+ if (argc < 3) {
+ display_usage();
+ exit(1);
+ }
+
+ if (!strcmp(argv[1], "shm")) {
+ if (remove_ids(SHM, argc-2, &argv[2])) {
+ exit(1);
+ }
}
- id = atoi (argv[2]);
- switch (argv[1][1]) {
- case 'h':
- if (!shmctl (id, IPC_RMID, NULL))
- break;
- perror ("shmctl ");
- exit (1);
-
- case 'e':
- if (!semctl (id, 0, IPC_RMID, arg))
- break;
- perror ("semctl ");
- exit (1);
-
- case 's':
- if (!msgctl (id, IPC_RMID, NULL))
- break;
- perror ("msgctl ");
- exit (1);
-
- default:
- printf (_("usage: %s [-shm | -msg | -sem] id\n"), argv[0]);
- exit (1);
+ else if (!strcmp(argv[1], "msg")) {
+ if (remove_ids(MSG, argc-2, &argv[2])) {
+ exit(1);
+ }
+ }
+ else if (!strcmp(argv[1], "sem")) {
+ if (remove_ids(SEM, argc-2, &argv[2])) {
+ exit(1);
+ }
}
- printf (_("resource deleted\n"));
+ else {
+ display_usage();
+ printf (_("unknown resource type: %s\n"), argv[1]);
+ exit(1);
+ }
+
+ printf (_("resource(s) deleted\n"));
return 0;
}
diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c
index 09dec45a0..3990ad3fa 100644
--- a/sys-utils/ipcs.c
+++ b/sys-utils/ipcs.c
@@ -69,6 +69,11 @@ struct shm_info {
#define SEM_STAT 18
#define SEM_INFO 19
#endif
+
+/* Some versions of libc only define IPC_INFO when __USE_GNU is defined. */
+#ifndef IPC_INFO
+#define IPC_INFO 3
+#endif
/*-------------------------------------------------------------------*/
/* The last arg of semctl is a union semun, but where is it defined?
@@ -112,16 +117,16 @@ void print_sem (int id);
static char *progname;
-void usage(void)
-{
+static void
+usage(void) {
printf (_("usage : %s -asmq -tclup \n"), progname);
printf (_("\t%s [-s -m -q] -i id\n"), progname);
printf (_("\t%s -h for help.\n"), progname);
return;
}
-void help (void)
-{
+static void
+help (void) {
printf (_("%s provides information on ipc facilities for"), progname);
printf (_(" which you have read access.\n"));
printf (_("Resource Specification:\n\t-m : shared_mem\n\t-q : messages\n"));
@@ -133,8 +138,8 @@ void help (void)
return;
}
-int main (int argc, char **argv)
-{
+int
+main (int argc, char **argv) {
int opt, msg = 0, sem = 0, shm = 0, id=0, print=0;
char format = 0;
char options[] = "atcluphsmqi:";
@@ -222,8 +227,8 @@ int main (int argc, char **argv)
}
-void print_perms (int id, struct ipc_perm *ipcp)
-{
+static void
+print_perms (int id, struct ipc_perm *ipcp) {
struct passwd *pw;
struct group *gr;
diff --git a/sys-utils/rdev.c b/sys-utils/rdev.c
index 434784b8b..768d17c86 100644
--- a/sys-utils/rdev.c
+++ b/sys-utils/rdev.c
@@ -61,9 +61,8 @@ Wed Jun 22 21:12:29 1994: Applied patches from Dave
/* rdev.c - query/set root device. */
-void
-usage()
-{
+static void
+usage(void) {
puts(_("usage: rdev [ -rsv ] [ -o OFFSET ] [ IMAGE [ VALUE [ OFFSET ] ] ]"));
puts(_(" rdev /dev/fd0 (or rdev /linux, etc.) displays the current ROOT device"));
@@ -115,8 +114,10 @@ static char *find_dev(int number)
strcpy(name,"/dev/");
while ((dir = readdir(dp)) != NULL) {
strcpy(name+5,dir->d_name);
- if (stat(name,&s) < 0) die(name);
- if ((s.st_mode & S_IFMT) == S_IFBLK && s.st_rdev == number) return 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;
diff --git a/sys-utils/readprofile.c b/sys-utils/readprofile.c
index 6a8d4d20f..551b2cbf4 100644
--- a/sys-utils/readprofile.c
+++ b/sys-utils/readprofile.c
@@ -46,8 +46,8 @@ static char defaultmap[]="/usr/src/linux/System.map";
static char defaultpro[]="/proc/profile";
static char optstring[]="m:p:itvarV";
-void usage()
-{
+static void
+usage(void) {
fprintf(stderr,
_("%s: Usage: \"%s [options]\n"
"\t -m <mapfile> (default = \"%s\")\n"
@@ -61,9 +61,9 @@ void usage()
exit(1);
}
-FILE *myopen(char *name, char *mode, int *flag)
-{
-static char cmdline[S_LEN];
+static FILE *
+myopen(char *name, char *mode, int *flag) {
+ static char cmdline[S_LEN];
if (!strcmp(name+strlen(name)-3,".gz"))
{
@@ -75,23 +75,23 @@ static char cmdline[S_LEN];
return fopen(name,mode);
}
-int main (int argc, char **argv)
-{
-FILE *pro;
-FILE *map;
-int proFd;
-char *mapFile, *proFile;
-unsigned long len=0, add0=0, index=0;
-unsigned int step;
-unsigned int *buf, total, fn_len;
-unsigned long fn_add, next_add; /* current and next address */
-char fn_name[S_LEN], next_name[S_LEN]; /* current and next name */
-char mode[8];
-int c;
-int optAll=0, optInfo=0, optReset=0, optVerbose=0;
-char mapline[S_LEN];
-int maplineno=1;
-int popenMap; /* flag to tell if popen() has been used */
+int
+main (int argc, char **argv) {
+ FILE *pro;
+ FILE *map;
+ int proFd;
+ char *mapFile, *proFile;
+ unsigned long len=0, add0=0, index=0;
+ unsigned int step;
+ unsigned int *buf, total, fn_len;
+ unsigned long fn_add, next_add; /* current and next address */
+ char fn_name[S_LEN], next_name[S_LEN]; /* current and next name */
+ char mode[8];
+ int c;
+ int optAll=0, optInfo=0, optReset=0, optVerbose=0;
+ char mapline[S_LEN];
+ int maplineno=1;
+ int popenMap; /* flag to tell if popen() has been used */
#define next (current^1)
diff --git a/sys-utils/sln.c b/sys-utils/sln.c
index 257b4342e..8c70114a4 100644
--- a/sys-utils/sln.c
+++ b/sys-utils/sln.c
@@ -27,10 +27,7 @@
#endif
int
-main (argc, argv)
- int argc;
- char **argv;
-{
+main (int argc, char **argv) {
struct stat stats;
if (argc != 3) return 1;
diff --git a/sys-utils/tunelp.c b/sys-utils/tunelp.c
index 7292a0cad..b04d868b4 100644
--- a/sys-utils/tunelp.c
+++ b/sys-utils/tunelp.c
@@ -69,7 +69,8 @@ struct command {
};
-void print_usage(char *progname) {
+static void
+print_usage(char *progname) {
printf(_("Usage: %s <device> [ -i <IRQ> | -t <TIME> | -c <CHARS> | -w <WAIT> | \n"
" -a [on|off] | -o [on|off] | -C [on|off] | -q [on|off] | -s | \n"
" -T [on|off] ]\n"),
@@ -77,13 +78,13 @@ void print_usage(char *progname) {
exit (1);
}
-
-void print_version(char *progname) {
+static void
+print_version(char *progname) {
printf("%s %s\n", progname, UTIL_LINUX_VERSION);
}
-
-void *mylloc(long size) {
+static void *
+mylloc(long size) {
void *ptr;
if(!(ptr = (void*)malloc(size))) {
perror(_("malloc error"));
@@ -94,7 +95,8 @@ void *mylloc(long size) {
static char *progname;
-long get_val(char *val) {
+static long
+get_val(char *val) {
long ret;
if (!(sscanf(val, "%ld", &ret) == 1)) {
fprintf(stderr, _("%s: bad value\n"), progname);
@@ -104,13 +106,15 @@ long get_val(char *val) {
}
-long get_onoff(char *val) {
+static long
+get_onoff(char *val) {
if (!strncasecmp("on", val, 2))
return 1;
return 0;
}
-int main (int argc, char ** argv) {
+int
+main (int argc, char ** argv) {
int c, fd, irq, status, show_irq, offset = 0, retval;
char *filename, *p;
struct stat statbuf;