More stuff

-Erik
This commit is contained in:
Erik Andersen 2000-05-02 00:07:56 +00:00
parent 3c1217cfad
commit 5afc864422
13 changed files with 68 additions and 34 deletions

View File

@ -16,7 +16,8 @@
* tail can now accept -<num> commands (e.g. -10) for better * tail can now accept -<num> commands (e.g. -10) for better
compatibility with the standard tail command compatibility with the standard tail command
* added a simple id implementation; doesn't support supp. groups yet * added a simple id implementation; doesn't support supp. groups yet
* logname used getlogin(3), which uses utmp under the hood. Now it behaves. * logname used getlogin(3) which uses utmp under the hood. Now it behaves.
* whoami used getpwuid(3) which uses libc NSS. Now it behaves.
* Due to the license change, I can now use minix code. Minux tr replaces * Due to the license change, I can now use minix code. Minux tr replaces
the BSD derived tr, saving 4k and eliminating bsearch(3) from the the BSD derived tr, saving 4k and eliminating bsearch(3) from the
list of used Libc symbols. list of used Libc symbols.

View File

@ -68,7 +68,8 @@ ifndef $(STRIPTOOL)
STRIPTOOL = strip STRIPTOOL = strip
endif endif
#also to try -- use --prefix=/usr/my-libc2.0.7-stuff # TODO: Try compiling vs other libcs. See what -nostdinc and -nostdlib do for that.
# 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)
@ -78,8 +79,6 @@ ifeq ($(DODEBUG),true)
else else
CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
LDFLAGS = -s LDFLAGS = -s
#CFLAGS += -nostdinc -I/home/andersen/apps/newlib/src/newlib/libc/include -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
#LDFLAGS = -nostdlib -s -L/home/andersen/apps/newlib/src/newlib/libc.a
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG) STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
#Only staticly link when _not_ debugging #Only staticly link when _not_ debugging
ifeq ($(DOSTATIC),true) ifeq ($(DOSTATIC),true)

33
TODO
View File

@ -47,6 +47,39 @@ for GNU libc to be so big. I'm sure it can be a lot better.
(BTW, this is more informative if BB_FEATURE_NFSMOUNT is turned off...) (BTW, this is more informative if BB_FEATURE_NFSMOUNT is turned off...)
Most wanted list:
[andersen@slag busybox]$ grep -l getgroups *.[ch]
test.c
Policy violation. getgroups uses libc nss, which is unlikely
to be present in an embedded system.
[andersen@slag busybox]$ grep -l getopt *.[ch]
dmesg.c
gunzip.c
hostname.c
mkfs_minix.c
printf.c
sfdisk.c
This includes the symbols:
getopt_long
optarg
opterr
optind
To be replaced with a non-getopt parser.
[andersen@slag busybox]$ grep -l glob *.[ch]
gunzip.c
gzip.c
sh.c
tar.c
telnet.c
Can check_wildcard_match() from utility.c do this job?
----------------------- -----------------------

View File

@ -63,7 +63,6 @@
#define BB_MNC #define BB_MNC
#define BB_MORE #define BB_MORE
#define BB_MOUNT #define BB_MOUNT
#define BB_NFSMOUNT
#define BB_MT #define BB_MT
#define BB_NSLOOKUP #define BB_NSLOOKUP
#define BB_PING #define BB_PING
@ -185,6 +184,9 @@
// Enable support for remounting filesystems // Enable support for remounting filesystems
#define BB_FEATURE_REMOUNT #define BB_FEATURE_REMOUNT
// //
// Enable support for mounting remote NFS volumes
//#define BB_FEATURE_NFSMOUNT
//
// Enable support for creation of tar files. // Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE #define BB_FEATURE_TAR_CREATE
// //
@ -253,3 +255,7 @@
#endif #endif
#endif #endif
// //
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//

View File

@ -2,8 +2,10 @@
/* /*
* Mini tr implementation for busybox * Mini tr implementation for busybox
* *
* This version of tr is adapted from Minix tr * Copyright (c) Michiel Huisjes
* Author: Michiel Huisjes *
* This version of tr is adapted from Minix tr and was modified
* by Erik Andersen <andersee@debian.org> to be used in busybox.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

View File

@ -29,16 +29,15 @@ static const char whoami_usage[] = "whoami\n\n"
extern int whoami_main(int argc, char **argv) extern int whoami_main(int argc, char **argv)
{ {
struct passwd *pw; char *user = xmalloc(9);
uid_t uid; uid_t uid = geteuid();
if (argc > 1) if (argc > 1)
usage(whoami_usage); usage(whoami_usage);
uid = geteuid(); my_getpwuid(user, uid);
pw = getpwuid(uid); if (user) {
if (pw) { puts(user);
puts(pw->pw_name);
exit(TRUE); exit(TRUE);
} }
fprintf(stderr, "%s: cannot find username for UID %u\n", argv[0], fprintf(stderr, "%s: cannot find username for UID %u\n", argv[0],

View File

@ -25,6 +25,7 @@
#define utmp new_utmp #define utmp new_utmp
#endif #endif
static const char dutmp_usage[] = "dutmp [FILE]\n\n" static const char dutmp_usage[] = "dutmp [FILE]\n\n"
"Dump utmp file format (pipe delimited) from FILE\n" "Dump utmp file format (pipe delimited) from FILE\n"
"or stdin to stdout. (i.e. 'dutmp /var/run/utmp')\n"; "or stdin to stdout. (i.e. 'dutmp /var/run/utmp')\n";

View File

@ -25,6 +25,7 @@
#define utmp new_utmp #define utmp new_utmp
#endif #endif
static const char dutmp_usage[] = "dutmp [FILE]\n\n" static const char dutmp_usage[] = "dutmp [FILE]\n\n"
"Dump utmp file format (pipe delimited) from FILE\n" "Dump utmp file format (pipe delimited) from FILE\n"
"or stdin to stdout. (i.e. 'dutmp /var/run/utmp')\n"; "or stdin to stdout. (i.e. 'dutmp /var/run/utmp')\n";

View File

@ -135,7 +135,7 @@ static struct hostent *hostent_fprint(struct hostent *host, FILE * dst)
fprintf(dst, "Name: %s\n", host->h_name); fprintf(dst, "Name: %s\n", host->h_name);
addr_list_fprint(host->h_addr_list, dst); addr_list_fprint(host->h_addr_list, dst);
} else { } else {
fprintf(dst, "*** %s\n", hstrerror(h_errno)); fprintf(dst, "*** Unknown host\n");
} }
return host; return host;
} }
@ -173,4 +173,4 @@ int nslookup_main(int argc, char **argv)
exit( TRUE); exit( TRUE);
} }
/* $Id: nslookup.c,v 1.7 2000/04/15 16:34:54 erik Exp $ */ /* $Id: nslookup.c,v 1.8 2000/05/02 00:07:56 erik Exp $ */

View File

@ -135,7 +135,7 @@ static struct hostent *hostent_fprint(struct hostent *host, FILE * dst)
fprintf(dst, "Name: %s\n", host->h_name); fprintf(dst, "Name: %s\n", host->h_name);
addr_list_fprint(host->h_addr_list, dst); addr_list_fprint(host->h_addr_list, dst);
} else { } else {
fprintf(dst, "*** %s\n", hstrerror(h_errno)); fprintf(dst, "*** Unknown host\n");
} }
return host; return host;
} }
@ -173,4 +173,4 @@ int nslookup_main(int argc, char **argv)
exit( TRUE); exit( TRUE);
} }
/* $Id: nslookup.c,v 1.7 2000/04/15 16:34:54 erik Exp $ */ /* $Id: nslookup.c,v 1.8 2000/05/02 00:07:56 erik Exp $ */

6
tr.c
View File

@ -2,8 +2,10 @@
/* /*
* Mini tr implementation for busybox * Mini tr implementation for busybox
* *
* This version of tr is adapted from Minix tr * Copyright (c) Michiel Huisjes
* Author: Michiel Huisjes *
* This version of tr is adapted from Minix tr and was modified
* by Erik Andersen <andersee@debian.org> to be used in busybox.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

View File

@ -1037,15 +1037,6 @@ extern int replace_match(char *haystack, char *needle, char *newNeedle,
while (where != NULL) { while (where != NULL) {
foundOne++; foundOne++;
strcpy(oldhayStack, haystack); strcpy(oldhayStack, haystack);
#if 0
if (strlen(newNeedle) > strlen(needle)) {
haystack =
(char *) realloc(haystack,
(unsigned) (strlen(haystack) -
strlen(needle) +
strlen(newNeedle)));
}
#endif
for (slider = haystack, slider1 = oldhayStack; slider != where; for (slider = haystack, slider1 = oldhayStack; slider != where;
slider++, slider1++); slider++, slider1++);
*slider = 0; *slider = 0;

View File

@ -29,16 +29,15 @@ static const char whoami_usage[] = "whoami\n\n"
extern int whoami_main(int argc, char **argv) extern int whoami_main(int argc, char **argv)
{ {
struct passwd *pw; char *user = xmalloc(9);
uid_t uid; uid_t uid = geteuid();
if (argc > 1) if (argc > 1)
usage(whoami_usage); usage(whoami_usage);
uid = geteuid(); my_getpwuid(user, uid);
pw = getpwuid(uid); if (user) {
if (pw) { puts(user);
puts(pw->pw_name);
exit(TRUE); exit(TRUE);
} }
fprintf(stderr, "%s: cannot find username for UID %u\n", argv[0], fprintf(stderr, "%s: cannot find username for UID %u\n", argv[0],