1 # Copyright (C) 2006 OpenWrt.org
3 # This is free software, licensed under the GNU General Public License v2.
4 # See /LICENSE for more information.
6 diff -ruN busybox-1.2.0-old/include/applets.h busybox-1.2.0-new/include/applets.h
7 --- busybox-1.2.0-old/include/applets.h 2006-07-31 11:21:00.000000000 +0200
8 +++ busybox-1.2.0-new/include/applets.h 2006-08-01 10:21:15.000000000 +0200
10 USE_LN(APPLET(ln, _BB_DIR_BIN, _BB_SUID_NEVER))
11 USE_LOADFONT(APPLET(loadfont, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
12 USE_LOADKMAP(APPLET(loadkmap, _BB_DIR_SBIN, _BB_SUID_NEVER))
13 +USE_LOCK(APPLET_NOUSAGE(lock, lock, _BB_DIR_BIN, _BB_SUID_NEVER))
14 USE_LOGGER(APPLET(logger, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
15 USE_LOGIN(APPLET(login, _BB_DIR_BIN, _BB_SUID_ALWAYS))
16 USE_LOGNAME(APPLET(logname, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
17 diff -ruN busybox-1.2.0-old/miscutils/Config.in busybox-1.2.0-new/miscutils/Config.in
18 --- busybox-1.2.0-old/miscutils/Config.in 2006-07-01 00:42:09.000000000 +0200
19 +++ busybox-1.2.0-new/miscutils/Config.in 2006-08-01 10:21:15.000000000 +0200
21 Enables the 'hdparm -d' option to get/set using_dma flag.
22 This is dangerous stuff, so you should probably say N.
28 + Small utility for using locks in scripts
30 config CONFIG_MAKEDEVS
33 diff -ruN busybox-1.2.0-old/miscutils/lock.c busybox-1.2.0-new/miscutils/lock.c
34 --- busybox-1.2.0-old/miscutils/lock.c 1970-01-01 01:00:00.000000000 +0100
35 +++ busybox-1.2.0-new/miscutils/lock.c 2006-08-01 10:21:15.000000000 +0200
38 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
40 + * This is free software, licensed under the GNU General Public License v2.
42 +#include <sys/types.h>
43 +#include <sys/file.h>
44 +#include <sys/stat.h>
51 +static int unlock = 0;
52 +static int shared = 0;
53 +static int waitonly = 0;
57 +static void usage(char *name)
59 + fprintf(stderr, "Usage: %s [-suw] <filename>\n"
60 + " -s Use shared locking\n"
62 + " -w Wait for the lock to become free, don't acquire lock\n"
67 +static void exit_unlock(int sig)
74 +static int do_unlock(void)
79 + if ((f = fopen(file, "r")) == NULL)
82 + fscanf(f, "%d", &i);
91 +static int do_lock(void)
96 + if ((fd = open(file, O_RDWR | O_CREAT, 0700)) < 0) {
97 + fprintf(stderr, "Can't open %s\n", file);
101 + if (flock(fd, (shared ? LOCK_SH : LOCK_EX)) < 0) {
102 + fprintf(stderr, "Can't lock %s\n", file);
112 + signal(SIGKILL, exit_unlock);
113 + signal(SIGTERM, exit_unlock);
114 + signal(SIGINT, exit_unlock);
122 + lseek(fd, 0, SEEK_SET);
124 + sprintf(pidstr, "%d\n", pid);
125 + write(fd, pidstr, strlen(pidstr));
134 +int main(int argc, char **argv)
136 +int lock_main(int argc, char **argv)
139 + char **args = &argv[1];
142 + while ((*args != NULL) && (*args)[0] == '-') {
144 + while (*(++ch) > 0) {
166 + return do_unlock();
170 diff -ruN busybox-1.2.0-old/miscutils/Makefile.in busybox-1.2.0-new/miscutils/Makefile.in
171 --- busybox-1.2.0-old/miscutils/Makefile.in 2006-07-01 00:42:09.000000000 +0200
172 +++ busybox-1.2.0-new/miscutils/Makefile.in 2006-08-01 10:21:15.000000000 +0200
174 MISCUTILS-$(CONFIG_EJECT) += eject.o
175 MISCUTILS-$(CONFIG_HDPARM) += hdparm.o
176 MISCUTILS-$(CONFIG_LAST) += last.o
177 +MISCUTILS-$(CONFIG_LOCK) += lock.o
178 MISCUTILS-${CONFIG_LESS} += less.o
179 MISCUTILS-$(CONFIG_MAKEDEVS) += makedevs.o
180 MISCUTILS-$(CONFIG_MOUNTPOINT) += mountpoint.o