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 | O_EXCL, 0700)) < 0) {
97 + if ((fd = open(file, O_RDWR)) < 0) {
98 + fprintf(stderr, "Can't open %s\n", file);
103 + if (flock(fd, (shared ? LOCK_SH : LOCK_EX)) < 0) {
104 + fprintf(stderr, "Can't lock %s\n", file);
114 + signal(SIGKILL, exit_unlock);
115 + signal(SIGTERM, exit_unlock);
116 + signal(SIGINT, exit_unlock);
124 + lseek(fd, 0, SEEK_SET);
126 + sprintf(pidstr, "%d\n", pid);
127 + write(fd, pidstr, strlen(pidstr));
136 +int main(int argc, char **argv)
138 +int lock_main(int argc, char **argv)
141 + char **args = &argv[1];
144 + while ((*args != NULL) && (*args)[0] == '-') {
146 + while (*(++ch) > 0) {
168 + return do_unlock();
172 diff -ruN busybox-1.2.0-old/miscutils/Makefile.in busybox-1.2.0-new/miscutils/Makefile.in
173 --- busybox-1.2.0-old/miscutils/Makefile.in 2006-07-01 00:42:09.000000000 +0200
174 +++ busybox-1.2.0-new/miscutils/Makefile.in 2006-08-01 10:21:15.000000000 +0200
176 MISCUTILS-$(CONFIG_EJECT) += eject.o
177 MISCUTILS-$(CONFIG_HDPARM) += hdparm.o
178 MISCUTILS-$(CONFIG_LAST) += last.o
179 +MISCUTILS-$(CONFIG_LOCK) += lock.o
180 MISCUTILS-${CONFIG_LESS} += less.o
181 MISCUTILS-$(CONFIG_MAKEDEVS) += makedevs.o
182 MISCUTILS-$(CONFIG_MOUNTPOINT) += mountpoint.o