mirror of https://github.com/mirror/busybox.git
parent
4e9ca75281
commit
6b404431aa
|
@ -70,9 +70,9 @@ int index_in_substrings(const char *strings, const char *key)
|
||||||
|
|
||||||
const char *nth_string(const char *strings, int n)
|
const char *nth_string(const char *strings, int n)
|
||||||
{
|
{
|
||||||
while (n) {
|
while (n) {
|
||||||
n--;
|
n--;
|
||||||
strings += strlen(strings) + 1;
|
strings += strlen(strings) + 1;
|
||||||
}
|
}
|
||||||
return strings;
|
return strings;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
enum {
|
enum {
|
||||||
/* We use int16_t for positions, need to limit line len */
|
/* We use int16_t for positions, need to limit line len */
|
||||||
MAX_LINELEN = CONFIG_FEATURE_EDITING_MAX_LEN < 0x7ff0
|
MAX_LINELEN = CONFIG_FEATURE_EDITING_MAX_LEN < 0x7ff0
|
||||||
? CONFIG_FEATURE_EDITING_MAX_LEN
|
? CONFIG_FEATURE_EDITING_MAX_LEN
|
||||||
: 0x7ff0
|
: 0x7ff0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ int ndelay_on(int fd)
|
||||||
|
|
||||||
int close_on_exec_on(int fd)
|
int close_on_exec_on(int fd)
|
||||||
{
|
{
|
||||||
return fcntl(fd, F_SETFD, FD_CLOEXEC);
|
return fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ndelay_off(int fd)
|
int ndelay_off(int fd)
|
||||||
|
|
|
@ -1155,10 +1155,10 @@ static void identify(uint16_t *val)
|
||||||
|
|
||||||
#if ENABLE_FEATURE_HDPARM_GET_IDENTITY
|
#if ENABLE_FEATURE_HDPARM_GET_IDENTITY
|
||||||
static const char cfg_str[] ALIGN1 =
|
static const char cfg_str[] ALIGN1 =
|
||||||
"""\0" "HardSect""\0" "SoftSect""\0" "NotMFM""\0"
|
"""\0" "HardSect""\0" "SoftSect""\0" "NotMFM""\0"
|
||||||
"HdSw>15uSec""\0" "SpinMotCtl""\0" "Fixed""\0" "Removeable""\0"
|
"HdSw>15uSec""\0" "SpinMotCtl""\0" "Fixed""\0" "Removeable""\0"
|
||||||
"DTR<=5Mbs""\0" "DTR>5Mbs""\0" "DTR>10Mbs""\0" "RotSpdTol>.5%""\0"
|
"DTR<=5Mbs""\0" "DTR>5Mbs""\0" "DTR>10Mbs""\0" "RotSpdTol>.5%""\0"
|
||||||
"dStbOff""\0" "TrkOff""\0" "FmtGapReq""\0" "nonMagnetic"
|
"dStbOff""\0" "TrkOff""\0" "FmtGapReq""\0" "nonMagnetic"
|
||||||
;
|
;
|
||||||
|
|
||||||
static const char BuffType[] ALIGN1 =
|
static const char BuffType[] ALIGN1 =
|
||||||
|
|
|
@ -55,7 +55,7 @@ struct ethtool_drvinfo {
|
||||||
char version[32]; /* driver version string */
|
char version[32]; /* driver version string */
|
||||||
char fw_version[32]; /* firmware version string, if applicable */
|
char fw_version[32]; /* firmware version string, if applicable */
|
||||||
char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
|
char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
|
||||||
/* For PCI devices, use pci_dev->slot_name. */
|
/* For PCI devices, use pci_dev->slot_name. */
|
||||||
char reserved1[32];
|
char reserved1[32];
|
||||||
char reserved2[16];
|
char reserved2[16];
|
||||||
uint32_t n_stats; /* number of u64's from ETHTOOL_GSTATS */
|
uint32_t n_stats; /* number of u64's from ETHTOOL_GSTATS */
|
||||||
|
|
|
@ -277,8 +277,8 @@ struct globals {
|
||||||
#define rcvd_tbl (G.rcvd_tbl )
|
#define rcvd_tbl (G.rcvd_tbl )
|
||||||
void BUG_ping_globals_too_big(void);
|
void BUG_ping_globals_too_big(void);
|
||||||
#define INIT_G() do { \
|
#define INIT_G() do { \
|
||||||
if (sizeof(G) > COMMON_BUFSIZE) \
|
if (sizeof(G) > COMMON_BUFSIZE) \
|
||||||
BUG_ping_globals_too_big(); \
|
BUG_ping_globals_too_big(); \
|
||||||
pingsock = -1; \
|
pingsock = -1; \
|
||||||
tmin = UINT_MAX; \
|
tmin = UINT_MAX; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
|
@ -36,7 +36,7 @@ struct globals {
|
||||||
};
|
};
|
||||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||||
struct BUG_G_too_big {
|
struct BUG_G_too_big {
|
||||||
char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1];
|
char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1];
|
||||||
};
|
};
|
||||||
#define content_len (G.content_len )
|
#define content_len (G.content_len )
|
||||||
#define beg_range (G.beg_range )
|
#define beg_range (G.beg_range )
|
||||||
|
|
|
@ -116,7 +116,7 @@ int pgrep_main(int argc, char **argv)
|
||||||
cmd = proc->comm;
|
cmd = proc->comm;
|
||||||
/* NB: OPT_INVERT is always 0 or 1 */
|
/* NB: OPT_INVERT is always 0 or 1 */
|
||||||
if ((regexec(&re_buffer, cmd, 1, re_match, 0) == 0 /* match found */
|
if ((regexec(&re_buffer, cmd, 1, re_match, 0) == 0 /* match found */
|
||||||
&& (!OPT_ANCHOR || (re_match[0].rm_so == 0 && re_match[0].rm_eo == strlen(cmd)))) ^ OPT_INVERT
|
&& (!OPT_ANCHOR || (re_match[0].rm_so == 0 && re_match[0].rm_eo == strlen(cmd)))) ^ OPT_INVERT
|
||||||
) {
|
) {
|
||||||
matched_pid = proc->pid;
|
matched_pid = proc->pid;
|
||||||
if (OPT_LAST) {
|
if (OPT_LAST) {
|
||||||
|
|
82
procps/ps.c
82
procps/ps.c
|
@ -66,60 +66,60 @@ struct globals {
|
||||||
/* for ELF executables, notes are pushed before environment and args */
|
/* for ELF executables, notes are pushed before environment and args */
|
||||||
static ptrdiff_t find_elf_note(ptrdiff_t findme)
|
static ptrdiff_t find_elf_note(ptrdiff_t findme)
|
||||||
{
|
{
|
||||||
ptrdiff_t *ep = (ptrdiff_t *) environ;
|
ptrdiff_t *ep = (ptrdiff_t *) environ;
|
||||||
|
|
||||||
while (*ep++);
|
while (*ep++);
|
||||||
while (*ep) {
|
while (*ep) {
|
||||||
if (ep[0] == findme) {
|
if (ep[0] == findme) {
|
||||||
return ep[1];
|
return ep[1];
|
||||||
}
|
}
|
||||||
ep += 2;
|
ep += 2;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_FEATURE_PS_UNUSUAL_SYSTEMS
|
#if ENABLE_FEATURE_PS_UNUSUAL_SYSTEMS
|
||||||
static unsigned get_HZ_by_waiting(void)
|
static unsigned get_HZ_by_waiting(void)
|
||||||
{
|
{
|
||||||
struct timeval tv1, tv2;
|
struct timeval tv1, tv2;
|
||||||
unsigned t1, t2, r, hz;
|
unsigned t1, t2, r, hz;
|
||||||
unsigned cnt = cnt; /* for compiler */
|
unsigned cnt = cnt; /* for compiler */
|
||||||
int diff;
|
int diff;
|
||||||
|
|
||||||
r = 0;
|
r = 0;
|
||||||
|
|
||||||
/* Wait for times() to reach new tick */
|
/* Wait for times() to reach new tick */
|
||||||
t1 = times(NULL);
|
t1 = times(NULL);
|
||||||
do {
|
do {
|
||||||
t2 = times(NULL);
|
t2 = times(NULL);
|
||||||
} while (t2 == t1);
|
} while (t2 == t1);
|
||||||
gettimeofday(&tv2, NULL);
|
gettimeofday(&tv2, NULL);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
t1 = t2;
|
t1 = t2;
|
||||||
tv1.tv_usec = tv2.tv_usec;
|
tv1.tv_usec = tv2.tv_usec;
|
||||||
|
|
||||||
/* Wait exactly one times() tick */
|
/* Wait exactly one times() tick */
|
||||||
do {
|
do {
|
||||||
t2 = times(NULL);
|
t2 = times(NULL);
|
||||||
} while (t2 == t1);
|
} while (t2 == t1);
|
||||||
gettimeofday(&tv2, NULL);
|
gettimeofday(&tv2, NULL);
|
||||||
|
|
||||||
/* Calculate ticks per sec, rounding up to even */
|
/* Calculate ticks per sec, rounding up to even */
|
||||||
diff = tv2.tv_usec - tv1.tv_usec;
|
diff = tv2.tv_usec - tv1.tv_usec;
|
||||||
if (diff <= 0) diff += 1000000;
|
if (diff <= 0) diff += 1000000;
|
||||||
hz = 1000000u / (unsigned)diff;
|
hz = 1000000u / (unsigned)diff;
|
||||||
hz = (hz+1) & ~1;
|
hz = (hz+1) & ~1;
|
||||||
|
|
||||||
/* Count how many same hz values we saw */
|
/* Count how many same hz values we saw */
|
||||||
if (r != hz) {
|
if (r != hz) {
|
||||||
r = hz;
|
r = hz;
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
}
|
}
|
||||||
cnt++;
|
cnt++;
|
||||||
} while (cnt < 3); /* exit if saw 3 same values */
|
} while (cnt < 3); /* exit if saw 3 same values */
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline unsigned get_HZ_by_waiting(void)
|
static inline unsigned get_HZ_by_waiting(void)
|
||||||
|
@ -190,7 +190,7 @@ static void put_lu(char *buf, int size, unsigned long u)
|
||||||
char buf5[5];
|
char buf5[5];
|
||||||
|
|
||||||
/* see http://en.wikipedia.org/wiki/Tera */
|
/* see http://en.wikipedia.org/wiki/Tera */
|
||||||
smart_ulltoa4( (u, buf5, " mgtpezy");
|
smart_ulltoa4(u, buf5, " mgtpezy");
|
||||||
buf5[5] = '\0';
|
buf5[5] = '\0';
|
||||||
sprintf(buf, "%.*s", size, buf5);
|
sprintf(buf, "%.*s", size, buf5);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue