aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toys/lsb/seq.c17
-rw-r--r--toys/other/blockdev.c7
-rw-r--r--toys/other/lspci.c14
-rw-r--r--toys/other/nsenter.c14
4 files changed, 26 insertions, 26 deletions
diff --git a/toys/lsb/seq.c b/toys/lsb/seq.c
index a8c1a4e8..988466b7 100644
--- a/toys/lsb/seq.c
+++ b/toys/lsb/seq.c
@@ -26,8 +26,7 @@ config SEQ
#include "toys.h"
GLOBALS(
- char *sep;
- char *fmt;
+ char *s, *f;
int precision;
)
@@ -60,7 +59,7 @@ void seq_main(void)
double first = 1, increment = 1, last, dd;
int i;
- if (!TT.sep) TT.sep = "\n";
+ if (!TT.s) TT.s = "\n";
switch (toys.optc) {
case 3: increment = parsef(toys.optargs[1]);
case 2: first = parsef(*toys.optargs);
@@ -68,8 +67,8 @@ void seq_main(void)
}
// Prepare format string with appropriate precision. Can't use %g because 1e6
- if (toys.optflags & FLAG_f) insanitize(TT.fmt);
- else sprintf(TT.fmt = toybuf, "%%.%df", TT.precision);
+ if (toys.optflags & FLAG_f) insanitize(TT.f);
+ else sprintf(TT.f = toybuf, "%%.%df", TT.precision);
// Pad to largest width
if (toys.optflags & FLAG_w) {
@@ -77,9 +76,9 @@ void seq_main(void)
for (i=0; i<3; i++) {
dd = (double []){first, increment, last}[i];
- len = maxof(len, snprintf(0, 0, TT.fmt, dd));
+ len = maxof(len, snprintf(0, 0, TT.f, dd));
}
- sprintf(TT.fmt = toybuf, "%%0%d.%df", len, TT.precision);
+ sprintf(TT.f = toybuf, "%%0%d.%df", len, TT.precision);
}
// Other implementations output nothing if increment is 0 and first > last,
@@ -92,8 +91,8 @@ void seq_main(void)
// Multiply to avoid accumulating rounding errors from increment.
dd = first+i*increment;
if ((increment<0 && dd<last) || (increment>0 && dd>last)) break;
- if (i++) printf("%s", TT.sep);
- printf(TT.fmt, dd);
+ if (i++) printf("%s", TT.s);
+ printf(TT.f, dd);
}
if (i) printf("\n");
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 <linux/fs.h>
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 <sys/syscall.h>
#include <linux/sched.h>
-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<ARRAY_LEN(flags); i++) {
- char *filename = TT.nsnames[i];
+ char *filename = TT.Uupnmi[i];
if (toys.optflags & (1<<i)) {
if (!filename || !*filename) {
if (!(toys.optflags & FLAG_t)) error_exit("need -t or =filename");
- sprintf(toybuf, "/proc/%ld/ns/%s", TT.targetpid, nsnames);
+ sprintf(toybuf, "/proc/%ld/ns/%s", TT.t, nsnames);
filename = toybuf;
}