Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Added sfdisk. Ststic-ified a bunch of stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBAndersen committed Oct 19, 1999
1 parent a3f0907 commit e77ae3a
Show file tree
Hide file tree
Showing 61 changed files with 3,997 additions and 472 deletions.
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ Please see the top of the source files for more precise indivigual
copyright and license info.

This program suite may be distributed under the GNU General Public License.


Please send patches, suggestions, insults, and bribes to <andersee@debian.org>.

6 changes: 5 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ using C++ comments (//)
After the build is complete a busybox.links file is generated to allow
you to easily make the sym/hard links to the busybox binary.

Note the modular system is Makefile based, and purposly very
Note the modular system is Makefile based, and purposely very
simplistic. It does no dependency checking. That is left for you
to figure out by trial and error.

Please feed patches back to:
Erik Andersen <andersee@deban.org>
and
Bruce Perens <bruce@perens.com>
and
Dave Cinege <dcinege@psychosis.com>
and:
Enrique Zanardi <ezanardi@ull.es>
8 changes: 6 additions & 2 deletions applets/busybox.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static const struct Applet applets[] = {
{"block_device", block_device_main},
#endif
#ifdef BB_CAT //bin
{"cat", cat_more_main},
{"cat", cat_main},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP //bin
{"chmod", chmod_chown_chgrp_main},
Expand Down Expand Up @@ -43,7 +43,7 @@ static const struct Applet applets[] = {
{"dmesg", dmesg_main},
#endif
#ifdef BB_DUTMP //usr/sbin
{"dutmp", cat_more_main},
{"dutmp", dutmp_main},
#endif
#ifdef BB_FDFLUSH //bin
{"fdflush", fdflush_main},
Expand Down Expand Up @@ -123,6 +123,10 @@ static const struct Applet applets[] = {
#ifdef BB_RMDIR //bin
{"rmdir", rmdir_main},
#endif
#ifdef BB_SFDISK //sbin
{"fdisk", sfdisk_main},
{"sfdisk", sfdisk_main},
#endif
#ifdef BB_SLEEP //bin
{"sleep", sleep_main},
#endif
Expand Down
18 changes: 9 additions & 9 deletions archival/gzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#error you need zcat to have gzip support!
#endif

const char gzip_usage[] = "gzip\nignores all command line arguments\ncompress stdin to stdout with -9 compression\n";
static const char gzip_usage[] = "gzip\nignores all command line arguments\ncompress stdin to stdout with -9 compression\n";

/* gzip.h -- common declarations for all gzip modules
* Copyright (C) 1992-1993 Jean-loup Gailly.
Expand Down Expand Up @@ -380,7 +380,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */
# undef LZW
#endif

/* $Id: gzip.c,v 1.3 1999/10/16 15:48:40 andersen Exp $ */
/* $Id: gzip.c,v 1.4 1999/10/19 20:03:34 andersen Exp $ */
/* tailor.h -- target dependent definitions
* Copyright (C) 1992-1993 Jean-loup Gailly.
* This is free software; you can redistribute it and/or modify it under the
Expand All @@ -391,7 +391,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */
* The target dependent functions should be defined in tailor.c.
*/

/* $Id: gzip.c,v 1.3 1999/10/16 15:48:40 andersen Exp $ */
/* $Id: gzip.c,v 1.4 1999/10/19 20:03:34 andersen Exp $ */

#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
Expand Down Expand Up @@ -767,7 +767,7 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */
#endif

#ifdef RCSID
static char rcsid[] = "$Id: gzip.c,v 1.3 1999/10/16 15:48:40 andersen Exp $";
static char rcsid[] = "$Id: gzip.c,v 1.4 1999/10/19 20:03:34 andersen Exp $";
#endif

/* ===========================================================================
Expand Down Expand Up @@ -976,7 +976,7 @@ void copy_block(buf, len, header)
#include <stdio.h>

#ifdef RCSID
static char rcsid[] = "$Id: gzip.c,v 1.3 1999/10/16 15:48:40 andersen Exp $";
static char rcsid[] = "$Id: gzip.c,v 1.4 1999/10/19 20:03:34 andersen Exp $";
#endif

/* ===========================================================================
Expand Down Expand Up @@ -1592,7 +1592,7 @@ ulg deflate()
*/

#ifdef RCSID
static char rcsid[] = "$Id: gzip.c,v 1.3 1999/10/16 15:48:40 andersen Exp $";
static char rcsid[] = "$Id: gzip.c,v 1.4 1999/10/19 20:03:34 andersen Exp $";
#endif

#include <ctype.h>
Expand Down Expand Up @@ -1925,7 +1925,7 @@ local void do_exit(int exitcode)
#include <ctype.h>

#ifdef RCSID
static char rcsid[] = "$Id: gzip.c,v 1.3 1999/10/16 15:48:40 andersen Exp $";
static char rcsid[] = "$Id: gzip.c,v 1.4 1999/10/19 20:03:34 andersen Exp $";
#endif

/* ===========================================================================
Expand Down Expand Up @@ -2943,7 +2943,7 @@ local void set_file_type()
*/

#ifdef RCSID
static char rcsid[] = "$Id: gzip.c,v 1.3 1999/10/16 15:48:40 andersen Exp $";
static char rcsid[] = "$Id: gzip.c,v 1.4 1999/10/19 20:03:34 andersen Exp $";
#endif

#include <ctype.h>
Expand Down Expand Up @@ -3142,7 +3142,7 @@ void display_ratio(num, den, file)
*/

#ifdef RCSID
static char rcsid[] = "$Id: gzip.c,v 1.3 1999/10/16 15:48:40 andersen Exp $";
static char rcsid[] = "$Id: gzip.c,v 1.4 1999/10/19 20:03:34 andersen Exp $";
#endif

#include <ctype.h>
Expand Down
17 changes: 7 additions & 10 deletions archival/tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,22 @@


#include "internal.h"
#include <stdio.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>

#ifdef BB_TAR

const char tar_usage[] =
static const char tar_usage[] =
"Create, extract, or list files from a TAR file\n\n"
"usage: tar -[cxtvOf] [tarFileName] [FILE] ...\n"
"\tc=create, x=extract, t=list contents, v=verbose,\n"
"\tO=extract to stdout, f=tarfile or \"-\" for stdin\n";



#include <stdio.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>

/*
* Tar file constants.
*/
Expand Down Expand Up @@ -1151,5 +1149,4 @@ wantFileName (const char *fileName, int fileCount, char **fileTable)



#endif
/* END CODE */
8 changes: 6 additions & 2 deletions busybox.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static const struct Applet applets[] = {
{"block_device", block_device_main},
#endif
#ifdef BB_CAT //bin
{"cat", cat_more_main},
{"cat", cat_main},
#endif
#ifdef BB_CHMOD_CHOWN_CHGRP //bin
{"chmod", chmod_chown_chgrp_main},
Expand Down Expand Up @@ -43,7 +43,7 @@ static const struct Applet applets[] = {
{"dmesg", dmesg_main},
#endif
#ifdef BB_DUTMP //usr/sbin
{"dutmp", cat_more_main},
{"dutmp", dutmp_main},
#endif
#ifdef BB_FDFLUSH //bin
{"fdflush", fdflush_main},
Expand Down Expand Up @@ -123,6 +123,10 @@ static const struct Applet applets[] = {
#ifdef BB_RMDIR //bin
{"rmdir", rmdir_main},
#endif
#ifdef BB_SFDISK //sbin
{"fdisk", sfdisk_main},
{"sfdisk", sfdisk_main},
#endif
#ifdef BB_SLEEP //bin
{"sleep", sleep_main},
#endif
Expand Down
1 change: 1 addition & 0 deletions busybox.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#define BB_REBOOT
#define BB_RM
#define BB_RMDIR
#define BB_SFDISK
#define BB_SLEEP
#define BB_SWAPONOFF
#define BB_SYNC
Expand Down
2 changes: 1 addition & 1 deletion cat.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static void print_file( FILE *file)
fflush(stdout);
}

extern int cat_more_main(int argc, char **argv)
extern int cat_main(int argc, char **argv)
{
FILE *file;

Expand Down
168 changes: 168 additions & 0 deletions chmod_chown_chgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,171 @@ int chmod_chown_chgrp_main(int argc, char **argv)
exit(TRUE);
}












#ifdef fooo















#include "internal.h"
#include <pwd.h>
#include <grp.h>
#include <string.h>
#include <stdio.h>

int my_getid(const char *filename, const char *name, uid_t *id)
{
FILE *stream;
uid_t rid;
char *rname, *start, *end, buf[128];

stream=fopen(filename,"r");

while (fgets (buf, 128, stream) != NULL) {
if (buf[0] == '#')
continue;

start = buf;
end = strchr (start, ':');
if (end == NULL)
continue;
*end = '\0';
rname = start;

start = end + 1;
end = strchr (start, ':');
if (end == NULL)
continue;

start = end + 1;
rid = (uid_t) strtol (start, &end, 10);
if (end == start)
continue;

if (name) {
if (0 == strcmp(rname, name)) {
*id=rid;
return 0;
}
} else {
if ( *id == rid )
return 0;
}
}
fclose(stream);
return -1;
}

int
my_getpwuid(uid_t *uid)
{
return my_getid("/etc/passwd", NULL, uid);
}

int
my_getpwnam(char *name, uid_t *uid)
{
return my_getid("/etc/passwd", name, uid);
}

int
my_getgrgid(gid_t *gid)
{
return my_getid("/etc/group", NULL, gid);
}

int
my_getgrnam(char *name, gid_t *gid)
{
return my_getid("/etc/group", name, gid);
}

const char chown_usage[] = "chown [-R] user-name file [file ...]\n"
"\n\tThe group list is kept in the file /etc/groups.\n\n"
"\t-R:\tRecursively change the mode of all files and directories\n"
"\t\tunder the argument directory.";

int
parse_user_name(const char * s, struct FileInfo * i)
{
char * dot = strchr(s, '.');
char * end = NULL;
uid_t id = 0;

if (! dot )
dot = strchr(s, ':');

if ( dot )
*dot = '\0';

if ( my_getpwnam(s,&id) == -1 ) {
id = strtol(s,&end,10);
if ((*end != '\0') || ( my_getpwuid(&id) == -1 )) {
fprintf(stderr, "%s: no such user.\n", s);
return 1;
}
}
i->userID = id;

if ( dot ) {
if ( my_getgrnam(++dot,&id) == -1 ) {
id = strtol(dot,&end,10);
if ((*end != '\0') || ( my_getgrgid(&id) == -1 )) {
fprintf(stderr, "%s: no such group.\n", dot);
return 1;
}
}
i->groupID = id;
i->changeGroupID = 1;
}
return 0;
}

extern int
chown_main(struct FileInfo * i, int argc, char * * argv)
{
int status;

while ( argc >= 3 && strcmp("-R", argv[1]) == 0 ) {
i->recursive = 1;
argc--;
argv++;
}

if ( (status = parse_user_name(argv[1], i)) != 0 )
return status;

argv++;
argc--;

i->changeUserID = 1;
i->complainInPostProcess = 1;

return monadic_main(i, argc, argv);
}




#endif
Loading

0 comments on commit e77ae3a

Please sign in to comment.