1 diff -urN busybox.old/include/applets.h busybox.dev/include/applets.h
2 --- busybox.old/include/applets.h 2006-04-05 01:06:29.000000000 +0200
3 +++ busybox.dev/include/applets.h 2006-04-05 01:19:09.000000000 +0200
5 USE_LN(APPLET(ln, ln_main, _BB_DIR_BIN, _BB_SUID_NEVER))
6 USE_LOADFONT(APPLET(loadfont, loadfont_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
7 USE_LOADKMAP(APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN, _BB_SUID_NEVER))
8 +USE_LOCK(APPLET_NOUSAGE(lock, lock_main, _BB_DIR_BIN, _BB_SUID_NEVER))
9 USE_LOGGER(APPLET(logger, logger_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
10 USE_LOGIN(APPLET(login, login_main, _BB_DIR_BIN, _BB_SUID_ALWAYS))
11 USE_LOGNAME(APPLET(logname, logname_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
12 diff -urN busybox.old/miscutils/Config.in busybox.dev/miscutils/Config.in
13 --- busybox.old/miscutils/Config.in 2006-03-22 22:16:24.000000000 +0100
14 +++ busybox.dev/miscutils/Config.in 2006-04-05 01:07:12.000000000 +0200
16 Enables the 'hdparm -d' option to get/set using_dma flag.
17 This is dangerous stuff, so you should probably say N.
23 + Small utility for using locks in scripts
25 config CONFIG_MAKEDEVS
28 diff -urN busybox.old/miscutils/Makefile.in busybox.dev/miscutils/Makefile.in
29 --- busybox.old/miscutils/Makefile.in 2006-03-22 22:16:24.000000000 +0100
30 +++ busybox.dev/miscutils/Makefile.in 2006-04-05 01:10:50.000000000 +0200
32 MISCUTILS-$(CONFIG_EJECT) += eject.o
33 MISCUTILS-$(CONFIG_HDPARM) += hdparm.o
34 MISCUTILS-$(CONFIG_LAST) += last.o
35 +MISCUTILS-$(CONFIG_LOCK) += lock.o
36 MISCUTILS-${CONFIG_LESS} += less.o
37 MISCUTILS-$(CONFIG_MAKEDEVS) += makedevs.o
38 MISCUTILS-$(CONFIG_MOUNTPOINT) += mountpoint.o
39 diff -urN busybox.old/miscutils/lock.c busybox.dev/miscutils/lock.c
40 --- busybox.old/miscutils/lock.c 1970-01-01 01:00:00.000000000 +0100
41 +++ busybox.dev/miscutils/lock.c 2006-04-05 01:07:12.000000000 +0200
43 +#include <sys/types.h>
44 +#include <sys/file.h>
45 +#include <sys/stat.h>
52 +static int unlock = 0;
53 +static int shared = 0;
54 +static int waitonly = 0;
58 +static void usage(char *name)
60 + fprintf(stderr, "Usage: %s [-suw] <filename>\n"
61 + " -s Use shared locking\n"
63 + " -w Wait for the lock to become free, don't acquire lock\n"
68 +static void exit_unlock(int sig)
75 +static int do_unlock(void)
80 + if ((f = fopen(file, "r")) == NULL)
83 + fscanf(f, "%d", &i);
92 +static int do_lock(void)
97 + if ((fd = open(file, O_RDWR | O_CREAT, 0700)) < 0) {
98 + fprintf(stderr, "Can't open %s\n", file);
102 + if (flock(fd, (shared ? LOCK_SH : LOCK_EX)) < 0) {
103 + fprintf(stderr, "Can't lock %s\n", file);
113 + signal(SIGKILL, exit_unlock);
114 + signal(SIGTERM, exit_unlock);
115 + signal(SIGINT, exit_unlock);
123 + lseek(fd, 0, SEEK_SET);
125 + sprintf(pidstr, "%d\n", pid);
126 + write(fd, pidstr, strlen(pidstr));
135 +int main(int argc, char **argv)
137 +int lock_main(int argc, char **argv)
140 + char **args = &argv[1];
143 + while ((*args != NULL) && (*args)[0] == '-') {
145 + while (*(++ch) > 0) {
167 + return do_unlock();