Some updates for better portability.
-Erik
This commit is contained in:
parent
969f9b0486
commit
499f65fb98
18
Makefile
18
Makefile
@ -31,6 +31,12 @@ DODEBUG = false
|
|||||||
# If you want a static binary, turn this on.
|
# If you want a static binary, turn this on.
|
||||||
DOSTATIC = false
|
DOSTATIC = false
|
||||||
|
|
||||||
|
# To compile vs an alternative libc, you may need to use/adjust
|
||||||
|
# the following lines to meet your needs. This is how I did it...
|
||||||
|
#CFLAGS+=-nostdinc -I/home/andersen/CVS/uC-libc/include -I/usr/include/linux
|
||||||
|
#LDFLAGS+=-nostdlib -L/home/andersen/CVS/libc.a
|
||||||
|
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
# use '-Os' optimization if available, else use -O2
|
# use '-Os' optimization if available, else use -O2
|
||||||
@ -43,10 +49,6 @@ ifndef $(STRIPTOOL)
|
|||||||
STRIPTOOL = strip
|
STRIPTOOL = strip
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# TODO: Try compiling vs other libcs.
|
|
||||||
# See what -nostdinc and -nostdlib do for them.
|
|
||||||
# also try --prefix=/usr/my-libc-stuff
|
|
||||||
|
|
||||||
# -D_GNU_SOURCE is needed because environ is used in init.c
|
# -D_GNU_SOURCE is needed because environ is used in init.c
|
||||||
ifeq ($(DODEBUG),true)
|
ifeq ($(DODEBUG),true)
|
||||||
CFLAGS += -Wall -g -D_GNU_SOURCE
|
CFLAGS += -Wall -g -D_GNU_SOURCE
|
||||||
@ -65,11 +67,10 @@ else
|
|||||||
#want to give it a shot...
|
#want to give it a shot...
|
||||||
#
|
#
|
||||||
#ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
|
#ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
|
||||||
# -o /dev/null -xc /dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1)
|
# -o /dev/null -xc /dev/null 2>/dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1)
|
||||||
# CFLAGS += -ffunction-sections -fdata-sections -DFUNCTION_SECTIONS
|
# CFLAGS += -ffunction-sections -fdata-sections
|
||||||
# LDFLAGS += --gc-sections
|
# LDFLAGS += --gc-sections
|
||||||
#endif
|
#endif
|
||||||
#
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -77,6 +78,7 @@ ifndef $(PREFIX)
|
|||||||
PREFIX = `pwd`/_install
|
PREFIX = `pwd`/_install
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
LIBRARIES =
|
LIBRARIES =
|
||||||
OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
|
OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
|
||||||
CFLAGS += -DBB_VER='"$(VERSION)"'
|
CFLAGS += -DBB_VER='"$(VERSION)"'
|
||||||
|
@ -181,7 +181,7 @@ int date_main(int argc, char **argv)
|
|||||||
set_time = 1;
|
set_time = 1;
|
||||||
if (date_str != NULL)
|
if (date_str != NULL)
|
||||||
usage(date_usage);
|
usage(date_usage);
|
||||||
date_str = optarg;
|
date_str = *argv;
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
utc = 1;
|
utc = 1;
|
||||||
@ -192,7 +192,7 @@ int date_main(int argc, char **argv)
|
|||||||
use_arg = 1;
|
use_arg = 1;
|
||||||
if (date_str != NULL)
|
if (date_str != NULL)
|
||||||
usage(date_usage);
|
usage(date_usage);
|
||||||
date_str = optarg;
|
date_str = *argv;
|
||||||
break;
|
break;
|
||||||
case '-':
|
case '-':
|
||||||
usage(date_usage);
|
usage(date_usage);
|
||||||
|
4
date.c
4
date.c
@ -181,7 +181,7 @@ int date_main(int argc, char **argv)
|
|||||||
set_time = 1;
|
set_time = 1;
|
||||||
if (date_str != NULL)
|
if (date_str != NULL)
|
||||||
usage(date_usage);
|
usage(date_usage);
|
||||||
date_str = optarg;
|
date_str = *argv;
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
utc = 1;
|
utc = 1;
|
||||||
@ -192,7 +192,7 @@ int date_main(int argc, char **argv)
|
|||||||
use_arg = 1;
|
use_arg = 1;
|
||||||
if (date_str != NULL)
|
if (date_str != NULL)
|
||||||
usage(date_usage);
|
usage(date_usage);
|
||||||
date_str = optarg;
|
date_str = *argv;
|
||||||
break;
|
break;
|
||||||
case '-':
|
case '-':
|
||||||
usage(date_usage);
|
usage(date_usage);
|
||||||
|
35
dutmp.c
35
dutmp.c
@ -8,22 +8,20 @@
|
|||||||
* versions of 'who', 'last', etc. IP Addr is output in hex,
|
* versions of 'who', 'last', etc. IP Addr is output in hex,
|
||||||
* little endian on x86.
|
* little endian on x86.
|
||||||
*
|
*
|
||||||
* made against libc6
|
* Modified to support all sort of libcs by
|
||||||
|
* Erik Andersen <andersen@lineo.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include <stdio.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#define BB_DECLARE_EXTERN
|
#define BB_DECLARE_EXTERN
|
||||||
#define bb_need_io_error
|
#define bb_need_io_error
|
||||||
#include "messages.c"
|
#include "messages.c"
|
||||||
|
|
||||||
#if defined(__GLIBC__)
|
|
||||||
#include <utmp.h>
|
#include <utmp.h>
|
||||||
#else
|
|
||||||
#include <utmp-wrap.h>
|
|
||||||
#define utmp new_utmp
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static const char dutmp_usage[] = "dutmp [FILE]\n"
|
static const char dutmp_usage[] = "dutmp [FILE]\n"
|
||||||
@ -36,27 +34,26 @@ static const char dutmp_usage[] = "dutmp [FILE]\n"
|
|||||||
extern int dutmp_main(int argc, char **argv)
|
extern int dutmp_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
FILE *f;
|
int file;
|
||||||
struct utmp ut;
|
struct utmp ut;
|
||||||
|
|
||||||
if (argc<2) {
|
if (argc<2) {
|
||||||
f = stdin;
|
file = fileno(stdin);
|
||||||
} else if (*argv[1] == '-' ) {
|
} else if (*argv[1] == '-' ) {
|
||||||
usage(dutmp_usage);
|
usage(dutmp_usage);
|
||||||
} else {
|
} else {
|
||||||
f = fopen(argv[1], "r");
|
file = open(argv[1], O_RDONLY);
|
||||||
if (f == NULL) {
|
if (file < 0) {
|
||||||
fatalError(io_error, argv[1], strerror(errno));
|
fatalError(io_error, argv[1], strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fread(&ut, sizeof(struct utmp), 1, f)) {
|
while (read(file, (void*)&ut, sizeof(struct utmp))) {
|
||||||
printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
|
printf("%d|%d|%s|%s|%s|%s|%s|%lx\n",
|
||||||
ut.ut_type, ut.ut_pid, ut.ut_line,
|
ut.ut_type, ut.ut_pid, ut.ut_line,
|
||||||
ut.ut_id, ut.ut_user, ut.ut_host,
|
ut.ut_id, ut.ut_user, ut.ut_host,
|
||||||
ut.ut_exit.e_termination, ut.ut_exit.e_exit,
|
ctime(&(ut.ut_time)),
|
||||||
ut.ut_session, ut.ut_tv.tv_sec, ut.ut_tv.tv_usec,
|
(long)ut.ut_addr);
|
||||||
ut.ut_addr_v6[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(TRUE);
|
exit(TRUE);
|
||||||
|
@ -8,22 +8,20 @@
|
|||||||
* versions of 'who', 'last', etc. IP Addr is output in hex,
|
* versions of 'who', 'last', etc. IP Addr is output in hex,
|
||||||
* little endian on x86.
|
* little endian on x86.
|
||||||
*
|
*
|
||||||
* made against libc6
|
* Modified to support all sort of libcs by
|
||||||
|
* Erik Andersen <andersen@lineo.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include <stdio.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#define BB_DECLARE_EXTERN
|
#define BB_DECLARE_EXTERN
|
||||||
#define bb_need_io_error
|
#define bb_need_io_error
|
||||||
#include "messages.c"
|
#include "messages.c"
|
||||||
|
|
||||||
#if defined(__GLIBC__)
|
|
||||||
#include <utmp.h>
|
#include <utmp.h>
|
||||||
#else
|
|
||||||
#include <utmp-wrap.h>
|
|
||||||
#define utmp new_utmp
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static const char dutmp_usage[] = "dutmp [FILE]\n"
|
static const char dutmp_usage[] = "dutmp [FILE]\n"
|
||||||
@ -36,27 +34,26 @@ static const char dutmp_usage[] = "dutmp [FILE]\n"
|
|||||||
extern int dutmp_main(int argc, char **argv)
|
extern int dutmp_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
FILE *f;
|
int file;
|
||||||
struct utmp ut;
|
struct utmp ut;
|
||||||
|
|
||||||
if (argc<2) {
|
if (argc<2) {
|
||||||
f = stdin;
|
file = fileno(stdin);
|
||||||
} else if (*argv[1] == '-' ) {
|
} else if (*argv[1] == '-' ) {
|
||||||
usage(dutmp_usage);
|
usage(dutmp_usage);
|
||||||
} else {
|
} else {
|
||||||
f = fopen(argv[1], "r");
|
file = open(argv[1], O_RDONLY);
|
||||||
if (f == NULL) {
|
if (file < 0) {
|
||||||
fatalError(io_error, argv[1], strerror(errno));
|
fatalError(io_error, argv[1], strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fread(&ut, sizeof(struct utmp), 1, f)) {
|
while (read(file, (void*)&ut, sizeof(struct utmp))) {
|
||||||
printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
|
printf("%d|%d|%s|%s|%s|%s|%s|%lx\n",
|
||||||
ut.ut_type, ut.ut_pid, ut.ut_line,
|
ut.ut_type, ut.ut_pid, ut.ut_line,
|
||||||
ut.ut_id, ut.ut_user, ut.ut_host,
|
ut.ut_id, ut.ut_user, ut.ut_host,
|
||||||
ut.ut_exit.e_termination, ut.ut_exit.e_exit,
|
ctime(&(ut.ut_time)),
|
||||||
ut.ut_session, ut.ut_tv.tv_sec, ut.ut_tv.tv_usec,
|
(long)ut.ut_addr);
|
||||||
ut.ut_addr_v6[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(TRUE);
|
exit(TRUE);
|
||||||
|
@ -61,7 +61,7 @@ extern int mt_main(int argc, char **argv)
|
|||||||
struct mtop op;
|
struct mtop op;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if ((argc != 2 && argc != 3) || **(argv + 1) == '-') {
|
if ((argc != 2 && argc != 3) && **(argv + 1) != '-') {
|
||||||
usage(mt_usage);
|
usage(mt_usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user