mostly style fixes
This commit is contained in:
parent
048c93cc55
commit
9225854144
@ -444,7 +444,7 @@ void bb_show_usage(void)
|
||||
format_string = "%s\n\nUsage: %s %s\n\n";
|
||||
if (*usage_string == '\b')
|
||||
format_string = "%s\n\nNo help available.\n\n";
|
||||
fprintf (stderr, format_string, bb_msg_full_version,
|
||||
fprintf(stderr, format_string, bb_msg_full_version,
|
||||
applet_using->name, usage_string);
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ static const char * idle_string (time_t t)
|
||||
if (s < 60)
|
||||
return ".";
|
||||
if (s < (24 * 60 * 60)) {
|
||||
sprintf (str, "%02d:%02d",
|
||||
sprintf(str, "%02d:%02d",
|
||||
(int) (s / (60 * 60)),
|
||||
(int) ((s % (60 * 60)) / 60));
|
||||
return str;
|
||||
|
@ -9818,7 +9818,7 @@ static int jread(struct buffer_head **bhp, journal_t *journal,
|
||||
err = journal_bmap(journal, offset, &blocknr);
|
||||
|
||||
if (err) {
|
||||
printf ("JBD: bad block at offset %u\n", offset);
|
||||
printf("JBD: bad block at offset %u\n", offset);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -9835,7 +9835,7 @@ static int jread(struct buffer_head **bhp, journal_t *journal,
|
||||
}
|
||||
|
||||
if (!buffer_uptodate(bh)) {
|
||||
printf ("JBD: Failed to read block at offset %u\n", offset);
|
||||
printf("JBD: Failed to read block at offset %u\n", offset);
|
||||
brelse(bh);
|
||||
return -EIO;
|
||||
}
|
||||
@ -10049,7 +10049,7 @@ static int do_one_pass(journal_t *journal,
|
||||
/* Recover what we can, but
|
||||
* report failure at the end. */
|
||||
success = err;
|
||||
printf ("JBD: IO error %d recovering "
|
||||
printf("JBD: IO error %d recovering "
|
||||
"block %ld in log\n",
|
||||
err, io_block);
|
||||
} else {
|
||||
@ -10074,7 +10074,7 @@ static int do_one_pass(journal_t *journal,
|
||||
blocknr,
|
||||
journal->j_blocksize);
|
||||
if (nbh == NULL) {
|
||||
printf ("JBD: Out of memory "
|
||||
printf("JBD: Out of memory "
|
||||
"during recovery.\n");
|
||||
err = -ENOMEM;
|
||||
brelse(bh);
|
||||
@ -10153,7 +10153,7 @@ static int do_one_pass(journal_t *journal,
|
||||
/* It's really bad news if different passes end up at
|
||||
* different places (but possible due to IO errors). */
|
||||
if (info->end_transaction != next_commit_ID) {
|
||||
printf ("JBD: recovery pass %d ended at "
|
||||
printf("JBD: recovery pass %d ended at "
|
||||
"transaction %u, expected %u\n",
|
||||
pass, next_commit_ID, info->end_transaction);
|
||||
if (!success)
|
||||
@ -12335,15 +12335,15 @@ static int ask_yn(const char * string, int def)
|
||||
int ask (e2fsck_t ctx, const char * string, int def)
|
||||
{
|
||||
if (ctx->options & E2F_OPT_NO) {
|
||||
printf (_("%s? no\n\n"), string);
|
||||
printf(_("%s? no\n\n"), string);
|
||||
return 0;
|
||||
}
|
||||
if (ctx->options & E2F_OPT_YES) {
|
||||
printf (_("%s? yes\n\n"), string);
|
||||
printf(_("%s? yes\n\n"), string);
|
||||
return 1;
|
||||
}
|
||||
if (ctx->options & E2F_OPT_PREEN) {
|
||||
printf ("%s? %s\n\n", string, def ? _("yes") : _("no"));
|
||||
printf("%s? %s\n\n", string, def ? _("yes") : _("no"));
|
||||
return def;
|
||||
}
|
||||
return ask_yn(string, def);
|
||||
@ -12606,26 +12606,26 @@ static void show_stats(e2fsck_t ctx)
|
||||
blocks_used, blocks);
|
||||
return;
|
||||
}
|
||||
printf ("\n%8d inode%s used (%d%%)\n", P_E2("", "s", inodes_used),
|
||||
printf("\n%8d inode%s used (%d%%)\n", P_E2("", "s", inodes_used),
|
||||
100 * inodes_used / inodes);
|
||||
printf ("%8d non-contiguous inode%s (%0d.%d%%)\n",
|
||||
printf("%8d non-contiguous inode%s (%0d.%d%%)\n",
|
||||
P_E2("", "s", ctx->fs_fragmented),
|
||||
frag_percent / 10, frag_percent % 10);
|
||||
printf (_(" # of inodes with ind/dind/tind blocks: %d/%d/%d\n"),
|
||||
printf(_(" # of inodes with ind/dind/tind blocks: %d/%d/%d\n"),
|
||||
ctx->fs_ind_count, ctx->fs_dind_count, ctx->fs_tind_count);
|
||||
printf ("%8d block%s used (%d%%)\n", P_E2("", "s", blocks_used),
|
||||
printf("%8d block%s used (%d%%)\n", P_E2("", "s", blocks_used),
|
||||
(int) ((long long) 100 * blocks_used / blocks));
|
||||
printf ("%8d large file%s\n", P_E2("", "s", ctx->large_files));
|
||||
printf ("\n%8d regular file%s\n", P_E2("", "s", ctx->fs_regular_count));
|
||||
printf ("%8d director%s\n", P_E2("y", "ies", ctx->fs_directory_count));
|
||||
printf ("%8d character device file%s\n", P_E2("", "s", ctx->fs_chardev_count));
|
||||
printf ("%8d block device file%s\n", P_E2("", "s", ctx->fs_blockdev_count));
|
||||
printf ("%8d fifo%s\n", P_E2("", "s", ctx->fs_fifo_count));
|
||||
printf ("%8d link%s\n", P_E2("", "s", ctx->fs_links_count - dir_links));
|
||||
printf ("%8d symbolic link%s", P_E2("", "s", ctx->fs_symlinks_count));
|
||||
printf (" (%d fast symbolic link%s)\n", P_E2("", "s", ctx->fs_fast_symlinks_count));
|
||||
printf ("%8d socket%s--------\n\n", P_E2("", "s", ctx->fs_sockets_count));
|
||||
printf ("%8d file%s\n", P_E2("", "s", ctx->fs_total_count - dir_links));
|
||||
printf("%8d large file%s\n", P_E2("", "s", ctx->large_files));
|
||||
printf("\n%8d regular file%s\n", P_E2("", "s", ctx->fs_regular_count));
|
||||
printf("%8d director%s\n", P_E2("y", "ies", ctx->fs_directory_count));
|
||||
printf("%8d character device file%s\n", P_E2("", "s", ctx->fs_chardev_count));
|
||||
printf("%8d block device file%s\n", P_E2("", "s", ctx->fs_blockdev_count));
|
||||
printf("%8d fifo%s\n", P_E2("", "s", ctx->fs_fifo_count));
|
||||
printf("%8d link%s\n", P_E2("", "s", ctx->fs_links_count - dir_links));
|
||||
printf("%8d symbolic link%s", P_E2("", "s", ctx->fs_symlinks_count));
|
||||
printf(" (%d fast symbolic link%s)\n", P_E2("", "s", ctx->fs_fast_symlinks_count));
|
||||
printf("%8d socket%s--------\n\n", P_E2("", "s", ctx->fs_sockets_count));
|
||||
printf("%8d file%s\n", P_E2("", "s", ctx->fs_total_count - dir_links));
|
||||
}
|
||||
|
||||
static void check_mount(e2fsck_t ctx)
|
||||
@ -12663,7 +12663,7 @@ static void check_mount(e2fsck_t ctx)
|
||||
"SEVERE filesystem damage.\007\007\007\n\n"));
|
||||
cont = ask_yn(_("Do you really want to continue"), -1);
|
||||
if (!cont) {
|
||||
printf (_("check aborted.\n"));
|
||||
printf(_("check aborted.\n"));
|
||||
exit (0);
|
||||
}
|
||||
return;
|
||||
|
@ -23,5 +23,5 @@ void print_fs_state(FILE *f, unsigned short state)
|
||||
{
|
||||
fprintf(f, (state & EXT2_VALID_FS ? " clean" : " not clean"));
|
||||
if (state & EXT2_ERROR_FS)
|
||||
fprintf (f, " with errors");
|
||||
fprintf(f, " with errors");
|
||||
}
|
||||
|
@ -56,20 +56,20 @@ typedef int (*action_fp)(const char *fileName, struct stat *statbuf, void *);
|
||||
typedef struct {
|
||||
action_fp f;
|
||||
} action;
|
||||
#define SACT(name, arg...) typedef struct { action a; arg; } action_##name;
|
||||
#define SFUNC(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap)
|
||||
SACT(print)
|
||||
SACT(name, char *pattern;)
|
||||
USE_FEATURE_FIND_PRINT0(SACT(print0))
|
||||
USE_FEATURE_FIND_TYPE( SACT(type, int type_mask;))
|
||||
USE_FEATURE_FIND_PERM( SACT(perm, char perm_char; int perm_mask;))
|
||||
USE_FEATURE_FIND_MTIME( SACT(mtime, char mtime_char; int mtime_days;))
|
||||
USE_FEATURE_FIND_MMIN( SACT(mmin, char mmin_char; int mmin_mins;))
|
||||
USE_FEATURE_FIND_NEWER( SACT(newer, time_t newer_mtime;))
|
||||
USE_FEATURE_FIND_INUM( SACT(inum, ino_t inode_num;))
|
||||
USE_FEATURE_FIND_EXEC( SACT(exec, char **exec_argv; int *subst_count; int exec_argc;))
|
||||
USE_DESKTOP( SACT(paren, action ***subexpr;))
|
||||
USE_DESKTOP( SACT(prune))
|
||||
#define ACTS(name, arg...) typedef struct { action a; arg; } action_##name;
|
||||
#define ACTF(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap)
|
||||
ACTS(print)
|
||||
ACTS(name, char *pattern;)
|
||||
USE_FEATURE_FIND_PRINT0(ACTS(print0))
|
||||
USE_FEATURE_FIND_TYPE( ACTS(type, int type_mask;))
|
||||
USE_FEATURE_FIND_PERM( ACTS(perm, char perm_char; int perm_mask;))
|
||||
USE_FEATURE_FIND_MTIME( ACTS(mtime, char mtime_char; int mtime_days;))
|
||||
USE_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; int mmin_mins;))
|
||||
USE_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;))
|
||||
USE_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;))
|
||||
USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; int *subst_count; int exec_argc;))
|
||||
USE_DESKTOP( ACTS(paren, action ***subexpr;))
|
||||
USE_DESKTOP( ACTS(prune))
|
||||
|
||||
static action ***actions;
|
||||
static int need_print = 1;
|
||||
@ -131,7 +131,7 @@ static int exec_actions(action ***appp, const char *fileName, struct stat *statb
|
||||
}
|
||||
|
||||
|
||||
SFUNC(name)
|
||||
ACTF(name)
|
||||
{
|
||||
const char *tmp = strrchr(fileName, '/');
|
||||
if (tmp == NULL)
|
||||
@ -141,13 +141,13 @@ SFUNC(name)
|
||||
return fnmatch(ap->pattern, tmp, FNM_PERIOD) == 0;
|
||||
}
|
||||
#if ENABLE_FEATURE_FIND_TYPE
|
||||
SFUNC(type)
|
||||
ACTF(type)
|
||||
{
|
||||
return ((statbuf->st_mode & S_IFMT) == ap->type_mask);
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_FEATURE_FIND_PERM
|
||||
SFUNC(perm)
|
||||
ACTF(perm)
|
||||
{
|
||||
return !((isdigit(ap->perm_char) && (statbuf->st_mode & 07777) == ap->perm_mask)
|
||||
|| (ap->perm_char == '-' && (statbuf->st_mode & ap->perm_mask) == ap->perm_mask)
|
||||
@ -155,7 +155,7 @@ SFUNC(perm)
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_FEATURE_FIND_MTIME
|
||||
SFUNC(mtime)
|
||||
ACTF(mtime)
|
||||
{
|
||||
time_t file_age = time(NULL) - statbuf->st_mtime;
|
||||
time_t mtime_secs = ap->mtime_days * 24 * 60 * 60;
|
||||
@ -166,7 +166,7 @@ SFUNC(mtime)
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_FEATURE_FIND_MMIN
|
||||
SFUNC(mmin)
|
||||
ACTF(mmin)
|
||||
{
|
||||
time_t file_age = time(NULL) - statbuf->st_mtime;
|
||||
time_t mmin_secs = ap->mmin_mins * 60;
|
||||
@ -177,19 +177,19 @@ SFUNC(mmin)
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_FEATURE_FIND_NEWER
|
||||
SFUNC(newer)
|
||||
ACTF(newer)
|
||||
{
|
||||
return (ap->newer_mtime >= statbuf->st_mtime);
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_FEATURE_FIND_INUM
|
||||
SFUNC(inum)
|
||||
ACTF(inum)
|
||||
{
|
||||
return (statbuf->st_ino != ap->inode_num);
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_FEATURE_FIND_EXEC
|
||||
SFUNC(exec)
|
||||
ACTF(exec)
|
||||
{
|
||||
int i, rc;
|
||||
char *argv[ap->exec_argc+1];
|
||||
@ -207,21 +207,21 @@ SFUNC(exec)
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_FIND_PRINT0
|
||||
SFUNC(print0)
|
||||
ACTF(print0)
|
||||
{
|
||||
printf("%s%c", fileName, '\0');
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
SFUNC(print)
|
||||
ACTF(print)
|
||||
{
|
||||
puts(fileName);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if ENABLE_DESKTOP
|
||||
SFUNC(paren)
|
||||
ACTF(paren)
|
||||
{
|
||||
return exec_actions(ap->subexpr, fileName, statbuf);
|
||||
}
|
||||
@ -231,7 +231,7 @@ SFUNC(paren)
|
||||
* Example:
|
||||
* find dir -name 'asm-*' -prune -o -name '*.[chS]' -print
|
||||
*/
|
||||
SFUNC(prune)
|
||||
ACTF(prune)
|
||||
{
|
||||
return SKIP;
|
||||
}
|
||||
@ -501,6 +501,7 @@ action*** parse_params(char **argv)
|
||||
int find_main(int argc, char **argv)
|
||||
{
|
||||
int dereference = FALSE;
|
||||
char *arg;
|
||||
char **argp;
|
||||
int i, firstopt, status = EXIT_SUCCESS;
|
||||
|
||||
@ -524,10 +525,9 @@ int find_main(int argc, char **argv)
|
||||
// We implement: -follow, -xdev
|
||||
|
||||
/* Process options, and replace then with -a */
|
||||
/* (that will be ignored by recursive parser later) */
|
||||
/* (-a will be ignored by recursive parser later) */
|
||||
argp = &argv[firstopt];
|
||||
while (*argp) {
|
||||
char *arg = argp[0];
|
||||
while ((arg = argp[0])) {
|
||||
if (strcmp(arg, "-follow") == 0) {
|
||||
dereference = TRUE;
|
||||
argp[0] = "-a";
|
||||
|
@ -180,7 +180,7 @@ int adduser_main(int argc, char **argv)
|
||||
/* create string for $HOME if not specified already */
|
||||
if (!pw.pw_dir) {
|
||||
snprintf(bb_common_bufsiz1, BUFSIZ, "/home/%s", argv[optind]);
|
||||
pw.pw_dir = &bb_common_bufsiz1[0];
|
||||
pw.pw_dir = &bb_common_bufsiz1[0];
|
||||
}
|
||||
|
||||
/* create a passwd struct */
|
||||
|
@ -107,7 +107,7 @@ int mt_main(int argc, char **argv)
|
||||
case MTTELL:
|
||||
if (ioctl(fd, MTIOCPOS, &position) < 0)
|
||||
bb_perror_msg_and_die("%s", file);
|
||||
printf ("At block %d.\n", (int) position.mt_blkno);
|
||||
printf("At block %d.\n", (int) position.mt_blkno);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -455,14 +455,14 @@ static int iproute_flush_cache(void)
|
||||
char *buffer = "-1";
|
||||
|
||||
if (flush_fd < 0) {
|
||||
fprintf (stderr, "Cannot open \"%s\"\n", ROUTE_FLUSH_PATH);
|
||||
fprintf(stderr, "Cannot open \"%s\"\n", ROUTE_FLUSH_PATH);
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = strlen (buffer);
|
||||
|
||||
if ((write (flush_fd, (void *)buffer, len)) < len) {
|
||||
fprintf (stderr, "Cannot flush routing cache\n");
|
||||
fprintf(stderr, "Cannot flush routing cache\n");
|
||||
return -1;
|
||||
}
|
||||
close(flush_fd);
|
||||
|
@ -72,8 +72,7 @@ int ps_main(int argc, char **argv)
|
||||
safe_strncpy(sbuf, "unknown", 7);
|
||||
}
|
||||
len = printf("%5u %-32s %s ", (unsigned)p->pid, sbuf, p->state);
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
if (p->rss == 0)
|
||||
len = printf("%5u %-8s %s ", (unsigned)p->pid, p->user, p->state);
|
||||
|
@ -10,14 +10,7 @@
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Copied from linux/rtc.h to eliminate the kernel dependency */
|
||||
@ -42,59 +35,62 @@ struct linux_rtc_time {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static time_t read_rtc(int utc)
|
||||
static int xopen_rtc(int flags)
|
||||
{
|
||||
int rtc;
|
||||
rtc = open("/dev/rtc", flags);
|
||||
if (rtc < 0) {
|
||||
rtc = open("/dev/misc/rtc", flags);
|
||||
if (rtc < 0)
|
||||
bb_perror_msg_and_die("cannot access RTC");
|
||||
}
|
||||
return rtc;
|
||||
}
|
||||
|
||||
static time_t read_rtc(int utc)
|
||||
{
|
||||
struct tm tm;
|
||||
char *oldtz = 0;
|
||||
time_t t = 0;
|
||||
int rtc = xopen_rtc(O_RDONLY);
|
||||
|
||||
if (( rtc = open ( "/dev/rtc", O_RDONLY )) < 0 ) {
|
||||
if (( rtc = open ( "/dev/misc/rtc", O_RDONLY )) < 0 )
|
||||
bb_perror_msg_and_die ( "cannot access RTC" );
|
||||
}
|
||||
memset ( &tm, 0, sizeof( struct tm ));
|
||||
if ( ioctl ( rtc, RTC_RD_TIME, &tm ) < 0 )
|
||||
bb_perror_msg_and_die ( "cannot read time from RTC" );
|
||||
memset(&tm, 0, sizeof(struct tm));
|
||||
if (ioctl(rtc, RTC_RD_TIME, &tm) < 0 )
|
||||
bb_perror_msg_and_die("cannot read time from RTC");
|
||||
tm.tm_isdst = -1; /* not known */
|
||||
|
||||
close ( rtc );
|
||||
close(rtc);
|
||||
|
||||
if ( utc ) {
|
||||
oldtz = getenv ( "TZ" );
|
||||
setenv ( "TZ", "UTC 0", 1 );
|
||||
tzset ( );
|
||||
if (utc) {
|
||||
oldtz = getenv("TZ");
|
||||
setenv("TZ", "UTC 0", 1);
|
||||
tzset();
|
||||
}
|
||||
|
||||
t = mktime ( &tm );
|
||||
t = mktime(&tm);
|
||||
|
||||
if ( utc ) {
|
||||
if ( oldtz )
|
||||
setenv ( "TZ", oldtz, 1 );
|
||||
if (utc) {
|
||||
if (oldtz)
|
||||
setenv("TZ", oldtz, 1);
|
||||
else
|
||||
unsetenv ( "TZ" );
|
||||
tzset ( );
|
||||
unsetenv("TZ");
|
||||
tzset();
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
static void write_rtc(time_t t, int utc)
|
||||
{
|
||||
int rtc;
|
||||
struct tm tm;
|
||||
int rtc = xopen_rtc(O_WRONLY);
|
||||
|
||||
if (( rtc = open ( "/dev/rtc", O_WRONLY )) < 0 ) {
|
||||
if (( rtc = open ( "/dev/misc/rtc", O_WRONLY )) < 0 )
|
||||
bb_perror_msg_and_die ( "cannot access RTC" );
|
||||
}
|
||||
|
||||
tm = *( utc ? gmtime ( &t ) : localtime ( &t ));
|
||||
tm = *(utc ? gmtime(&t) : localtime(&t));
|
||||
tm.tm_isdst = 0;
|
||||
|
||||
if ( ioctl ( rtc, RTC_SET_TIME, &tm ) < 0 )
|
||||
bb_perror_msg_and_die ( "cannot set the RTC time" );
|
||||
if (ioctl(rtc, RTC_SET_TIME, &tm) < 0)
|
||||
bb_perror_msg_and_die("cannot set the RTC time");
|
||||
|
||||
close ( rtc );
|
||||
close(rtc);
|
||||
}
|
||||
|
||||
static int show_clock(int utc)
|
||||
@ -103,15 +99,15 @@ static int show_clock(int utc)
|
||||
time_t t;
|
||||
RESERVE_CONFIG_BUFFER(buffer, 64);
|
||||
|
||||
t = read_rtc ( utc );
|
||||
ptm = localtime ( &t ); /* Sets 'tzname[]' */
|
||||
t = read_rtc(utc);
|
||||
ptm = localtime(&t); /* Sets 'tzname[]' */
|
||||
|
||||
safe_strncpy ( buffer, ctime ( &t ), 64);
|
||||
if ( buffer [0] )
|
||||
buffer [strlen ( buffer ) - 1] = 0;
|
||||
safe_strncpy(buffer, ctime(&t), 64);
|
||||
if (buffer[0])
|
||||
buffer[strlen(buffer) - 1] = 0;
|
||||
|
||||
//printf ( "%s %.6f seconds %s\n", buffer, 0.0, utc ? "" : ( ptm-> tm_isdst ? tzname [1] : tzname [0] ));
|
||||
printf ( "%s %.6f seconds\n", buffer, 0.0 );
|
||||
//printf("%s %.6f seconds %s\n", buffer, 0.0, utc ? "" : (ptm->tm_isdst ? tzname [1] : tzname [0]));
|
||||
printf( "%s %.6f seconds\n", buffer, 0.0);
|
||||
RELEASE_CONFIG_BUFFER(buffer);
|
||||
|
||||
return 0;
|
||||
@ -122,10 +118,10 @@ static int to_sys_clock(int utc)
|
||||
struct timeval tv = { 0, 0 };
|
||||
const struct timezone tz = { timezone/60 - 60*daylight, 0 };
|
||||
|
||||
tv.tv_sec = read_rtc ( utc );
|
||||
tv.tv_sec = read_rtc(utc);
|
||||
|
||||
if ( settimeofday ( &tv, &tz ))
|
||||
bb_perror_msg_and_die ( "settimeofday() failed" );
|
||||
if (settimeofday(&tv, &tz))
|
||||
bb_perror_msg_and_die("settimeofday() failed");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -135,10 +131,10 @@ static int from_sys_clock(int utc)
|
||||
struct timeval tv = { 0, 0 };
|
||||
struct timezone tz = { 0, 0 };
|
||||
|
||||
if ( gettimeofday ( &tv, &tz ))
|
||||
bb_perror_msg_and_die ( "gettimeofday() failed" );
|
||||
if (gettimeofday(&tv, &tz))
|
||||
bb_perror_msg_and_die("gettimeofday() failed");
|
||||
|
||||
write_rtc ( tv.tv_sec, utc );
|
||||
write_rtc(tv.tv_sec, utc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -150,43 +146,43 @@ static int from_sys_clock(int utc)
|
||||
static int check_utc(void)
|
||||
{
|
||||
int utc = 0;
|
||||
FILE *f = fopen ( ADJTIME_PATH, "r" );
|
||||
FILE *f = fopen(ADJTIME_PATH, "r");
|
||||
|
||||
if ( f ) {
|
||||
if (f) {
|
||||
RESERVE_CONFIG_BUFFER(buffer, 128);
|
||||
|
||||
while ( fgets ( buffer, sizeof( buffer ), f )) {
|
||||
int len = strlen ( buffer );
|
||||
while (fgets(buffer, sizeof(buffer), f)) {
|
||||
int len = strlen(buffer);
|
||||
|
||||
while ( len && isspace ( buffer [len - 1] ))
|
||||
while (len && isspace(buffer[len - 1]))
|
||||
len--;
|
||||
|
||||
buffer [len] = 0;
|
||||
buffer[len] = 0;
|
||||
|
||||
if ( strncmp ( buffer, "UTC", 3 ) == 0 ) {
|
||||
if (strncmp(buffer, "UTC", 3) == 0 ) {
|
||||
utc = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose ( f );
|
||||
fclose(f);
|
||||
RELEASE_CONFIG_BUFFER(buffer);
|
||||
}
|
||||
return utc;
|
||||
}
|
||||
|
||||
#define HWCLOCK_OPT_LOCALTIME 0x01
|
||||
#define HWCLOCK_OPT_UTC 0x02
|
||||
#define HWCLOCK_OPT_SHOW 0x04
|
||||
#define HWCLOCK_OPT_HCTOSYS 0x08
|
||||
#define HWCLOCK_OPT_SYSTOHC 0x10
|
||||
#define HWCLOCK_OPT_LOCALTIME 0x01
|
||||
#define HWCLOCK_OPT_UTC 0x02
|
||||
#define HWCLOCK_OPT_SHOW 0x04
|
||||
#define HWCLOCK_OPT_HCTOSYS 0x08
|
||||
#define HWCLOCK_OPT_SYSTOHC 0x10
|
||||
|
||||
int hwclock_main ( int argc, char **argv )
|
||||
int hwclock_main(int argc, char **argv )
|
||||
{
|
||||
unsigned opt;
|
||||
int utc;
|
||||
|
||||
#if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS
|
||||
static const struct option hwclock_long_options[] = {
|
||||
static const struct option hwclock_long_options[] = {
|
||||
{ "localtime", 0, 0, 'l' },
|
||||
{ "utc", 0, 0, 'u' },
|
||||
{ "show", 0, 0, 'r' },
|
||||
@ -196,7 +192,6 @@ static const struct option hwclock_long_options[] = {
|
||||
};
|
||||
applet_long_options = hwclock_long_options;
|
||||
#endif
|
||||
|
||||
opt_complementary = "?:r--ws:w--rs:s--wr:l--u:u--l";
|
||||
opt = getopt32(argc, argv, "lursw");
|
||||
|
||||
@ -207,12 +202,12 @@ static const struct option hwclock_long_options[] = {
|
||||
utc = check_utc();
|
||||
|
||||
if (opt & HWCLOCK_OPT_HCTOSYS) {
|
||||
return to_sys_clock ( utc );
|
||||
return to_sys_clock(utc);
|
||||
}
|
||||
else if (opt & HWCLOCK_OPT_SYSTOHC) {
|
||||
return from_sys_clock ( utc );
|
||||
return from_sys_clock(utc);
|
||||
} else {
|
||||
/* default HWCLOCK_OPT_SHOW */
|
||||
return show_clock ( utc );
|
||||
return show_clock(utc);
|
||||
}
|
||||
}
|
||||
|
@ -44,19 +44,20 @@ static const char defaultpro[] = "/proc/profile";
|
||||
int readprofile_main(int argc, char **argv)
|
||||
{
|
||||
FILE *map;
|
||||
const char *mapFile, *proFile, *mult=0;
|
||||
unsigned long indx=1;
|
||||
const char *mapFile, *proFile, *mult = 0;
|
||||
unsigned long indx = 1;
|
||||
size_t len;
|
||||
uint64_t add0=0;
|
||||
uint64_t add0 = 0;
|
||||
unsigned int step;
|
||||
unsigned int *buf, total, fn_len;
|
||||
unsigned long 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 optAll=0, optInfo=0, optReset=0, optVerbose=0, optNative=0;
|
||||
int optBins=0, optSub=0;
|
||||
char mapline[S_LEN];
|
||||
int maplineno=1;
|
||||
char mode[8];
|
||||
int optAll = 0, optInfo = 0, optReset = 0;
|
||||
int optVerbose = 0, optNative = 0;
|
||||
int optBins = 0, optSub = 0;
|
||||
int maplineno = 1;
|
||||
int header_printed;
|
||||
|
||||
#define next (current^1)
|
||||
@ -85,9 +86,9 @@ int readprofile_main(int argc, char **argv)
|
||||
to_write = 1; /* sth different from sizeof(int) */
|
||||
}
|
||||
|
||||
fd = xopen(defaultpro,O_WRONLY);
|
||||
fd = xopen(defaultpro, O_WRONLY);
|
||||
|
||||
if (write(fd, &multiplier, to_write) != to_write)
|
||||
if (full_write(fd, &multiplier, to_write) != to_write)
|
||||
bb_perror_msg_and_die("error writing %s", defaultpro);
|
||||
|
||||
close(fd);
|
||||
@ -101,7 +102,7 @@ int readprofile_main(int argc, char **argv)
|
||||
buf = xmalloc_open_read_close(proFile, &len);
|
||||
if (!optNative) {
|
||||
int entries = len/sizeof(*buf);
|
||||
int big = 0,small = 0,i;
|
||||
int big = 0, small = 0, i;
|
||||
unsigned *p;
|
||||
|
||||
for (p = buf+1; p < buf+entries; p++) {
|
||||
@ -135,12 +136,12 @@ int readprofile_main(int argc, char **argv)
|
||||
|
||||
map = xfopen(mapFile, "r");
|
||||
|
||||
while (fgets(mapline,S_LEN,map)) {
|
||||
if (sscanf(mapline,"%llx %s %s",&fn_add,mode,fn_name) != 3)
|
||||
while (fgets(mapline, S_LEN, map)) {
|
||||
if (sscanf(mapline, "%llx %s %s", &fn_add, mode, fn_name) != 3)
|
||||
bb_error_msg_and_die("%s(%i): wrong map line",
|
||||
mapFile, maplineno);
|
||||
|
||||
if (!strcmp(fn_name,"_stext")) /* only elf works like this */ {
|
||||
if (!strcmp(fn_name, "_stext")) /* only elf works like this */ {
|
||||
add0 = fn_add;
|
||||
break;
|
||||
}
|
||||
@ -153,12 +154,12 @@ int readprofile_main(int argc, char **argv)
|
||||
/*
|
||||
* Main loop.
|
||||
*/
|
||||
while (fgets(mapline,S_LEN,map)) {
|
||||
while (fgets(mapline, S_LEN, map)) {
|
||||
unsigned int this = 0;
|
||||
|
||||
if (sscanf(mapline,"%llx %s %s",&next_add,mode,next_name) != 3)
|
||||
if (sscanf(mapline, "%llx %s %s", &next_add, mode, next_name) != 3)
|
||||
bb_error_msg_and_die("%s(%i): wrong map line",
|
||||
mapFile, maplineno);
|
||||
mapFile, maplineno);
|
||||
|
||||
header_printed = 0;
|
||||
|
||||
@ -176,10 +177,10 @@ int readprofile_main(int argc, char **argv)
|
||||
while (indx < (next_add-add0)/step) {
|
||||
if (optBins && (buf[indx] || optAll)) {
|
||||
if (!header_printed) {
|
||||
printf ("%s:\n", fn_name);
|
||||
printf("%s:\n", fn_name);
|
||||
header_printed = 1;
|
||||
}
|
||||
printf ("\t%"PRIx64"\t%u\n", (indx - 1)*step + add0, buf[indx]);
|
||||
printf("\t%"PRIx64"\t%u\n", (indx - 1)*step + add0, buf[indx]);
|
||||
}
|
||||
this += buf[indx++];
|
||||
}
|
||||
@ -187,15 +188,15 @@ int readprofile_main(int argc, char **argv)
|
||||
|
||||
if (optBins) {
|
||||
if (optVerbose || this > 0)
|
||||
printf (" total\t\t\t\t%u\n", this);
|
||||
printf(" total\t\t\t\t%u\n", this);
|
||||
} else if ((this || optAll) &&
|
||||
(fn_len = next_add-fn_add) != 0) {
|
||||
if (optVerbose)
|
||||
printf("%016llx %-40s %6i %8.4f\n", fn_add,
|
||||
fn_name,this,this/(double)fn_len);
|
||||
fn_name, this, this/(double)fn_len);
|
||||
else
|
||||
printf("%6i %-40s %8.4f\n",
|
||||
this,fn_name,this/(double)fn_len);
|
||||
this, fn_name, this/(double)fn_len);
|
||||
if (optSub) {
|
||||
unsigned long long scan;
|
||||
|
||||
@ -212,7 +213,7 @@ int readprofile_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
fn_add = next_add;
|
||||
strcpy(fn_name,next_name);
|
||||
strcpy(fn_name, next_name);
|
||||
|
||||
maplineno++;
|
||||
}
|
||||
@ -223,10 +224,10 @@ int readprofile_main(int argc, char **argv)
|
||||
/* trailer */
|
||||
if (optVerbose)
|
||||
printf("%016x %-40s %6i %8.4f\n",
|
||||
0,"total",total,total/(double)(fn_add-add0));
|
||||
0, "total", total, total/(double)(fn_add-add0));
|
||||
else
|
||||
printf("%6i %-40s %8.4f\n",
|
||||
total,"total",total/(double)(fn_add-add0));
|
||||
total, "total", total/(double)(fn_add-add0));
|
||||
|
||||
fclose(map);
|
||||
free(buf);
|
||||
|
@ -35,7 +35,7 @@ static void delete_contents(char *directory)
|
||||
struct stat st;
|
||||
|
||||
// Don't descend into other filesystems
|
||||
if (lstat(directory,&st) || st.st_dev != rootdev) return;
|
||||
if (lstat(directory, &st) || st.st_dev != rootdev) return;
|
||||
|
||||
// Recursively delete the contents of directories.
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
@ -71,8 +71,8 @@ int switch_root_main(int argc, char *argv[])
|
||||
|
||||
// Parse args (-c console)
|
||||
|
||||
opt_complementary="-2";
|
||||
getopt32(argc,argv,"c:",&console);
|
||||
opt_complementary = "-2";
|
||||
getopt32(argc, argv, "c:", &console);
|
||||
|
||||
// Change to new root directory and verify it's a different fs.
|
||||
|
||||
@ -81,7 +81,7 @@ int switch_root_main(int argc, char *argv[])
|
||||
if (chdir(newroot) || lstat(".", &st1) || lstat("/", &st2) ||
|
||||
st1.st_dev == st2.st_dev)
|
||||
{
|
||||
bb_error_msg_and_die("bad newroot %s",newroot);
|
||||
bb_error_msg_and_die("bad newroot %s", newroot);
|
||||
}
|
||||
rootdev=st2.st_dev;
|
||||
|
||||
@ -111,12 +111,12 @@ int switch_root_main(int argc, char *argv[])
|
||||
if (console) {
|
||||
close(0);
|
||||
if(open(console, O_RDWR) < 0)
|
||||
bb_error_msg_and_die("bad console '%s'",console);
|
||||
bb_error_msg_and_die("bad console '%s'", console);
|
||||
dup2(0, 1);
|
||||
dup2(0, 2);
|
||||
}
|
||||
|
||||
// Exec real init. (This is why we must be pid 1.)
|
||||
execv(argv[optind],argv+optind);
|
||||
bb_error_msg_and_die("bad init '%s'",argv[optind]);
|
||||
execv(argv[optind], argv+optind);
|
||||
bb_error_msg_and_die("bad init '%s'", argv[optind]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user