diff options
Diffstat (limited to 'toolbox')
-rw-r--r-- | toolbox/Android.mk | 3 | ||||
-rw-r--r-- | toolbox/date.c | 96 | ||||
-rw-r--r-- | toolbox/dd.c | 3 | ||||
-rw-r--r-- | toolbox/getevent.c | 2 | ||||
-rw-r--r-- | toolbox/insmod.c | 4 | ||||
-rw-r--r-- | toolbox/ls.c | 39 | ||||
-rw-r--r-- | toolbox/nandread.c | 10 | ||||
-rw-r--r-- | toolbox/newfs_msdos.c | 7 | ||||
-rw-r--r-- | toolbox/r.c | 56 | ||||
-rw-r--r-- | toolbox/schedtop.c | 2 | ||||
-rw-r--r-- | toolbox/setconsole.c | 166 | ||||
-rw-r--r-- | toolbox/swapon.c | 6 | ||||
-rw-r--r-- | toolbox/uptime.c | 21 |
13 files changed, 161 insertions, 254 deletions
diff --git a/toolbox/Android.mk b/toolbox/Android.mk index 75ce53f..4fff9f5 100644 --- a/toolbox/Android.mk +++ b/toolbox/Android.mk @@ -12,7 +12,6 @@ TOOLS := \ rmmod \ lsmod \ ifconfig \ - setconsole \ rm \ mkdir \ rmdir \ @@ -89,6 +88,8 @@ LOCAL_SRC_FILES := \ LOCAL_C_INCLUDES := bionic/libc/bionic +LOCAL_CFLAGS += -Wno-unused-parameter + LOCAL_SHARED_LIBRARIES := \ libcutils \ liblog \ diff --git a/toolbox/date.c b/toolbox/date.c index 35ef846..d6c9052 100644 --- a/toolbox/date.c +++ b/toolbox/date.c @@ -6,15 +6,87 @@ #include <errno.h> #include <time.h> #include <linux/android_alarm.h> +#include <linux/rtc.h> #include <sys/ioctl.h> +static int settime_alarm(struct timespec *ts) { + int fd, ret; + + fd = open("/dev/alarm", O_RDWR); + if (fd < 0) + return fd; + + ret = ioctl(fd, ANDROID_ALARM_SET_RTC, ts); + close(fd); + return ret; +} + +static int settime_alarm_tm(struct tm *tm) { + time_t t; + struct timespec ts; + + t = mktime(tm); + ts.tv_sec = t; + ts.tv_nsec = 0; + return settime_alarm(&ts); +} + +static int settime_alarm_timeval(struct timeval *tv) { + struct timespec ts; + + ts.tv_sec = tv->tv_sec; + ts.tv_nsec = tv->tv_usec * 1000; + return settime_alarm(&ts); +} + +static int settime_rtc_tm(struct tm *tm) { + int fd, ret; + struct timeval tv; + struct rtc_time rtc; + + fd = open("/dev/rtc0", O_RDWR); + if (fd < 0) + return fd; + + tv.tv_sec = mktime(tm); + tv.tv_usec = 0; + + ret = settimeofday(&tv, NULL); + if (ret < 0) + goto done; + + memset(&rtc, 0, sizeof(rtc)); + rtc.tm_sec = tm->tm_sec; + rtc.tm_min = tm->tm_min; + rtc.tm_hour = tm->tm_hour; + rtc.tm_mday = tm->tm_mday; + rtc.tm_mon = tm->tm_mon; + rtc.tm_year = tm->tm_year; + rtc.tm_wday = tm->tm_wday; + rtc.tm_yday = tm->tm_yday; + rtc.tm_isdst = tm->tm_isdst; + + ret = ioctl(fd, RTC_SET_TIME, rtc); +done: + close(fd); + return ret; +} + +static int settime_rtc_timeval(struct timeval *tv) { + struct tm tm, *err; + time_t t = tv->tv_sec; + + err = gmtime_r(&t, &tm); + if (!err) + return -1; + + return settime_rtc_tm(&tm); +} + static void settime(char *s) { struct tm tm; int day = atoi(s); int hour; - time_t t; - int fd; - struct timespec ts; while (*s && *s != '.') s++; @@ -32,12 +104,8 @@ static void settime(char *s) { tm.tm_sec = (hour % 100); tm.tm_isdst = -1; - t = mktime(&tm); - - fd = open("/dev/alarm", O_RDWR); - ts.tv_sec = t; - ts.tv_nsec = 0; - ioctl(fd, ANDROID_ALARM_SET_RTC, &ts); + if (settime_alarm_tm(&tm) < 0) + settime_rtc_tm(&tm); } int date_main(int argc, char *argv[]) @@ -114,12 +182,10 @@ int date_main(int argc, char *argv[]) //tv.tv_sec = mktime(&tm); //tv.tv_usec = 0; strtotimeval(argv[optind], &tv); - printf("time %s -> %d.%d\n", argv[optind], tv.tv_sec, tv.tv_usec); - fd = open("/dev/alarm", O_RDWR); - ts.tv_sec = tv.tv_sec; - ts.tv_nsec = tv.tv_usec * 1000; - res = ioctl(fd, ANDROID_ALARM_SET_RTC, &ts); - //res = settimeofday(&tv, NULL); + printf("time %s -> %lu.%lu\n", argv[optind], tv.tv_sec, tv.tv_usec); + res = settime_alarm_timeval(&tv); + if (res < 0) + res = settime_rtc_timeval(&tv); if(res < 0) { fprintf(stderr,"settimeofday failed %s\n", strerror(errno)); return 1; diff --git a/toolbox/dd.c b/toolbox/dd.c index a8c12d2..6b61ffb 100644 --- a/toolbox/dd.c +++ b/toolbox/dd.c @@ -92,9 +92,6 @@ extern u_int files_cnt; extern int progress; extern const u_char *ctab; - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) #define DEFFILEMODE (S_IRUSR | S_IWUSR) static void dd_close(void); diff --git a/toolbox/getevent.c b/toolbox/getevent.c index 5f5e16b..ed381f5 100644 --- a/toolbox/getevent.c +++ b/toolbox/getevent.c @@ -166,7 +166,7 @@ static int print_possible_events(int fd, int print_flags) if(bit_labels && (print_flags & PRINT_LABELS)) { bit_label = get_label(bit_labels, j * 8 + k); if(bit_label) - printf(" %.20s%c%*s", bit_label, down, 20 - strlen(bit_label), ""); + printf(" %.20s%c%*s", bit_label, down, (int) (20 - strlen(bit_label)), ""); else printf(" %04x%c ", j * 8 + k, down); } else { diff --git a/toolbox/insmod.c b/toolbox/insmod.c index 756a64b..fb1448b 100644 --- a/toolbox/insmod.c +++ b/toolbox/insmod.c @@ -4,6 +4,7 @@ #include <unistd.h> #include <malloc.h> #include <errno.h> +#include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> @@ -45,7 +46,6 @@ bail: return buffer; } -#define min(x,y) ((x) < (y) ? (x) : (y)) int insmod_main(int argc, char **argv) { void *file; @@ -73,7 +73,7 @@ int insmod_main(int argc, char **argv) char *ptr = opts; for (i = 2; (i < argc) && (ptr < end); i++) { - len = min(strlen(argv[i]), end - ptr); + len = MIN(strlen(argv[i]), end - ptr); memcpy(ptr, argv[i], len); ptr += len; *ptr++ = ' '; diff --git a/toolbox/ls.c b/toolbox/ls.c index 5324511..3cc5bb2 100644 --- a/toolbox/ls.c +++ b/toolbox/ls.c @@ -75,23 +75,23 @@ static void mode2str(unsigned mode, char *out) *out = 0; } -static void user2str(unsigned uid, char *out) +static void user2str(uid_t uid, char *out, size_t out_size) { struct passwd *pw = getpwuid(uid); if(pw) { - strcpy(out, pw->pw_name); + strlcpy(out, pw->pw_name, out_size); } else { - sprintf(out, "%d", uid); + snprintf(out, out_size, "%d", uid); } } -static void group2str(unsigned gid, char *out) +static void group2str(gid_t gid, char *out, size_t out_size) { struct group *gr = getgrgid(gid); if(gr) { - strcpy(out, gr->gr_name); + strlcpy(out, gr->gr_name, out_size); } else { - sprintf(out, "%d", gid); + snprintf(out, out_size, "%d", gid); } } @@ -164,8 +164,8 @@ static int listfile_long(const char *path, struct stat *s, int flags) { char date[32]; char mode[16]; - char user[16]; - char group[16]; + char user[32]; + char group[32]; const char *name; if(!s || !path) { @@ -182,11 +182,11 @@ static int listfile_long(const char *path, struct stat *s, int flags) mode2str(s->st_mode, mode); if (flags & LIST_LONG_NUMERIC) { - sprintf(user, "%ld", s->st_uid); - sprintf(group, "%ld", s->st_gid); + snprintf(user, sizeof(user), "%u", s->st_uid); + snprintf(group, sizeof(group), "%u", s->st_gid); } else { - user2str(s->st_uid, user); - group2str(s->st_gid, group); + user2str(s->st_uid, user, sizeof(user)); + group2str(s->st_gid, group, sizeof(group)); } strftime(date, 32, "%Y-%m-%d %H:%M", localtime((const time_t*)&s->st_mtime)); @@ -209,7 +209,7 @@ static int listfile_long(const char *path, struct stat *s, int flags) break; case S_IFLNK: { char linkto[256]; - int len; + ssize_t len; len = readlink(path, linkto, 256); if(len < 0) return -1; @@ -235,11 +235,11 @@ static int listfile_long(const char *path, struct stat *s, int flags) return 0; } -static int listfile_maclabel(const char *path, struct stat *s, int flags) +static int listfile_maclabel(const char *path, struct stat *s) { char mode[16]; - char user[16]; - char group[16]; + char user[32]; + char group[32]; char *maclabel = NULL; const char *name; @@ -261,8 +261,8 @@ static int listfile_maclabel(const char *path, struct stat *s, int flags) } mode2str(s->st_mode, mode); - user2str(s->st_uid, user); - group2str(s->st_gid, group); + user2str(s->st_uid, user, sizeof(user)); + group2str(s->st_gid, group, sizeof(group)); switch(s->st_mode & S_IFMT) { case S_IFLNK: { @@ -316,6 +316,7 @@ static int listfile(const char *dirname, const char *filename, int flags) } if(lstat(pathname, &s) < 0) { + fprintf(stderr, "lstat '%s' failed: %s\n", pathname, strerror(errno)); return -1; } @@ -324,7 +325,7 @@ static int listfile(const char *dirname, const char *filename, int flags) } if ((flags & LIST_MACLABEL) != 0) { - return listfile_maclabel(pathname, &s, flags); + return listfile_maclabel(pathname, &s); } else if ((flags & LIST_LONG) != 0) { return listfile_long(pathname, &s, flags); } else /*((flags & LIST_SIZE) != 0)*/ { diff --git a/toolbox/nandread.c b/toolbox/nandread.c index b124731..d43b2fe 100644 --- a/toolbox/nandread.c +++ b/toolbox/nandread.c @@ -12,7 +12,7 @@ static int test_empty(const char *buf, size_t size) { while(size--) { - if (*buf++ != 0xff) + if (*buf++ != (char) 0xff) return 0; } return 1; @@ -44,7 +44,7 @@ int nandread_main(int argc, char **argv) struct mtd_info_user mtdinfo; struct mtd_ecc_stats initial_ecc, last_ecc, ecc; struct mtd_oob_buf oobbuf; - struct nand_ecclayout ecclayout; + nand_ecclayout_t ecclayout; do { c = getopt(argc, argv, "d:f:s:S:L:Rhv"); @@ -158,7 +158,7 @@ int nandread_main(int argc, char **argv) printf("oobavail: %u\n", ecclayout.oobavail); } if (ecclayout.oobavail > spare_size) - printf("oobavail, %d > image spare size, %d\n", ecclayout.oobavail, spare_size); + printf("oobavail, %d > image spare size, %zu\n", ecclayout.oobavail, spare_size); ret = ioctl(fd, ECCGETSTATS, &initial_ecc); if (ret) { @@ -177,7 +177,11 @@ int nandread_main(int argc, char **argv) if (rawmode) { rawmode = mtdinfo.oobsize; +#if !defined(MTD_STUPID_LOCK) /* using uapi kernel headers */ + ret = ioctl(fd, MTDFILEMODE, MTD_FILE_MODE_RAW); +#else /* still using old kernel headers */ ret = ioctl(fd, MTDFILEMODE, MTD_MODE_RAW); +#endif if (ret) { fprintf(stderr, "failed set raw mode for %s, %s\n", devname, strerror(errno)); diff --git a/toolbox/newfs_msdos.c b/toolbox/newfs_msdos.c index 6d78eb6..27dca42 100644 --- a/toolbox/newfs_msdos.c +++ b/toolbox/newfs_msdos.c @@ -234,13 +234,6 @@ static void mklabel(u_int8_t *, const char *); static void setstr(u_int8_t *, const char *, size_t); static void usage(void); -#ifdef ANDROID -#define powerof2(x) ((((x) - 1) & (x)) == 0) -#define howmany(x, y) (((x) + ((y) - 1)) / (y)) -#define MAX(x,y) ((x) > (y) ? (x) : (y)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -#endif /* * Construct a FAT12, FAT16, or FAT32 file system. */ diff --git a/toolbox/r.c b/toolbox/r.c index eb8ea0b..3b80db7 100644 --- a/toolbox/r.c +++ b/toolbox/r.c @@ -1,8 +1,16 @@ +#include <fcntl.h> +#include <inttypes.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> -#include <sys/mman.h> -#include <fcntl.h> #include <string.h> +#include <sys/mman.h> + +#if __LP64__ +#define strtoptr strtoull +#else +#define strtoptr strtoul +#endif static int usage() { @@ -12,14 +20,9 @@ static int usage() int r_main(int argc, char *argv[]) { - int width = 4, set = 0, fd; - unsigned addr, value, endaddr = 0; - unsigned long mmap_start, mmap_size; - void *page; - char *end; - if(argc < 2) return usage(); + int width = 4; if(!strcmp(argv[1], "-b")) { width = 1; argc--; @@ -31,37 +34,40 @@ int r_main(int argc, char *argv[]) } if(argc < 2) return usage(); - addr = strtoul(argv[1], 0, 16); + uintptr_t addr = strtoptr(argv[1], 0, 16); - end = strchr(argv[1], '-'); + uintptr_t endaddr = 0; + char* end = strchr(argv[1], '-'); if (end) - endaddr = strtoul(end + 1, 0, 16); + endaddr = strtoptr(end + 1, 0, 16); if (!endaddr) endaddr = addr + width - 1; if (endaddr <= addr) { - fprintf(stderr, "invalid end address\n"); + fprintf(stderr, "end address <= start address\n"); return -1; } + bool set = false; + uint32_t value = 0; if(argc > 2) { - set = 1; + set = true; value = strtoul(argv[2], 0, 16); } - fd = open("/dev/mem", O_RDWR | O_SYNC); + int fd = open("/dev/mem", O_RDWR | O_SYNC); if(fd < 0) { fprintf(stderr,"cannot open /dev/mem\n"); return -1; } - - mmap_start = addr & ~(PAGE_SIZE - 1); - mmap_size = endaddr - mmap_start + 1; + + off64_t mmap_start = addr & ~(PAGE_SIZE - 1); + size_t mmap_size = endaddr - mmap_start + 1; mmap_size = (mmap_size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); - page = mmap(0, mmap_size, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, mmap_start); + void* page = mmap64(0, mmap_size, PROT_READ | PROT_WRITE, + MAP_SHARED, fd, mmap_start); if(page == MAP_FAILED){ fprintf(stderr,"cannot mmap region\n"); @@ -71,21 +77,21 @@ int r_main(int argc, char *argv[]) while (addr <= endaddr) { switch(width){ case 4: { - unsigned *x = (unsigned*) (((unsigned) page) + (addr & 4095)); + uint32_t* x = (uint32_t*) (((uintptr_t) page) + (addr & 4095)); if(set) *x = value; - fprintf(stderr,"%08x: %08x\n", addr, *x); + fprintf(stderr,"%08"PRIxPTR": %08x\n", addr, *x); break; } case 2: { - unsigned short *x = (unsigned short*) (((unsigned) page) + (addr & 4095)); + uint16_t* x = (uint16_t*) (((uintptr_t) page) + (addr & 4095)); if(set) *x = value; - fprintf(stderr,"%08x: %04x\n", addr, *x); + fprintf(stderr,"%08"PRIxPTR": %04x\n", addr, *x); break; } case 1: { - unsigned char *x = (unsigned char*) (((unsigned) page) + (addr & 4095)); + uint8_t* x = (uint8_t*) (((uintptr_t) page) + (addr & 4095)); if(set) *x = value; - fprintf(stderr,"%08x: %02x\n", addr, *x); + fprintf(stderr,"%08"PRIxPTR": %02x\n", addr, *x); break; } } diff --git a/toolbox/schedtop.c b/toolbox/schedtop.c index 6859b50..a76f968 100644 --- a/toolbox/schedtop.c +++ b/toolbox/schedtop.c @@ -212,7 +212,7 @@ static void update_table(DIR *d, uint32_t flags) } if (!(flags & FLAG_BATCH)) printf("\e[H\e[0J"); - printf("Processes: %d, Threads %d\n", processes.active, threads.active); + printf("Processes: %zu, Threads %zu\n", processes.active, threads.active); switch (time_dp) { case 3: printf(" TID --- SINCE LAST ---- ---------- TOTAL ----------\n"); diff --git a/toolbox/setconsole.c b/toolbox/setconsole.c deleted file mode 100644 index 0159c07..0000000 --- a/toolbox/setconsole.c +++ /dev/null @@ -1,166 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <fcntl.h> -#include <string.h> -#include <linux/kd.h> -#include <linux/vt.h> -#include <errno.h> -#include <pthread.h> -#include <unistd.h> -#include <sys/ioctl.h> - -static int activate_thread_switch_vc; -static void *activate_thread(void *arg) -{ - int res; - int fd = (int)arg; - while(activate_thread_switch_vc >= 0) { - do { - res = ioctl(fd, VT_ACTIVATE, (void*)activate_thread_switch_vc); - } while(res < 0 && errno == EINTR); - if (res < 0) { - fprintf(stderr, "ioctl( vcfd, VT_ACTIVATE, vtnum) failed, %d %d %s for %d\n", res, errno, strerror(errno), activate_thread_switch_vc); - } - if(activate_thread_switch_vc >= 0) - sleep(1); - } - return NULL; -} - - -int setconsole_main(int argc, char *argv[]) -{ - int c; - int fd; - int res; - - int mode = -1; - int new_vc = 0; - int close_vc = 0; - int switch_vc = -1; - int printvc = 0; - char *ttydev = "/dev/tty0"; - - do { - c = getopt(argc, argv, "d:gtncv:poh"); - if (c == EOF) - break; - switch (c) { - case 'd': - ttydev = optarg; - break; - case 'g': - if(mode == KD_TEXT) { - fprintf(stderr, "%s: cannot specify both -g and -t\n", argv[0]); - exit(1); - } - mode = KD_GRAPHICS; - break; - case 't': - if(mode == KD_GRAPHICS) { - fprintf(stderr, "%s: cannot specify both -g and -t\n", argv[0]); - exit(1); - } - mode = KD_TEXT; - break; - case 'n': - new_vc = 1; - break; - case 'c': - close_vc = 1; - break; - case 'v': - switch_vc = atoi(optarg); - break; - case 'p': - printvc |= 1; - break; - case 'o': - printvc |= 2; - break; - case 'h': - fprintf(stderr, "%s [-d <dev>] [-v <vc>] [-gtncpoh]\n" - " -d <dev> Use <dev> instead of /dev/tty0\n" - " -v <vc> Switch to virtual console <vc>\n" - " -g Switch to graphics mode\n" - " -t Switch to text mode\n" - " -n Create and switch to new virtual console\n" - " -c Close unused virtual consoles\n" - " -p Print new virtual console\n" - " -o Print old virtual console\n" - " -h Print help\n", argv[0]); - return -1; - case '?': - fprintf(stderr, "%s: invalid option -%c\n", - argv[0], optopt); - exit(1); - } - } while (1); - if(mode == -1 && new_vc == 0 && close_vc == 0 && switch_vc == -1 && printvc == 0) { - fprintf(stderr,"%s [-d <dev>] [-v <vc>] [-gtncpoh]\n", argv[0]); - return -1; - } - - fd = open(ttydev, O_RDWR | O_SYNC); - if (fd < 0) { - fprintf(stderr, "cannot open %s\n", ttydev); - return -1; - } - - if ((printvc && !new_vc) || (printvc & 2)) { - struct vt_stat vs; - - res = ioctl(fd, VT_GETSTATE, &vs); - if (res < 0) { - fprintf(stderr, "ioctl(vcfd, VT_GETSTATE, &vs) failed, %d\n", res); - } - printf("%d\n", vs.v_active); - } - - if (new_vc) { - int vtnum; - res = ioctl(fd, VT_OPENQRY, &vtnum); - if (res < 0 || vtnum == -1) { - fprintf(stderr, "ioctl(vcfd, VT_OPENQRY, &vtnum) failed, res %d, vtnum %d\n", res, vtnum); - } - switch_vc = vtnum; - } - if (switch_vc != -1) { - pthread_t thread; - pthread_attr_t attr; - activate_thread_switch_vc = switch_vc; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - pthread_create(&thread, &attr, activate_thread, (void*)fd); - - do { - res = ioctl(fd, VT_WAITACTIVE, (void*)switch_vc); - } while(res < 0 && errno == EINTR); - activate_thread_switch_vc = -1; - if (res < 0) { - fprintf(stderr, "ioctl( vcfd, VT_WAITACTIVE, vtnum) failed, %d %d %s for %d\n", res, errno, strerror(errno), switch_vc); - } - if(printvc & 1) - printf("%d\n", switch_vc); - - close(fd); - fd = open(ttydev, O_RDWR | O_SYNC); - if (fd < 0) { - fprintf(stderr, "cannot open %s\n", ttydev); - return -1; - } - } - if (close_vc) { - res = ioctl(fd, VT_DISALLOCATE, 0); - if (res < 0) { - fprintf(stderr, "ioctl(vcfd, VT_DISALLOCATE, 0) failed, %d\n", res); - } - } - if (mode != -1) { - if (ioctl(fd, KDSETMODE, (void*)mode) < 0) { - fprintf(stderr, "KDSETMODE %d failed\n", mode); - return -1; - } - } - return 0; -} diff --git a/toolbox/swapon.c b/toolbox/swapon.c index afa6868..a810b3d 100644 --- a/toolbox/swapon.c +++ b/toolbox/swapon.c @@ -5,12 +5,6 @@ #include <asm/page.h> #include <sys/swap.h> -/* XXX These need to be obtained from kernel headers. See b/9336527 */ -#define SWAP_FLAG_PREFER 0x8000 -#define SWAP_FLAG_PRIO_MASK 0x7fff -#define SWAP_FLAG_PRIO_SHIFT 0 -#define SWAP_FLAG_DISCARD 0x10000 - void usage(char *name) { fprintf(stderr, "Usage: %s [-p prio] <filename>\n" diff --git a/toolbox/uptime.c b/toolbox/uptime.c index 1c312b0..3fb4606 100644 --- a/toolbox/uptime.c +++ b/toolbox/uptime.c @@ -54,24 +54,35 @@ static void format_time(int time, char* buffer) { sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds); } -int64_t elapsedRealtime() +static int elapsedRealtimeAlarm(struct timespec *ts) { - struct timespec ts; int fd, result; fd = open("/dev/alarm", O_RDONLY); if (fd < 0) return fd; - result = ioctl(fd, ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME), &ts); - close(fd); + result = ioctl(fd, ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME), ts); + close(fd); + + return result; +} + +int64_t elapsedRealtime() +{ + struct timespec ts; + + int result = elapsedRealtimeAlarm(&ts); + if (result < 0) + result = clock_gettime(CLOCK_BOOTTIME, &ts); if (result == 0) return ts.tv_sec; return -1; } -int uptime_main(int argc, char *argv[]) +int uptime_main(int argc __attribute__((unused)), + char *argv[] __attribute__((unused))) { float up_time, idle_time; char up_string[100], idle_string[100], sleep_string[100]; |