From 30ebb153fb129bae14c4d2d95e42db9b1a45416d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 19 Nov 2018 16:42:06 -0600 Subject: A few more GLOBALS() single character argument style conversions. --- toys/other/blockdev.c | 7 +++---- toys/other/lspci.c | 14 +++++++------- toys/other/nsenter.c | 14 ++++++++------ 3 files changed, 18 insertions(+), 17 deletions(-) (limited to 'toys/other') diff --git a/toys/other/blockdev.c b/toys/other/blockdev.c index 75f71ad3..a9bc3e78 100644 --- a/toys/other/blockdev.c +++ b/toys/other/blockdev.c @@ -34,8 +34,7 @@ config BLOCKDEV #include GLOBALS( - long bsz; - long ra; + long setbsz, setra; ) void blockdev_main(void) @@ -56,10 +55,10 @@ void blockdev_main(void) if (!flag) continue; - if (flag & FLAG_setbsz) val = TT.bsz; + if (flag & FLAG_setbsz) val = TT.setbsz; else val = !!(flag & FLAG_setro); - if (flag & FLAG_setra) val = TT.ra; + if (flag & FLAG_setra) val = TT.setra; xioctl(fd, cmds[i], &val); diff --git a/toys/other/lspci.c b/toys/other/lspci.c index a0671791..c208484d 100644 --- a/toys/other/lspci.c +++ b/toys/other/lspci.c @@ -31,8 +31,8 @@ config LSPCI_TEXT #include "toys.h" GLOBALS( - char *ids; - long numeric; + char *i; + long n; FILE *db; ) @@ -74,7 +74,7 @@ static int do_lspci(struct dirtree *new) // Lookup/display data from pci.ids? if (CFG_LSPCI_TEXT && TT.db) { - if (TT.numeric != 1) { + if (TT.n != 1) { char *s; fseek(TT.db, 0, SEEK_SET); @@ -94,7 +94,7 @@ static int do_lspci(struct dirtree *new) } } - if (TT.numeric > 1) { + if (TT.n > 1) { printf((toys.optflags & FLAG_m) ? "%s, \"%s\" \"%s [%s]\" \"%s [%s]\"" : "%s Class %s: %s [%s] %s [%s]", @@ -119,9 +119,9 @@ driver: void lspci_main(void) { - if (CFG_LSPCI_TEXT && TT.numeric != 1) { - if (!TT.ids) TT.ids = "/usr/share/misc/pci.ids"; - if (!(TT.db = fopen(TT.ids, "r"))) perror_msg("%s", TT.ids); + if (CFG_LSPCI_TEXT && TT.n != 1) { + if (!TT.i) TT.i = "/usr/share/misc/pci.ids"; + if (!(TT.db = fopen(TT.i, "r"))) perror_msg("%s", TT.i); } dirtree_read("/sys/bus/pci/devices", do_lspci); diff --git a/toys/other/nsenter.c b/toys/other/nsenter.c index 5424df7e..007e0556 100644 --- a/toys/other/nsenter.c +++ b/toys/other/nsenter.c @@ -64,13 +64,15 @@ config NSENTER #define FOR_nsenter #include "toys.h" +#include #include -int unshare(int flags); -int setns(int fd, int nstype); + +#define unshare(flags) syscall(SYS_unshare, flags) +#define setns(fd, nstype) syscall(SYS_setns, fd, nstype) GLOBALS( - char *nsnames[6]; - long targetpid; + char *Uupnmi[6]; + long t; ) // Code that must run in unshare's flag context @@ -144,12 +146,12 @@ void unshare_main(void) char *nsnames = "user\0uts\0pid\0net\0mnt\0ipc"; for (i = 0; i