2006-07-03 01:17:05 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
2006-07-12 13:26:04 +05:30
|
|
|
/*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2006-07-12 13:26:04 +05:30
|
|
|
*/
|
|
|
|
|
2003-10-09 17:16:23 +05:30
|
|
|
/*
|
|
|
|
devfsd implementation for busybox
|
|
|
|
|
|
|
|
Copyright (C) 2003 by Tito Ragusa <farmatito@tiscali.it>
|
|
|
|
|
|
|
|
Busybox version is based on some previous work and ideas
|
|
|
|
Copyright (C) [2003] by [Matteo Croce] <3297627799@wind.it>
|
|
|
|
|
|
|
|
devfsd.c
|
|
|
|
|
|
|
|
Main file for devfsd (devfs daemon for Linux).
|
|
|
|
|
|
|
|
Copyright (C) 1998-2002 Richard Gooch
|
|
|
|
|
|
|
|
devfsd.h
|
|
|
|
|
|
|
|
Header file for devfsd (devfs daemon for Linux).
|
|
|
|
|
|
|
|
Copyright (C) 1998-2000 Richard Gooch
|
|
|
|
|
|
|
|
compat_name.c
|
|
|
|
|
|
|
|
Compatibility name file for devfsd (build compatibility names).
|
|
|
|
|
|
|
|
Copyright (C) 1998-2002 Richard Gooch
|
|
|
|
|
|
|
|
expression.c
|
|
|
|
|
|
|
|
This code provides Borne Shell-like expression expansion.
|
|
|
|
|
|
|
|
Copyright (C) 1997-1999 Richard Gooch
|
|
|
|
|
|
|
|
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
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
Richard Gooch may be reached by email at rgooch@atnf.csiro.au
|
|
|
|
The postal address is:
|
|
|
|
Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
|
|
|
|
*/
|
2016-11-23 03:44:24 +05:30
|
|
|
//config:config DEVFSD
|
|
|
|
//config: bool "devfsd (obsolete)"
|
|
|
|
//config: default n
|
|
|
|
//config: select FEATURE_SYSLOG
|
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: This is deprecated and should NOT be used anymore.
|
|
|
|
//config: Use linux >= 2.6 (optionally with hotplug) and mdev instead!
|
|
|
|
//config: See docs/mdev.txt for detailed instructions on how to use mdev
|
|
|
|
//config: instead.
|
2016-11-23 03:44:24 +05:30
|
|
|
//config:
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: Provides compatibility with old device names on a devfs systems.
|
|
|
|
//config: You should set it to true if you have devfs enabled.
|
|
|
|
//config: The following keywords in devsfd.conf are supported:
|
|
|
|
//config: "CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
|
|
|
|
//config: "PERMISSIONS", "EXECUTE", "COPY", "IGNORE",
|
|
|
|
//config: "MKOLDCOMPAT", "MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
|
2016-11-23 03:44:24 +05:30
|
|
|
//config:
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: But only if they are written UPPERCASE!!!!!!!!
|
2016-11-23 03:44:24 +05:30
|
|
|
//config:
|
|
|
|
//config:config DEVFSD_MODLOAD
|
|
|
|
//config: bool "Adds support for MODLOAD keyword in devsfd.conf"
|
|
|
|
//config: default y
|
|
|
|
//config: depends on DEVFSD
|
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: This actually doesn't work with busybox modutils but needs
|
|
|
|
//config: the external modutils.
|
2016-11-23 03:44:24 +05:30
|
|
|
//config:
|
|
|
|
//config:config DEVFSD_FG_NP
|
2017-01-10 19:28:54 +05:30
|
|
|
//config: bool "Enable the -fg and -np options"
|
2016-11-23 03:44:24 +05:30
|
|
|
//config: default y
|
|
|
|
//config: depends on DEVFSD
|
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: -fg Run the daemon in the foreground.
|
|
|
|
//config: -np Exit after parsing config. Do not poll for events.
|
2016-11-23 03:44:24 +05:30
|
|
|
//config:
|
|
|
|
//config:config DEVFSD_VERBOSE
|
|
|
|
//config: bool "Increases logging (and size)"
|
|
|
|
//config: default y
|
|
|
|
//config: depends on DEVFSD
|
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: Increases logging to stderr or syslog.
|
2016-11-23 03:44:24 +05:30
|
|
|
//config:
|
|
|
|
//config:config FEATURE_DEVFS
|
|
|
|
//config: bool "Use devfs names for all devices (obsolete)"
|
|
|
|
//config: default n
|
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: This is obsolete and should NOT be used anymore.
|
|
|
|
//config: Use linux >= 2.6 (optionally with hotplug) and mdev instead!
|
2016-11-23 03:44:24 +05:30
|
|
|
//config:
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: For legacy systems -- if there is no way around devfsd -- this
|
|
|
|
//config: tells busybox to look for names like /dev/loop/0 instead of
|
|
|
|
//config: /dev/loop0. If your /dev directory has normal names instead of
|
|
|
|
//config: devfs names, you don't want this.
|
2011-04-11 06:59:49 +05:30
|
|
|
|
2016-11-23 04:24:17 +05:30
|
|
|
//applet:IF_DEVFSD(APPLET(devfsd, BB_DIR_SBIN, BB_SUID_DROP))
|
|
|
|
|
|
|
|
//kbuild:lib-$(CONFIG_DEVFSD) += devfsd.o
|
|
|
|
|
2011-04-11 06:59:49 +05:30
|
|
|
//usage:#define devfsd_trivial_usage
|
|
|
|
//usage: "mntpnt [-v]" IF_DEVFSD_FG_NP("[-fg][-np]")
|
|
|
|
//usage:#define devfsd_full_usage "\n\n"
|
|
|
|
//usage: "Manage devfs permissions and old device name symlinks\n"
|
|
|
|
//usage: "\n mntpnt The mount point where devfs is mounted"
|
|
|
|
//usage: "\n -v Print the protocol version numbers for devfsd"
|
|
|
|
//usage: "\n and the kernel-side protocol version and exit"
|
|
|
|
//usage: IF_DEVFSD_FG_NP(
|
|
|
|
//usage: "\n -fg Run in foreground"
|
|
|
|
//usage: "\n -np Exit after parsing the configuration file"
|
|
|
|
//usage: "\n and processing synthetic REGISTER events,"
|
|
|
|
//usage: "\n don't poll for events"
|
|
|
|
//usage: )
|
|
|
|
|
2007-06-01 04:12:12 +05:30
|
|
|
#include "libbb.h"
|
|
|
|
#include "xregex.h"
|
2008-01-27 18:20:12 +05:30
|
|
|
#include <syslog.h>
|
2003-10-10 02:32:23 +05:30
|
|
|
|
2008-01-27 18:20:12 +05:30
|
|
|
#include <sys/un.h>
|
|
|
|
#include <sys/sysmacros.h>
|
2003-10-10 02:32:23 +05:30
|
|
|
|
|
|
|
/* Various defines taken from linux/major.h */
|
|
|
|
#define IDE0_MAJOR 3
|
|
|
|
#define IDE1_MAJOR 22
|
|
|
|
#define IDE2_MAJOR 33
|
|
|
|
#define IDE3_MAJOR 34
|
|
|
|
#define IDE4_MAJOR 56
|
|
|
|
#define IDE5_MAJOR 57
|
|
|
|
#define IDE6_MAJOR 88
|
|
|
|
#define IDE7_MAJOR 89
|
|
|
|
#define IDE8_MAJOR 90
|
|
|
|
#define IDE9_MAJOR 91
|
|
|
|
|
|
|
|
|
|
|
|
/* Various defines taken from linux/devfs_fs.h */
|
|
|
|
#define DEVFSD_PROTOCOL_REVISION_KERNEL 5
|
2010-10-28 22:27:19 +05:30
|
|
|
#define DEVFSD_IOCTL_BASE 'd'
|
2003-10-10 02:32:23 +05:30
|
|
|
/* These are the various ioctls */
|
|
|
|
#define DEVFSDIOC_GET_PROTO_REV _IOR(DEVFSD_IOCTL_BASE, 0, int)
|
|
|
|
#define DEVFSDIOC_SET_EVENT_MASK _IOW(DEVFSD_IOCTL_BASE, 2, int)
|
|
|
|
#define DEVFSDIOC_RELEASE_EVENT_QUEUE _IOW(DEVFSD_IOCTL_BASE, 3, int)
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
#define DEVFSDIOC_SET_CONFIG_DEBUG_MASK _IOW(DEVFSD_IOCTL_BASE, 4, int)
|
2003-10-10 02:32:23 +05:30
|
|
|
#define DEVFSD_NOTIFY_REGISTERED 0
|
|
|
|
#define DEVFSD_NOTIFY_UNREGISTERED 1
|
|
|
|
#define DEVFSD_NOTIFY_ASYNC_OPEN 2
|
|
|
|
#define DEVFSD_NOTIFY_CLOSE 3
|
|
|
|
#define DEVFSD_NOTIFY_LOOKUP 4
|
|
|
|
#define DEVFSD_NOTIFY_CHANGE 5
|
|
|
|
#define DEVFSD_NOTIFY_CREATE 6
|
|
|
|
#define DEVFSD_NOTIFY_DELETE 7
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
#define DEVFS_PATHLEN 1024
|
|
|
|
/* Never change this otherwise the binary interface will change */
|
|
|
|
|
2009-06-05 15:36:05 +05:30
|
|
|
struct devfsd_notify_struct {
|
|
|
|
/* Use native C types to ensure same types in kernel and user space */
|
2008-03-28 06:30:09 +05:30
|
|
|
unsigned int type; /* DEVFSD_NOTIFY_* value */
|
|
|
|
unsigned int mode; /* Mode of the inode or device entry */
|
|
|
|
unsigned int major; /* Major number of device entry */
|
|
|
|
unsigned int minor; /* Minor number of device entry */
|
|
|
|
unsigned int uid; /* Uid of process, inode or device entry */
|
|
|
|
unsigned int gid; /* Gid of process, inode or device entry */
|
|
|
|
unsigned int overrun_count; /* Number of lost events */
|
|
|
|
unsigned int namelen; /* Number of characters not including '\0' */
|
|
|
|
/* The device name MUST come last */
|
|
|
|
char devname[DEVFS_PATHLEN]; /* This will be '\0' terminated */
|
2003-10-10 02:32:23 +05:30
|
|
|
};
|
|
|
|
|
2003-10-09 17:16:23 +05:30
|
|
|
#define BUFFER_SIZE 16384
|
|
|
|
#define DEVFSD_VERSION "1.3.25"
|
|
|
|
#define CONFIG_FILE "/etc/devfsd.conf"
|
2006-01-25 05:38:53 +05:30
|
|
|
#define MODPROBE "/sbin/modprobe"
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
#define MODPROBE_SWITCH_1 "-k"
|
|
|
|
#define MODPROBE_SWITCH_2 "-C"
|
2003-12-01 05:16:06 +05:30
|
|
|
#define CONFIG_MODULES_DEVFS "/etc/modules.devfs"
|
2003-10-09 17:16:23 +05:30
|
|
|
#define MAX_ARGS (6 + 1)
|
|
|
|
#define MAX_SUBEXPR 10
|
|
|
|
#define STRING_LENGTH 255
|
|
|
|
|
|
|
|
/* for get_uid_gid() */
|
|
|
|
#define UID 0
|
|
|
|
#define GID 1
|
|
|
|
|
2005-10-08 23:12:35 +05:30
|
|
|
/* fork_and_execute() */
|
2003-12-01 05:16:06 +05:30
|
|
|
# define DIE 1
|
2003-10-09 17:16:23 +05:30
|
|
|
# define NO_DIE 0
|
|
|
|
|
2003-12-01 05:16:06 +05:30
|
|
|
/* for dir_operation() */
|
|
|
|
#define RESTORE 0
|
|
|
|
#define SERVICE 1
|
|
|
|
#define READ_CONFIG 2
|
|
|
|
|
2003-10-09 17:16:23 +05:30
|
|
|
/* Update only after changing code to reflect new protocol */
|
|
|
|
#define DEVFSD_PROTOCOL_REVISION_DAEMON 5
|
|
|
|
|
|
|
|
/* Compile-time check */
|
|
|
|
#if DEVFSD_PROTOCOL_REVISION_KERNEL != DEVFSD_PROTOCOL_REVISION_DAEMON
|
|
|
|
#error protocol version mismatch. Update your kernel headers
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define AC_PERMISSIONS 0
|
2003-12-01 05:16:06 +05:30
|
|
|
#define AC_MODLOAD 1
|
2003-10-09 17:16:23 +05:30
|
|
|
#define AC_EXECUTE 2
|
|
|
|
#define AC_MFUNCTION 3 /* not supported by busybox */
|
|
|
|
#define AC_CFUNCTION 4 /* not supported by busybox */
|
2003-12-01 05:16:06 +05:30
|
|
|
#define AC_COPY 5
|
2003-10-09 17:16:23 +05:30
|
|
|
#define AC_IGNORE 6
|
|
|
|
#define AC_MKOLDCOMPAT 7
|
|
|
|
#define AC_MKNEWCOMPAT 8
|
|
|
|
#define AC_RMOLDCOMPAT 9
|
|
|
|
#define AC_RMNEWCOMPAT 10
|
|
|
|
#define AC_RESTORE 11
|
|
|
|
|
2009-06-05 15:36:05 +05:30
|
|
|
struct permissions_type {
|
2007-06-26 04:25:34 +05:30
|
|
|
mode_t mode;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
2003-10-09 17:16:23 +05:30
|
|
|
};
|
|
|
|
|
2009-06-05 15:36:05 +05:30
|
|
|
struct execute_type {
|
2007-06-26 04:25:34 +05:30
|
|
|
char *argv[MAX_ARGS + 1]; /* argv[0] must always be the programme */
|
2003-10-09 17:16:23 +05:30
|
|
|
};
|
|
|
|
|
2009-06-05 15:36:05 +05:30
|
|
|
struct copy_type {
|
2007-06-26 04:25:34 +05:30
|
|
|
const char *source;
|
|
|
|
const char *destination;
|
2003-10-09 17:16:23 +05:30
|
|
|
};
|
|
|
|
|
2009-06-05 15:36:05 +05:30
|
|
|
struct action_type {
|
2007-06-26 04:25:34 +05:30
|
|
|
unsigned int what;
|
|
|
|
unsigned int when;
|
2003-10-09 17:16:23 +05:30
|
|
|
};
|
|
|
|
|
2009-06-05 15:36:05 +05:30
|
|
|
struct config_entry_struct {
|
2007-06-26 04:25:34 +05:30
|
|
|
struct action_type action;
|
|
|
|
regex_t preg;
|
|
|
|
union
|
|
|
|
{
|
2003-10-09 17:16:23 +05:30
|
|
|
struct permissions_type permissions;
|
|
|
|
struct execute_type execute;
|
|
|
|
struct copy_type copy;
|
2007-06-26 04:25:34 +05:30
|
|
|
}
|
|
|
|
u;
|
|
|
|
struct config_entry_struct *next;
|
2003-10-09 17:16:23 +05:30
|
|
|
};
|
|
|
|
|
2009-06-05 15:36:05 +05:30
|
|
|
struct get_variable_info {
|
2007-06-26 04:25:34 +05:30
|
|
|
const struct devfsd_notify_struct *info;
|
|
|
|
const char *devname;
|
|
|
|
char devpath[STRING_LENGTH];
|
2003-10-09 17:16:23 +05:30
|
|
|
};
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void dir_operation(int , const char * , int, unsigned long*);
|
2003-12-01 05:16:06 +05:30
|
|
|
static void service(struct stat statbuf, char *path);
|
2007-06-26 04:25:34 +05:30
|
|
|
static int st_expr_expand(char *, unsigned, const char *, const char *(*)(const char *, void *), void *);
|
2003-10-09 17:16:23 +05:30
|
|
|
static const char *get_old_name(const char *, unsigned, char *, unsigned, unsigned);
|
2007-06-26 04:25:34 +05:30
|
|
|
static int mksymlink(const char *oldpath, const char *newpath);
|
|
|
|
static void read_config_file(char *path, int optional, unsigned long *event_mask);
|
|
|
|
static void process_config_line(const char *, unsigned long *);
|
|
|
|
static int do_servicing(int, unsigned long);
|
|
|
|
static void service_name(const struct devfsd_notify_struct *);
|
|
|
|
static void action_permissions(const struct devfsd_notify_struct *, const struct config_entry_struct *);
|
|
|
|
static void action_execute(const struct devfsd_notify_struct *, const struct config_entry_struct *,
|
2003-10-09 17:16:23 +05:30
|
|
|
const regmatch_t *, unsigned);
|
2007-06-26 04:25:34 +05:30
|
|
|
static void action_modload(const struct devfsd_notify_struct *info, const struct config_entry_struct *entry);
|
|
|
|
static void action_copy(const struct devfsd_notify_struct *, const struct config_entry_struct *,
|
2013-01-14 20:27:44 +05:30
|
|
|
const regmatch_t *, unsigned);
|
2007-06-26 04:25:34 +05:30
|
|
|
static void action_compat(const struct devfsd_notify_struct *, unsigned);
|
|
|
|
static void free_config(void);
|
2003-12-01 05:16:06 +05:30
|
|
|
static void restore(char *spath, struct stat source_stat, int rootlen);
|
2007-06-26 04:25:34 +05:30
|
|
|
static int copy_inode(const char *, const struct stat *, mode_t, const char *, const struct stat *);
|
|
|
|
static mode_t get_mode(const char *);
|
|
|
|
static void signal_handler(int);
|
|
|
|
static const char *get_variable(const char *, void *);
|
|
|
|
static int make_dir_tree(const char *);
|
2003-10-09 17:16:23 +05:30
|
|
|
static int expand_expression(char *, unsigned, const char *, const char *(*)(const char *, void *), void *,
|
2013-01-14 20:27:44 +05:30
|
|
|
const char *, const regmatch_t *, unsigned);
|
2007-06-26 04:25:34 +05:30
|
|
|
static void expand_regexp(char *, size_t, const char *, const char *, const regmatch_t *, unsigned);
|
2003-10-09 17:16:23 +05:30
|
|
|
static const char *expand_variable( char *, unsigned, unsigned *, const char *,
|
2007-06-26 04:25:34 +05:30
|
|
|
const char *(*)(const char *, void *), void *);
|
|
|
|
static const char *get_variable_v2(const char *, const char *(*)(const char *, void *), void *);
|
2013-01-14 20:27:44 +05:30
|
|
|
static char get_old_ide_name(unsigned, unsigned);
|
2007-06-26 04:25:34 +05:30
|
|
|
static char *write_old_sd_name(char *, unsigned, unsigned, const char *);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
|
|
|
/* busybox functions */
|
2007-07-02 03:55:33 +05:30
|
|
|
static int get_uid_gid(int flag, const char *string);
|
2007-06-26 04:25:34 +05:30
|
|
|
static void safe_memcpy(char * dest, const char * src, int len);
|
2007-06-30 13:34:05 +05:30
|
|
|
static unsigned int scan_dev_name_common(const char *d, unsigned int n, int addendum, const char *ptr);
|
|
|
|
static unsigned int scan_dev_name(const char *d, unsigned int n, const char *ptr);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
|
|
|
/* Structs and vars */
|
|
|
|
static struct config_entry_struct *first_config = NULL;
|
|
|
|
static struct config_entry_struct *last_config = NULL;
|
2007-07-02 03:55:33 +05:30
|
|
|
static char *mount_point = NULL;
|
2003-10-09 17:16:23 +05:30
|
|
|
static volatile int caught_signal = FALSE;
|
|
|
|
static volatile int caught_sighup = FALSE;
|
2007-08-13 02:28:27 +05:30
|
|
|
static struct initial_symlink_struct {
|
2007-06-26 04:25:34 +05:30
|
|
|
const char *dest;
|
|
|
|
const char *name;
|
2007-08-13 02:28:27 +05:30
|
|
|
} initial_symlinks[] = {
|
2007-06-26 04:25:34 +05:30
|
|
|
{"/proc/self/fd", "fd"},
|
|
|
|
{"fd/0", "stdin"},
|
|
|
|
{"fd/1", "stdout"},
|
|
|
|
{"fd/2", "stderr"},
|
|
|
|
{NULL, NULL},
|
2003-10-09 17:16:23 +05:30
|
|
|
};
|
|
|
|
|
2007-08-13 02:28:27 +05:30
|
|
|
static struct event_type {
|
2007-06-26 04:25:34 +05:30
|
|
|
unsigned int type; /* The DEVFSD_NOTIFY_* value */
|
|
|
|
const char *config_name; /* The name used in the config file */
|
2007-08-13 02:28:27 +05:30
|
|
|
} event_types[] = {
|
2007-06-26 04:25:34 +05:30
|
|
|
{DEVFSD_NOTIFY_REGISTERED, "REGISTER"},
|
|
|
|
{DEVFSD_NOTIFY_UNREGISTERED, "UNREGISTER"},
|
|
|
|
{DEVFSD_NOTIFY_ASYNC_OPEN, "ASYNC_OPEN"},
|
|
|
|
{DEVFSD_NOTIFY_CLOSE, "CLOSE"},
|
|
|
|
{DEVFSD_NOTIFY_LOOKUP, "LOOKUP"},
|
|
|
|
{DEVFSD_NOTIFY_CHANGE, "CHANGE"},
|
|
|
|
{DEVFSD_NOTIFY_CREATE, "CREATE"},
|
|
|
|
{DEVFSD_NOTIFY_DELETE, "DELETE"},
|
|
|
|
{0xffffffff, NULL}
|
2003-10-09 17:16:23 +05:30
|
|
|
};
|
|
|
|
|
2005-10-08 23:12:35 +05:30
|
|
|
/* Busybox messages */
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-08-13 02:28:27 +05:30
|
|
|
static const char bb_msg_proto_rev[] ALIGN1 = "protocol revision";
|
|
|
|
static const char bb_msg_bad_config[] ALIGN1 = "bad %s config file: %s";
|
|
|
|
static const char bb_msg_small_buffer[] ALIGN1 = "buffer too small";
|
|
|
|
static const char bb_msg_variable_not_found[] ALIGN1 = "variable: %s not found";
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2005-10-08 23:12:35 +05:30
|
|
|
/* Busybox stuff */
|
2007-07-02 03:55:33 +05:30
|
|
|
#if ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG
|
2019-04-12 22:31:51 +05:30
|
|
|
#define info_logger(p, fmt, args...) bb_info_msg(fmt, ## args)
|
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 15:05:03 +05:30
|
|
|
#define simple_info_logger(p, msg) bb_simple_info_msg(msg)
|
2007-07-02 03:55:33 +05:30
|
|
|
#define msg_logger(p, fmt, args...) bb_error_msg(fmt, ## args)
|
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 15:05:03 +05:30
|
|
|
#define simple_msg_logger(p, msg) bb_simple_error_msg(msg)
|
2007-07-02 03:55:33 +05:30
|
|
|
#define msg_logger_and_die(p, fmt, args...) bb_error_msg_and_die(fmt, ## args)
|
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 15:05:03 +05:30
|
|
|
#define simple_msg_logger_and_die(p, msg) bb_simple_error_msg_and_die(msg)
|
2007-07-02 03:55:33 +05:30
|
|
|
#define error_logger(p, fmt, args...) bb_perror_msg(fmt, ## args)
|
|
|
|
#define error_logger_and_die(p, fmt, args...) bb_perror_msg_and_die(fmt, ## args)
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
#else
|
2007-07-02 03:55:33 +05:30
|
|
|
#define info_logger(p, fmt, args...)
|
2020-06-23 07:13:39 +05:30
|
|
|
#define simple_info_logger(p, msg)
|
2006-01-25 05:38:53 +05:30
|
|
|
#define msg_logger(p, fmt, args...)
|
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 15:05:03 +05:30
|
|
|
#define simple_msg_logger(p, msg)
|
2008-05-19 14:59:47 +05:30
|
|
|
#define msg_logger_and_die(p, fmt, args...) exit(EXIT_FAILURE)
|
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 15:05:03 +05:30
|
|
|
#define simple_msg_logger_and_die(p, msg) exit(EXIT_FAILURE)
|
2007-07-02 03:55:33 +05:30
|
|
|
#define error_logger(p, fmt, args...)
|
2008-05-19 14:59:47 +05:30
|
|
|
#define error_logger_and_die(p, fmt, args...) exit(EXIT_FAILURE)
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
#endif
|
2005-10-08 23:12:35 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void safe_memcpy(char *dest, const char *src, int len)
|
2003-10-09 17:16:23 +05:30
|
|
|
{
|
2020-12-29 21:23:11 +05:30
|
|
|
memcpy(dest, src, len);
|
2003-10-09 17:16:23 +05:30
|
|
|
dest[len] = '\0';
|
|
|
|
}
|
|
|
|
|
2007-06-30 13:34:05 +05:30
|
|
|
static unsigned int scan_dev_name_common(const char *d, unsigned int n, int addendum, const char *ptr)
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
{
|
2007-06-26 04:25:34 +05:30
|
|
|
if (d[n - 4] == 'd' && d[n - 3] == 'i' && d[n - 2] == 's' && d[n - 1] == 'c')
|
2006-11-27 22:19:55 +05:30
|
|
|
return 2 + addendum;
|
2007-06-26 04:25:34 +05:30
|
|
|
if (d[n - 2] == 'c' && d[n - 1] == 'd')
|
2006-11-27 22:19:55 +05:30
|
|
|
return 3 + addendum;
|
2007-06-26 04:25:34 +05:30
|
|
|
if (ptr[0] == 'p' && ptr[1] == 'a' && ptr[2] == 'r' && ptr[3] == 't')
|
2006-11-27 22:19:55 +05:30
|
|
|
return 4 + addendum;
|
2007-06-26 04:25:34 +05:30
|
|
|
if (ptr[n - 2] == 'm' && ptr[n - 1] == 't')
|
2006-11-27 22:19:55 +05:30
|
|
|
return 5 + addendum;
|
|
|
|
return 0;
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
}
|
|
|
|
|
2007-06-30 13:34:05 +05:30
|
|
|
static unsigned int scan_dev_name(const char *d, unsigned int n, const char *ptr)
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
{
|
2007-06-26 04:25:34 +05:30
|
|
|
if (d[0] == 's' && d[1] == 'c' && d[2] == 's' && d[3] == 'i' && d[4] == '/') {
|
|
|
|
if (d[n - 7] == 'g' && d[n - 6] == 'e' && d[n - 5] == 'n'
|
|
|
|
&& d[n - 4] == 'e' && d[n - 3] == 'r' && d[n - 2] == 'i' && d[n - 1] == 'c'
|
|
|
|
)
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
return 1;
|
|
|
|
return scan_dev_name_common(d, n, 0, ptr);
|
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
if (d[0] == 'i' && d[1] == 'd' && d[2] == 'e' && d[3] == '/'
|
|
|
|
&& d[4] == 'h' && d[5] == 'o' && d[6] == 's' && d[7] == 't'
|
|
|
|
)
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
return scan_dev_name_common(d, n, 4, ptr);
|
2007-06-26 04:25:34 +05:30
|
|
|
if (d[0] == 's' && d[1] == 'b' && d[2] == 'p' && d[3] == '/')
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
return 10;
|
2007-06-26 04:25:34 +05:30
|
|
|
if (d[0] == 'v' && d[1] == 'c' && d[2] == 'c' && d[3] == '/')
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
return 11;
|
2007-06-26 04:25:34 +05:30
|
|
|
if (d[0] == 'p' && d[1] == 't' && d[2] == 'y' && d[3] == '/')
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
return 12;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-10-09 17:16:23 +05:30
|
|
|
/* Public functions follow */
|
|
|
|
|
2007-10-11 15:35:36 +05:30
|
|
|
int devfsd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2007-06-26 04:25:34 +05:30
|
|
|
int devfsd_main(int argc, char **argv)
|
2003-10-09 17:16:23 +05:30
|
|
|
{
|
|
|
|
int print_version = FALSE;
|
|
|
|
int do_daemon = TRUE;
|
|
|
|
int no_polling = FALSE;
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
int do_scan;
|
2003-10-09 17:16:23 +05:30
|
|
|
int fd, proto_rev, count;
|
|
|
|
unsigned long event_mask = 0;
|
|
|
|
struct sigaction new_action;
|
|
|
|
struct initial_symlink_struct *curr;
|
|
|
|
|
|
|
|
if (argc < 2)
|
|
|
|
bb_show_usage();
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
for (count = 2; count < argc; ++count) {
|
|
|
|
if (argv[count][0] == '-') {
|
|
|
|
if (argv[count][1] == 'v' && !argv[count][2]) /* -v */
|
2007-07-01 23:48:54 +05:30
|
|
|
print_version = TRUE;
|
2007-06-26 04:25:34 +05:30
|
|
|
else if (ENABLE_DEVFSD_FG_NP && argv[count][1] == 'f'
|
2007-07-01 23:48:54 +05:30
|
|
|
&& argv[count][2] == 'g' && !argv[count][3]) /* -fg */
|
|
|
|
do_daemon = FALSE;
|
2007-06-26 04:25:34 +05:30
|
|
|
else if (ENABLE_DEVFSD_FG_NP && argv[count][1] == 'n'
|
2007-07-01 23:48:54 +05:30
|
|
|
&& argv[count][2] == 'p' && !argv[count][3]) /* -np */
|
|
|
|
no_polling = TRUE;
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
else
|
|
|
|
bb_show_usage();
|
|
|
|
}
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
|
2007-07-02 03:55:33 +05:30
|
|
|
mount_point = bb_simplify_path(argv[1]);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-06-27 05:50:38 +05:30
|
|
|
xchdir(mount_point);
|
2006-01-25 05:38:53 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
fd = xopen(".devfsd", O_RDONLY);
|
2007-10-01 05:20:48 +05:30
|
|
|
close_on_exec_on(fd);
|
2007-07-15 03:37:14 +05:30
|
|
|
xioctl(fd, DEVFSDIOC_GET_PROTO_REV, &proto_rev);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
|
|
|
/*setup initial entries */
|
2007-07-01 23:48:54 +05:30
|
|
|
for (curr = initial_symlinks; curr->dest != NULL; ++curr)
|
2007-06-26 04:25:34 +05:30
|
|
|
symlink(curr->dest, curr->name);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
|
|
|
/* NB: The check for CONFIG_FILE is done in read_config_file() */
|
|
|
|
|
2007-08-13 02:28:27 +05:30
|
|
|
if (print_version || (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev)) {
|
2007-01-30 05:13:18 +05:30
|
|
|
printf("%s v%s\nDaemon %s:\t%d\nKernel-side %s:\t%d\n",
|
2007-06-26 04:25:34 +05:30
|
|
|
applet_name, DEVFSD_VERSION, bb_msg_proto_rev,
|
2007-08-13 02:28:27 +05:30
|
|
|
DEVFSD_PROTOCOL_REVISION_DAEMON, bb_msg_proto_rev, proto_rev);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev)
|
2007-06-26 04:25:34 +05:30
|
|
|
bb_error_msg_and_die("%s mismatch!", bb_msg_proto_rev);
|
2022-01-06 02:46:06 +05:30
|
|
|
exit_SUCCESS(); /* -v */
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
/* Tell kernel we are special(i.e. we get to see hidden entries) */
|
2007-07-15 03:37:14 +05:30
|
|
|
xioctl(fd, DEVFSDIOC_SET_EVENT_MASK, 0);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2008-03-13 04:43:50 +05:30
|
|
|
/* Set up SIGHUP and SIGUSR1 handlers */
|
2007-01-30 05:13:18 +05:30
|
|
|
sigemptyset(&new_action.sa_mask);
|
2003-10-09 17:16:23 +05:30
|
|
|
new_action.sa_flags = 0;
|
|
|
|
new_action.sa_handler = signal_handler;
|
2008-03-13 04:49:35 +05:30
|
|
|
sigaction_set(SIGHUP, &new_action);
|
|
|
|
sigaction_set(SIGUSR1, &new_action);
|
2006-01-25 05:38:53 +05:30
|
|
|
|
2008-03-13 04:43:50 +05:30
|
|
|
printf("%s v%s started for %s\n", applet_name, DEVFSD_VERSION, mount_point);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2006-01-25 05:38:53 +05:30
|
|
|
/* Set umask so that mknod(2), open(2) and mkdir(2) have complete control over permissions */
|
2007-01-30 05:13:18 +05:30
|
|
|
umask(0);
|
|
|
|
read_config_file((char*)CONFIG_FILE, FALSE, &event_mask);
|
2003-10-09 17:16:23 +05:30
|
|
|
/* Do the scan before forking, so that boot scripts see the finished product */
|
2007-06-26 04:25:34 +05:30
|
|
|
dir_operation(SERVICE, mount_point, 0, NULL);
|
2006-01-25 05:38:53 +05:30
|
|
|
|
2005-10-08 23:12:35 +05:30
|
|
|
if (ENABLE_DEVFSD_FG_NP && no_polling)
|
2022-01-06 02:46:06 +05:30
|
|
|
exit_SUCCESS();
|
2007-07-20 04:20:47 +05:30
|
|
|
|
2007-07-02 03:55:33 +05:30
|
|
|
if (ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG)
|
|
|
|
logmode = LOGMODE_BOTH;
|
|
|
|
else if (do_daemon == TRUE)
|
|
|
|
logmode = LOGMODE_SYSLOG;
|
|
|
|
/* This is the default */
|
|
|
|
/*else
|
|
|
|
logmode = LOGMODE_STDIO; */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (do_daemon) {
|
2003-10-09 17:16:23 +05:30
|
|
|
/* Release so that the child can grab it */
|
2007-07-15 03:37:14 +05:30
|
|
|
xioctl(fd, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0);
|
2007-07-02 03:55:33 +05:30
|
|
|
bb_daemonize_or_rexec(0, argv);
|
2007-06-26 04:25:34 +05:30
|
|
|
} else if (ENABLE_DEVFSD_FG_NP) {
|
|
|
|
setpgid(0, 0); /* Become process group leader */
|
2005-10-08 23:12:35 +05:30
|
|
|
}
|
2007-07-20 04:20:47 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
while (TRUE) {
|
|
|
|
do_scan = do_servicing(fd, event_mask);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
free_config();
|
|
|
|
read_config_file((char*)CONFIG_FILE, FALSE, &event_mask);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (do_scan)
|
2007-06-27 05:50:38 +05:30
|
|
|
dir_operation(SERVICE, mount_point, 0, NULL);
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2007-07-02 03:55:33 +05:30
|
|
|
if (ENABLE_FEATURE_CLEAN_UP) free(mount_point);
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function main */
|
|
|
|
|
|
|
|
|
|
|
|
/* Private functions follow */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void read_config_file(char *path, int optional, unsigned long *event_mask)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Read a configuration database.
|
|
|
|
<path> The path to read the database from. If this is a directory, all
|
2007-06-26 04:25:34 +05:30
|
|
|
entries in that directory will be read(except hidden entries).
|
2003-10-09 17:16:23 +05:30
|
|
|
<optional> If TRUE, the routine will silently ignore a missing config file.
|
|
|
|
<event_mask> The event mask is written here. This is not initialised.
|
|
|
|
[RETURNS] Nothing.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
struct stat statbuf;
|
|
|
|
FILE *fp;
|
|
|
|
char buf[STRING_LENGTH];
|
2007-01-30 05:13:18 +05:30
|
|
|
char *line = NULL;
|
2007-07-02 03:55:33 +05:30
|
|
|
char *p;
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (stat(path, &statbuf) == 0) {
|
2005-06-07 09:17:00 +05:30
|
|
|
/* Don't read 0 length files: ignored */
|
2007-06-26 04:25:34 +05:30
|
|
|
/*if (statbuf.st_size == 0)
|
2005-06-07 09:17:00 +05:30
|
|
|
return;*/
|
2007-06-26 04:25:34 +05:30
|
|
|
if (S_ISDIR(statbuf.st_mode)) {
|
2007-07-02 03:55:33 +05:30
|
|
|
p = bb_simplify_path(path);
|
|
|
|
dir_operation(READ_CONFIG, p, 0, event_mask);
|
|
|
|
free(p);
|
2005-06-07 09:17:00 +05:30
|
|
|
return;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2008-07-22 04:35:26 +05:30
|
|
|
fp = fopen_for_read(path);
|
2007-11-06 08:35:54 +05:30
|
|
|
if (fp != NULL) {
|
2007-06-26 04:25:34 +05:30
|
|
|
while (fgets(buf, STRING_LENGTH, fp) != NULL) {
|
2005-06-07 09:17:00 +05:30
|
|
|
/* Skip whitespace */
|
2007-07-02 03:55:33 +05:30
|
|
|
line = buf;
|
|
|
|
line = skip_whitespace(line);
|
2007-06-26 04:25:34 +05:30
|
|
|
if (line[0] == '\0' || line[0] == '#')
|
2005-06-07 09:17:00 +05:30
|
|
|
continue;
|
2007-06-26 04:25:34 +05:30
|
|
|
process_config_line(line, event_mask);
|
2005-06-07 09:17:00 +05:30
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
fclose(fp);
|
2005-06-07 09:17:00 +05:30
|
|
|
} else {
|
|
|
|
goto read_config_file_err;
|
|
|
|
}
|
|
|
|
} else {
|
2003-12-01 05:16:06 +05:30
|
|
|
read_config_file_err:
|
2007-07-02 03:55:33 +05:30
|
|
|
if (optional == 0 && errno == ENOENT)
|
|
|
|
error_logger_and_die(LOG_ERR, "read config file: %s", path);
|
2005-06-07 09:17:00 +05:30
|
|
|
}
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function read_config_file */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void process_config_line(const char *line, unsigned long *event_mask)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Process a line from a configuration file.
|
|
|
|
<line> The configuration line.
|
|
|
|
<event_mask> The event mask is written here. This is not initialised.
|
|
|
|
[RETURNS] Nothing.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
int num_args, count;
|
|
|
|
struct config_entry_struct *new;
|
|
|
|
char p[MAX_ARGS][STRING_LENGTH];
|
|
|
|
char when[STRING_LENGTH], what[STRING_LENGTH];
|
|
|
|
char name[STRING_LENGTH];
|
2007-01-30 05:13:18 +05:30
|
|
|
const char *msg = "";
|
2003-12-01 05:16:06 +05:30
|
|
|
char *ptr;
|
2006-02-22 22:31:00 +05:30
|
|
|
int i;
|
2003-12-01 05:16:06 +05:30
|
|
|
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
/* !!!! Only Uppercase Keywords in devsfd.conf */
|
2007-08-13 02:28:27 +05:30
|
|
|
static const char options[] ALIGN1 =
|
2007-07-24 21:24:42 +05:30
|
|
|
"CLEAR_CONFIG\0""INCLUDE\0""OPTIONAL_INCLUDE\0"
|
|
|
|
"RESTORE\0""PERMISSIONS\0""MODLOAD\0""EXECUTE\0"
|
|
|
|
"COPY\0""IGNORE\0""MKOLDCOMPAT\0""MKNEWCOMPAT\0"
|
|
|
|
"RMOLDCOMPAT\0""RMNEWCOMPAT\0";
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2007-06-27 05:50:38 +05:30
|
|
|
for (count = 0; count < MAX_ARGS; ++count)
|
|
|
|
p[count][0] = '\0';
|
2007-06-26 04:25:34 +05:30
|
|
|
num_args = sscanf(line, "%s %s %s %s %s %s %s %s %s %s",
|
2003-10-09 17:16:23 +05:30
|
|
|
when, name, what,
|
|
|
|
p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2007-07-24 21:24:42 +05:30
|
|
|
i = index_in_strings(options, when);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2007-07-24 21:24:42 +05:30
|
|
|
/* "CLEAR_CONFIG" */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 0) {
|
|
|
|
free_config();
|
2003-10-09 17:16:23 +05:30
|
|
|
*event_mask = 0;
|
|
|
|
return;
|
|
|
|
}
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (num_args < 2)
|
2003-10-09 17:16:23 +05:30
|
|
|
goto process_config_line_err;
|
|
|
|
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
/* "INCLUDE" & "OPTIONAL_INCLUDE" */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 1 || i == 2) {
|
|
|
|
st_expr_expand(name, STRING_LENGTH, name, get_variable, NULL);
|
2007-07-02 03:55:33 +05:30
|
|
|
info_logger(LOG_INFO, "%sinclude: %s", (toupper(when[0]) == 'I') ? "": "optional_", name);
|
2007-06-26 04:25:34 +05:30
|
|
|
read_config_file(name, (toupper(when[0]) == 'I') ? FALSE : TRUE, event_mask);
|
2003-10-09 17:16:23 +05:30
|
|
|
return;
|
|
|
|
}
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
/* "RESTORE" */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 3) {
|
2007-06-27 05:50:38 +05:30
|
|
|
dir_operation(RESTORE, name, strlen(name),NULL);
|
2003-10-09 17:16:23 +05:30
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (num_args < 3)
|
|
|
|
goto process_config_line_err;
|
|
|
|
|
2007-06-27 05:50:38 +05:30
|
|
|
new = xzalloc(sizeof *new);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
for (count = 0; event_types[count].config_name != NULL; ++count) {
|
|
|
|
if (strcasecmp(when, event_types[count].config_name) != 0)
|
2003-10-09 17:16:23 +05:30
|
|
|
continue;
|
|
|
|
new->action.when = event_types[count].type;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
if (event_types[count].config_name == NULL) {
|
2007-06-27 05:50:38 +05:30
|
|
|
msg = "WHEN in";
|
2003-10-09 17:16:23 +05:30
|
|
|
goto process_config_line_err;
|
|
|
|
}
|
|
|
|
|
2007-07-24 21:24:42 +05:30
|
|
|
i = index_in_strings(options, what);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
switch (i) {
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
case 4: /* "PERMISSIONS" */
|
|
|
|
new->action.what = AC_PERMISSIONS;
|
|
|
|
/* Get user and group */
|
2007-11-06 08:35:54 +05:30
|
|
|
ptr = strchr(p[0], '.');
|
|
|
|
if (ptr == NULL) {
|
2007-06-27 05:50:38 +05:30
|
|
|
msg = "UID.GID";
|
2006-02-22 22:31:00 +05:30
|
|
|
goto process_config_line_err; /*"missing '.' in UID.GID"*/
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
}
|
2003-10-09 17:16:23 +05:30
|
|
|
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
*ptr++ = '\0';
|
2007-06-26 04:25:34 +05:30
|
|
|
new->u.permissions.uid = get_uid_gid(UID, p[0]);
|
|
|
|
new->u.permissions.gid = get_uid_gid(GID, ptr);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
/* Get mode */
|
2007-06-26 04:25:34 +05:30
|
|
|
new->u.permissions.mode = get_mode(p[1]);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
break;
|
|
|
|
case 5: /* MODLOAD */
|
2007-06-26 04:25:34 +05:30
|
|
|
/*This action will pass "/dev/$devname"(i.e. "/dev/" prefixed to
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
the device name) to the module loading facility. In addition,
|
|
|
|
the /etc/modules.devfs configuration file is used.*/
|
2013-01-14 20:27:44 +05:30
|
|
|
if (ENABLE_DEVFSD_MODLOAD)
|
2006-01-25 05:38:53 +05:30
|
|
|
new->action.what = AC_MODLOAD;
|
2013-01-14 20:27:44 +05:30
|
|
|
break;
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
case 6: /* EXECUTE */
|
|
|
|
new->action.what = AC_EXECUTE;
|
|
|
|
num_args -= 3;
|
2003-10-09 17:16:23 +05:30
|
|
|
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
for (count = 0; count < num_args; ++count)
|
2007-06-26 04:25:34 +05:30
|
|
|
new->u.execute.argv[count] = xstrdup(p[count]);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
new->u.execute.argv[num_args] = NULL;
|
|
|
|
break;
|
|
|
|
case 7: /* COPY */
|
|
|
|
new->action.what = AC_COPY;
|
|
|
|
num_args -= 3;
|
|
|
|
if (num_args != 2)
|
|
|
|
goto process_config_line_err; /* missing path and function in line */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
new->u.copy.source = xstrdup(p[0]);
|
|
|
|
new->u.copy.destination = xstrdup(p[1]);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
break;
|
|
|
|
case 8: /* IGNORE */
|
|
|
|
/* FALLTROUGH */
|
|
|
|
case 9: /* MKOLDCOMPAT */
|
|
|
|
/* FALLTROUGH */
|
|
|
|
case 10: /* MKNEWCOMPAT */
|
|
|
|
/* FALLTROUGH */
|
|
|
|
case 11:/* RMOLDCOMPAT */
|
|
|
|
/* FALLTROUGH */
|
|
|
|
case 12: /* RMNEWCOMPAT */
|
|
|
|
/* AC_IGNORE 6
|
|
|
|
AC_MKOLDCOMPAT 7
|
|
|
|
AC_MKNEWCOMPAT 8
|
|
|
|
AC_RMOLDCOMPAT 9
|
|
|
|
AC_RMNEWCOMPAT 10*/
|
|
|
|
new->action.what = i - 2;
|
|
|
|
break;
|
|
|
|
default:
|
2007-06-27 05:50:38 +05:30
|
|
|
msg = "WHAT in";
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
goto process_config_line_err;
|
|
|
|
/*esac*/
|
|
|
|
} /* switch (i) */
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
xregcomp(&new->preg, name, REG_EXTENDED);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
|
|
|
*event_mask |= 1 << new->action.when;
|
|
|
|
new->next = NULL;
|
|
|
|
if (first_config == NULL)
|
|
|
|
first_config = new;
|
|
|
|
else
|
|
|
|
last_config->next = new;
|
|
|
|
last_config = new;
|
|
|
|
return;
|
2007-08-17 13:59:48 +05:30
|
|
|
|
|
|
|
process_config_line_err:
|
2018-12-27 22:33:20 +05:30
|
|
|
msg_logger_and_die(LOG_ERR, bb_msg_bad_config, msg, line);
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function process_config_line */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static int do_servicing(int fd, unsigned long event_mask)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Service devfs changes until a signal is received.
|
|
|
|
<fd> The open control file.
|
|
|
|
<event_mask> The event mask.
|
|
|
|
[RETURNS] TRUE if SIGHUP was caught, else FALSE.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
ssize_t bytes;
|
|
|
|
struct devfsd_notify_struct info;
|
|
|
|
|
2007-08-17 13:59:48 +05:30
|
|
|
/* (void*) cast is only in order to match prototype */
|
|
|
|
xioctl(fd, DEVFSDIOC_SET_EVENT_MASK, (void*)event_mask);
|
2007-06-26 04:25:34 +05:30
|
|
|
while (!caught_signal) {
|
2003-10-09 17:16:23 +05:30
|
|
|
errno = 0;
|
2010-01-28 17:00:24 +05:30
|
|
|
bytes = read(fd, (char *) &info, sizeof info);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (caught_signal)
|
|
|
|
break; /* Must test for this first */
|
|
|
|
if (errno == EINTR)
|
|
|
|
continue; /* Yes, the order is important */
|
|
|
|
if (bytes < 1)
|
|
|
|
break;
|
2007-06-26 04:25:34 +05:30
|
|
|
service_name(&info);
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
if (caught_signal) {
|
2003-10-09 17:16:23 +05:30
|
|
|
int c_sighup = caught_sighup;
|
|
|
|
|
|
|
|
caught_signal = FALSE;
|
|
|
|
caught_sighup = FALSE;
|
2006-11-27 22:19:55 +05:30
|
|
|
return c_sighup;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 15:05:03 +05:30
|
|
|
simple_msg_logger_and_die(LOG_ERR, "read error on control file");
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function do_servicing */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void service_name(const struct devfsd_notify_struct *info)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Service a single devfs change.
|
|
|
|
<info> The devfs change.
|
|
|
|
[RETURNS] Nothing.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
unsigned int n;
|
|
|
|
regmatch_t mbuf[MAX_SUBEXPR];
|
|
|
|
struct config_entry_struct *entry;
|
|
|
|
|
2005-10-08 23:12:35 +05:30
|
|
|
if (ENABLE_DEBUG && info->overrun_count > 0)
|
2007-06-27 05:50:38 +05:30
|
|
|
msg_logger(LOG_ERR, "lost %u events", info->overrun_count);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
|
|
|
/* Discard lookups on "/dev/log" and "/dev/initctl" */
|
2007-07-18 03:12:59 +05:30
|
|
|
if (info->type == DEVFSD_NOTIFY_LOOKUP
|
2007-06-26 04:25:34 +05:30
|
|
|
&& ((info->devname[0] == 'l' && info->devname[1] == 'o'
|
2007-07-18 03:12:59 +05:30
|
|
|
&& info->devname[2] == 'g' && !info->devname[3])
|
2007-06-26 04:25:34 +05:30
|
|
|
|| (info->devname[0] == 'i' && info->devname[1] == 'n'
|
|
|
|
&& info->devname[2] == 'i' && info->devname[3] == 't'
|
|
|
|
&& info->devname[4] == 'c' && info->devname[5] == 't'
|
|
|
|
&& info->devname[6] == 'l' && !info->devname[7]))
|
|
|
|
)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (entry = first_config; entry != NULL; entry = entry->next) {
|
2003-10-09 17:16:23 +05:30
|
|
|
/* First check if action matches the type, then check if name matches */
|
2007-07-18 03:12:59 +05:30
|
|
|
if (info->type != entry->action.when
|
2007-06-26 04:25:34 +05:30
|
|
|
|| regexec(&entry->preg, info->devname, MAX_SUBEXPR, mbuf, 0) != 0)
|
2003-10-09 17:16:23 +05:30
|
|
|
continue;
|
2007-06-26 04:25:34 +05:30
|
|
|
for (n = 0;(n < MAX_SUBEXPR) && (mbuf[n].rm_so != -1); ++n)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* VOID */;
|
2006-01-25 05:38:53 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
switch (entry->action.what) {
|
2003-10-09 17:16:23 +05:30
|
|
|
case AC_PERMISSIONS:
|
2007-06-26 04:25:34 +05:30
|
|
|
action_permissions(info, entry);
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
2003-12-01 05:16:06 +05:30
|
|
|
case AC_MODLOAD:
|
2007-06-26 04:25:34 +05:30
|
|
|
if (ENABLE_DEVFSD_MODLOAD)
|
|
|
|
action_modload(info, entry);
|
2003-12-01 05:16:06 +05:30
|
|
|
break;
|
2003-10-09 17:16:23 +05:30
|
|
|
case AC_EXECUTE:
|
2007-06-26 04:25:34 +05:30
|
|
|
action_execute(info, entry, mbuf, n);
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
|
|
|
case AC_COPY:
|
2007-06-26 04:25:34 +05:30
|
|
|
action_copy(info, entry, mbuf, n);
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
|
|
|
case AC_IGNORE:
|
|
|
|
return;
|
|
|
|
/*break;*/
|
|
|
|
case AC_MKOLDCOMPAT:
|
|
|
|
case AC_MKNEWCOMPAT:
|
|
|
|
case AC_RMOLDCOMPAT:
|
|
|
|
case AC_RMNEWCOMPAT:
|
2007-06-26 04:25:34 +05:30
|
|
|
action_compat(info, entry->action.what);
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
|
|
|
default:
|
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 15:05:03 +05:30
|
|
|
simple_msg_logger_and_die(LOG_ERR, "Unknown action");
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* End Function service_name */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void action_permissions(const struct devfsd_notify_struct *info,
|
2003-10-09 17:16:23 +05:30
|
|
|
const struct config_entry_struct *entry)
|
|
|
|
/* [SUMMARY] Update permissions for a device entry.
|
|
|
|
<info> The devfs change.
|
|
|
|
<entry> The config file entry.
|
|
|
|
[RETURNS] Nothing.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
struct stat statbuf;
|
|
|
|
|
2007-07-02 03:55:33 +05:30
|
|
|
if (stat(info->devname, &statbuf) != 0
|
|
|
|
|| chmod(info->devname, (statbuf.st_mode & S_IFMT) | (entry->u.permissions.mode & ~S_IFMT)) != 0
|
|
|
|
|| chown(info->devname, entry->u.permissions.uid, entry->u.permissions.gid) != 0
|
2007-06-27 05:50:38 +05:30
|
|
|
)
|
2007-07-02 03:55:33 +05:30
|
|
|
error_logger(LOG_ERR, "Can't chmod or chown: %s", info->devname);
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function action_permissions */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void action_modload(const struct devfsd_notify_struct *info,
|
2013-01-14 20:27:44 +05:30
|
|
|
const struct config_entry_struct *entry UNUSED_PARAM)
|
2003-12-01 05:16:06 +05:30
|
|
|
/* [SUMMARY] Load a module.
|
|
|
|
<info> The devfs change.
|
|
|
|
<entry> The config file entry.
|
|
|
|
[RETURNS] Nothing.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
char *argv[6];
|
|
|
|
|
2007-07-02 03:55:33 +05:30
|
|
|
argv[0] = (char*)MODPROBE;
|
|
|
|
argv[1] = (char*)MODPROBE_SWITCH_1; /* "-k" */
|
|
|
|
argv[2] = (char*)MODPROBE_SWITCH_2; /* "-C" */
|
|
|
|
argv[3] = (char*)CONFIG_MODULES_DEVFS;
|
2007-06-27 05:50:38 +05:30
|
|
|
argv[4] = concat_path_file("/dev", info->devname); /* device */
|
2003-12-01 05:16:06 +05:30
|
|
|
argv[5] = NULL;
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2010-03-19 03:14:00 +05:30
|
|
|
spawn_and_wait(argv);
|
2007-06-27 05:50:38 +05:30
|
|
|
free(argv[4]);
|
2003-12-01 05:16:06 +05:30
|
|
|
} /* End Function action_modload */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void action_execute(const struct devfsd_notify_struct *info,
|
2013-01-14 20:27:44 +05:30
|
|
|
const struct config_entry_struct *entry,
|
|
|
|
const regmatch_t *regexpr, unsigned int numexpr)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Execute a programme.
|
|
|
|
<info> The devfs change.
|
|
|
|
<entry> The config file entry.
|
2007-06-26 04:25:34 +05:30
|
|
|
<regexpr> The number of subexpression(start, end) offsets within the
|
2003-10-09 17:16:23 +05:30
|
|
|
device name.
|
|
|
|
<numexpr> The number of elements within <<regexpr>>.
|
|
|
|
[RETURNS] Nothing.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
unsigned int count;
|
|
|
|
struct get_variable_info gv_info;
|
|
|
|
char *argv[MAX_ARGS + 1];
|
|
|
|
char largv[MAX_ARGS + 1][STRING_LENGTH];
|
|
|
|
|
|
|
|
gv_info.info = info;
|
|
|
|
gv_info.devname = info->devname;
|
2007-06-26 04:25:34 +05:30
|
|
|
snprintf(gv_info.devpath, sizeof(gv_info.devpath), "%s/%s", mount_point, info->devname);
|
|
|
|
for (count = 0; entry->u.execute.argv[count] != NULL; ++count) {
|
|
|
|
expand_expression(largv[count], STRING_LENGTH,
|
2003-10-09 17:16:23 +05:30
|
|
|
entry->u.execute.argv[count],
|
|
|
|
get_variable, &gv_info,
|
2007-06-26 04:25:34 +05:30
|
|
|
gv_info.devname, regexpr, numexpr);
|
2003-10-09 17:16:23 +05:30
|
|
|
argv[count] = largv[count];
|
|
|
|
}
|
|
|
|
argv[count] = NULL;
|
2010-03-19 03:14:00 +05:30
|
|
|
spawn_and_wait(argv);
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function action_execute */
|
|
|
|
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void action_copy(const struct devfsd_notify_struct *info,
|
2013-01-15 18:28:01 +05:30
|
|
|
const struct config_entry_struct *entry,
|
|
|
|
const regmatch_t *regexpr, unsigned int numexpr)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Copy permissions.
|
|
|
|
<info> The devfs change.
|
|
|
|
<entry> The config file entry.
|
2007-06-26 04:25:34 +05:30
|
|
|
<regexpr> This list of subexpression(start, end) offsets within the
|
2003-10-09 17:16:23 +05:30
|
|
|
device name.
|
|
|
|
<numexpr> The number of elements in <<regexpr>>.
|
|
|
|
[RETURNS] Nothing.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
mode_t new_mode;
|
|
|
|
struct get_variable_info gv_info;
|
|
|
|
struct stat source_stat, dest_stat;
|
|
|
|
char source[STRING_LENGTH], destination[STRING_LENGTH];
|
2005-10-08 23:12:35 +05:30
|
|
|
int ret = 0;
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2005-10-08 23:12:35 +05:30
|
|
|
dest_stat.st_mode = 0;
|
2006-01-25 05:38:53 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if ((info->type == DEVFSD_NOTIFY_CHANGE) && S_ISLNK(info->mode))
|
2003-10-09 17:16:23 +05:30
|
|
|
return;
|
|
|
|
gv_info.info = info;
|
|
|
|
gv_info.devname = info->devname;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
snprintf(gv_info.devpath, sizeof(gv_info.devpath), "%s/%s", mount_point, info->devname);
|
|
|
|
expand_expression(source, STRING_LENGTH, entry->u.copy.source,
|
2003-10-09 17:16:23 +05:30
|
|
|
get_variable, &gv_info, gv_info.devname,
|
|
|
|
regexpr, numexpr);
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
expand_expression(destination, STRING_LENGTH, entry->u.copy.destination,
|
2003-10-09 17:16:23 +05:30
|
|
|
get_variable, &gv_info, gv_info.devname,
|
|
|
|
regexpr, numexpr);
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (!make_dir_tree(destination) || lstat(source, &source_stat) != 0)
|
2003-12-01 05:16:06 +05:30
|
|
|
return;
|
2007-06-26 04:25:34 +05:30
|
|
|
lstat(destination, &dest_stat);
|
2003-10-09 17:16:23 +05:30
|
|
|
new_mode = source_stat.st_mode & ~S_ISVTX;
|
|
|
|
if (info->type == DEVFSD_NOTIFY_CREATE)
|
|
|
|
new_mode |= S_ISVTX;
|
2007-06-26 04:25:34 +05:30
|
|
|
else if ((info->type == DEVFSD_NOTIFY_CHANGE) &&(dest_stat.st_mode & S_ISVTX))
|
2003-10-09 17:16:23 +05:30
|
|
|
new_mode |= S_ISVTX;
|
2007-06-26 04:25:34 +05:30
|
|
|
ret = copy_inode(destination, &dest_stat, new_mode, source, &source_stat);
|
2007-06-27 05:50:38 +05:30
|
|
|
if (ENABLE_DEBUG && ret && (errno != EEXIST))
|
2007-07-02 03:55:33 +05:30
|
|
|
error_logger(LOG_ERR, "copy_inode: %s to %s", source, destination);
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function action_copy */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void action_compat(const struct devfsd_notify_struct *info, unsigned int action)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Process a compatibility request.
|
|
|
|
<info> The devfs change.
|
|
|
|
<action> The action to take.
|
|
|
|
[RETURNS] Nothing.
|
|
|
|
*/
|
|
|
|
{
|
2005-10-08 23:12:35 +05:30
|
|
|
int ret;
|
2003-10-09 17:16:23 +05:30
|
|
|
const char *compat_name = NULL;
|
|
|
|
const char *dest_name = info->devname;
|
2007-06-30 13:34:05 +05:30
|
|
|
const char *ptr;
|
2003-10-09 17:16:23 +05:30
|
|
|
char compat_buf[STRING_LENGTH], dest_buf[STRING_LENGTH];
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
int mode, host, bus, target, lun;
|
|
|
|
unsigned int i;
|
|
|
|
char rewind_;
|
|
|
|
/* 1 to 5 "scsi/" , 6 to 9 "ide/host" */
|
2022-02-07 00:37:12 +05:30
|
|
|
static const char *const fmt[] ALIGN_PTR = {
|
2006-02-22 22:31:00 +05:30
|
|
|
NULL ,
|
|
|
|
"sg/c%db%dt%du%d", /* scsi/generic */
|
|
|
|
"sd/c%db%dt%du%d", /* scsi/disc */
|
|
|
|
"sr/c%db%dt%du%d", /* scsi/cd */
|
|
|
|
"sd/c%db%dt%du%dp%d", /* scsi/part */
|
|
|
|
"st/c%db%dt%du%dm%d%c", /* scsi/mt */
|
|
|
|
"ide/hd/c%db%dt%du%d", /* ide/host/disc */
|
|
|
|
"ide/cd/c%db%dt%du%d", /* ide/host/cd */
|
|
|
|
"ide/hd/c%db%dt%du%dp%d", /* ide/host/part */
|
|
|
|
"ide/mt/c%db%dt%du%d%s", /* ide/host/mt */
|
|
|
|
NULL
|
|
|
|
};
|
2003-10-09 17:16:23 +05:30
|
|
|
|
|
|
|
/* First construct compatibility name */
|
2007-06-26 04:25:34 +05:30
|
|
|
switch (action) {
|
2003-10-09 17:16:23 +05:30
|
|
|
case AC_MKOLDCOMPAT:
|
|
|
|
case AC_RMOLDCOMPAT:
|
2007-06-26 04:25:34 +05:30
|
|
|
compat_name = get_old_name(info->devname, info->namelen, compat_buf, info->major, info->minor);
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
|
|
|
case AC_MKNEWCOMPAT:
|
|
|
|
case AC_RMNEWCOMPAT:
|
2007-06-30 13:34:05 +05:30
|
|
|
ptr = bb_basename(info->devname);
|
2007-06-27 05:50:38 +05:30
|
|
|
i = scan_dev_name(info->devname, info->namelen, ptr);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
|
|
|
/* nothing found */
|
2007-06-27 05:50:38 +05:30
|
|
|
if (i == 0 || i > 9)
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
return;
|
|
|
|
|
2007-06-27 05:50:38 +05:30
|
|
|
sscanf(info->devname + ((i < 6) ? 5 : 4), "host%d/bus%d/target%d/lun%d/", &host, &bus, &target, &lun);
|
|
|
|
snprintf(dest_buf, sizeof(dest_buf), "../%s", info->devname + (( i > 5) ? 4 : 0));
|
2003-10-09 17:16:23 +05:30
|
|
|
dest_name = dest_buf;
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
compat_name = compat_buf;
|
2003-10-09 17:16:23 +05:30
|
|
|
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
|
|
|
/* 1 == scsi/generic 2 == scsi/disc 3 == scsi/cd 6 == ide/host/disc 7 == ide/host/cd */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 1 || i == 2 || i == 3 || i == 6 || i ==7)
|
|
|
|
sprintf(compat_buf, fmt[i], host, bus, target, lun);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
|
|
|
/* 4 == scsi/part 8 == ide/host/part */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 4 || i == 8)
|
|
|
|
sprintf(compat_buf, fmt[i], host, bus, target, lun, atoi(ptr + 4));
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
|
|
|
/* 5 == scsi/mt */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 5) {
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
rewind_ = info->devname[info->namelen - 1];
|
2003-10-09 17:16:23 +05:30
|
|
|
if (rewind_ != 'n')
|
|
|
|
rewind_ = '\0';
|
2022-08-30 20:11:17 +05:30
|
|
|
mode = 0;
|
2007-06-26 04:25:34 +05:30
|
|
|
if (ptr[2] == 'l' /*108*/ || ptr[2] == 'm'/*109*/)
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
mode = ptr[2] - 107; /* 1 or 2 */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (ptr[2] == 'a')
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
mode = 3;
|
2007-06-27 05:50:38 +05:30
|
|
|
sprintf(compat_buf, fmt[i], host, bus, target, lun, mode, rewind_);
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
/* 9 == ide/host/mt */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 9)
|
|
|
|
snprintf(compat_buf, sizeof(compat_buf), fmt[i], host, bus, target, lun, ptr + 2);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
/* esac */
|
2006-12-26 16:12:51 +05:30
|
|
|
} /* switch (action) */
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (compat_name == NULL)
|
2003-10-09 17:16:23 +05:30
|
|
|
return;
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2003-10-09 17:16:23 +05:30
|
|
|
/* Now decide what to do with it */
|
2007-06-26 04:25:34 +05:30
|
|
|
switch (action) {
|
2003-10-09 17:16:23 +05:30
|
|
|
case AC_MKOLDCOMPAT:
|
|
|
|
case AC_MKNEWCOMPAT:
|
2007-06-26 04:25:34 +05:30
|
|
|
mksymlink(dest_name, compat_name);
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
|
|
|
case AC_RMOLDCOMPAT:
|
|
|
|
case AC_RMNEWCOMPAT:
|
2007-06-26 04:25:34 +05:30
|
|
|
ret = unlink(compat_name);
|
2005-10-08 23:12:35 +05:30
|
|
|
if (ENABLE_DEBUG && ret)
|
2007-07-02 03:55:33 +05:30
|
|
|
error_logger(LOG_ERR, "unlink: %s", compat_name);
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
/*esac*/
|
2006-12-26 16:12:51 +05:30
|
|
|
} /* switch (action) */
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function action_compat */
|
|
|
|
|
2003-12-01 05:16:06 +05:30
|
|
|
static void restore(char *spath, struct stat source_stat, int rootlen)
|
2003-10-09 17:16:23 +05:30
|
|
|
{
|
2007-06-27 05:50:38 +05:30
|
|
|
char *dpath;
|
2003-12-01 05:16:06 +05:30
|
|
|
struct stat dest_stat;
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2003-12-01 05:16:06 +05:30
|
|
|
dest_stat.st_mode = 0;
|
2007-06-27 05:50:38 +05:30
|
|
|
dpath = concat_path_file(mount_point, spath + rootlen);
|
2007-06-26 04:25:34 +05:30
|
|
|
lstat(dpath, &dest_stat);
|
2007-06-27 05:50:38 +05:30
|
|
|
free(dpath);
|
2007-07-02 03:55:33 +05:30
|
|
|
if (S_ISLNK(source_stat.st_mode) || (source_stat.st_mode & S_ISVTX))
|
2010-01-28 17:00:24 +05:30
|
|
|
copy_inode(dpath, &dest_stat, (source_stat.st_mode & ~S_ISVTX), spath, &source_stat);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (S_ISDIR(source_stat.st_mode))
|
2010-01-28 17:00:24 +05:30
|
|
|
dir_operation(RESTORE, spath, rootlen, NULL);
|
2003-12-01 05:16:06 +05:30
|
|
|
}
|
2003-10-09 17:16:23 +05:30
|
|
|
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static int copy_inode(const char *destpath, const struct stat *dest_stat,
|
2003-10-09 17:16:23 +05:30
|
|
|
mode_t new_mode,
|
|
|
|
const char *sourcepath, const struct stat *source_stat)
|
|
|
|
/* [SUMMARY] Copy an inode.
|
|
|
|
<destpath> The destination path. An existing inode may be deleted.
|
|
|
|
<dest_stat> The destination stat(2) information.
|
|
|
|
<new_mode> The desired new mode for the destination.
|
|
|
|
<sourcepath> The source path.
|
|
|
|
<source_stat> The source stat(2) information.
|
|
|
|
[RETURNS] TRUE on success, else FALSE.
|
|
|
|
*/
|
|
|
|
{
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
int source_len, dest_len;
|
|
|
|
char source_link[STRING_LENGTH], dest_link[STRING_LENGTH];
|
|
|
|
int fd, val;
|
|
|
|
struct sockaddr_un un_addr;
|
|
|
|
char symlink_val[STRING_LENGTH];
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if ((source_stat->st_mode & S_IFMT) ==(dest_stat->st_mode & S_IFMT)) {
|
2003-10-09 17:16:23 +05:30
|
|
|
/* Same type */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (S_ISLNK(source_stat->st_mode)) {
|
2007-11-06 08:35:54 +05:30
|
|
|
source_len = readlink(sourcepath, source_link, STRING_LENGTH - 1);
|
|
|
|
if ((source_len < 0)
|
|
|
|
|| (dest_len = readlink(destpath, dest_link, STRING_LENGTH - 1)) < 0
|
2007-06-26 04:25:34 +05:30
|
|
|
)
|
2006-11-27 22:19:55 +05:30
|
|
|
return FALSE;
|
2003-10-09 17:16:23 +05:30
|
|
|
source_link[source_len] = '\0';
|
2006-01-25 05:38:53 +05:30
|
|
|
dest_link[dest_len] = '\0';
|
2007-06-26 04:25:34 +05:30
|
|
|
if ((source_len != dest_len) || (strcmp(source_link, dest_link) != 0)) {
|
|
|
|
unlink(destpath);
|
|
|
|
symlink(source_link, destpath);
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2006-11-27 22:19:55 +05:30
|
|
|
return TRUE;
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* Else not a symlink */
|
2007-06-26 04:25:34 +05:30
|
|
|
chmod(destpath, new_mode & ~S_IFMT);
|
|
|
|
chown(destpath, source_stat->st_uid, source_stat->st_gid);
|
2006-11-27 22:19:55 +05:30
|
|
|
return TRUE;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
/* Different types: unlink and create */
|
2007-06-26 04:25:34 +05:30
|
|
|
unlink(destpath);
|
|
|
|
switch (source_stat->st_mode & S_IFMT) {
|
2003-10-09 17:16:23 +05:30
|
|
|
case S_IFSOCK:
|
2007-11-06 08:35:54 +05:30
|
|
|
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
|
|
|
if (fd < 0)
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
|
|
|
un_addr.sun_family = AF_UNIX;
|
2007-06-26 04:25:34 +05:30
|
|
|
snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s", destpath);
|
2010-01-28 17:00:24 +05:30
|
|
|
val = bind(fd, (struct sockaddr *) &un_addr, (int) sizeof un_addr);
|
2007-06-26 04:25:34 +05:30
|
|
|
close(fd);
|
|
|
|
if (val != 0 || chmod(destpath, new_mode & ~S_IFMT) != 0)
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
2003-12-01 05:16:06 +05:30
|
|
|
goto do_chown;
|
2003-10-09 17:16:23 +05:30
|
|
|
case S_IFLNK:
|
2007-11-06 08:35:54 +05:30
|
|
|
val = readlink(sourcepath, symlink_val, STRING_LENGTH - 1);
|
|
|
|
if (val < 0)
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
|
|
|
symlink_val[val] = '\0';
|
2007-06-26 04:25:34 +05:30
|
|
|
if (symlink(symlink_val, destpath) == 0)
|
2006-11-27 22:19:55 +05:30
|
|
|
return TRUE;
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
|
|
|
case S_IFREG:
|
2007-11-06 08:35:54 +05:30
|
|
|
fd = open(destpath, O_RDONLY | O_CREAT, new_mode & ~S_IFMT);
|
|
|
|
if (fd < 0)
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
2007-06-26 04:25:34 +05:30
|
|
|
close(fd);
|
|
|
|
if (chmod(destpath, new_mode & ~S_IFMT) != 0)
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
2003-12-01 05:16:06 +05:30
|
|
|
goto do_chown;
|
2003-10-09 17:16:23 +05:30
|
|
|
case S_IFBLK:
|
|
|
|
case S_IFCHR:
|
|
|
|
case S_IFIFO:
|
2007-06-26 04:25:34 +05:30
|
|
|
if (mknod(destpath, new_mode, source_stat->st_rdev) != 0)
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
2003-12-01 05:16:06 +05:30
|
|
|
goto do_chown;
|
2003-10-09 17:16:23 +05:30
|
|
|
case S_IFDIR:
|
2007-06-26 04:25:34 +05:30
|
|
|
if (mkdir(destpath, new_mode & ~S_IFMT) != 0)
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
2003-12-01 05:16:06 +05:30
|
|
|
do_chown:
|
2007-06-26 04:25:34 +05:30
|
|
|
if (chown(destpath, source_stat->st_uid, source_stat->st_gid) == 0)
|
2006-11-27 22:19:55 +05:30
|
|
|
return TRUE;
|
2020-12-29 21:23:11 +05:30
|
|
|
/*break;*/
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2006-11-27 22:19:55 +05:30
|
|
|
return FALSE;
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function copy_inode */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void free_config(void)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Free the configuration information.
|
|
|
|
[RETURNS] Nothing.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
struct config_entry_struct *c_entry;
|
|
|
|
void *next;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
for (c_entry = first_config; c_entry != NULL; c_entry = next) {
|
2003-10-09 17:16:23 +05:30
|
|
|
unsigned int count;
|
|
|
|
|
|
|
|
next = c_entry->next;
|
2007-06-26 04:25:34 +05:30
|
|
|
regfree(&c_entry->preg);
|
|
|
|
if (c_entry->action.what == AC_EXECUTE) {
|
|
|
|
for (count = 0; count < MAX_ARGS; ++count) {
|
2003-10-09 17:16:23 +05:30
|
|
|
if (c_entry->u.execute.argv[count] == NULL)
|
|
|
|
break;
|
2007-06-26 04:25:34 +05:30
|
|
|
free(c_entry->u.execute.argv[count]);
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
free(c_entry);
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
first_config = NULL;
|
|
|
|
last_config = NULL;
|
|
|
|
} /* End Function free_config */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static int get_uid_gid(int flag, const char *string)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Convert a string to a UID or GID value.
|
|
|
|
<flag> "UID" or "GID".
|
|
|
|
<string> The string.
|
|
|
|
[RETURNS] The UID or GID value.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
struct passwd *pw_ent;
|
|
|
|
struct group *grp_ent;
|
2013-11-26 16:42:27 +05:30
|
|
|
const char *msg;
|
2006-01-25 05:38:53 +05:30
|
|
|
|
2013-11-26 16:42:27 +05:30
|
|
|
if (isdigit(string[0]) || ((string[0] == '-') && isdigit(string[1])))
|
2006-11-27 22:19:55 +05:30
|
|
|
return atoi(string);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-11-06 08:35:54 +05:30
|
|
|
if (flag == UID && (pw_ent = getpwnam(string)) != NULL)
|
2006-11-27 22:19:55 +05:30
|
|
|
return pw_ent->pw_uid;
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2013-11-26 16:42:27 +05:30
|
|
|
if (ENABLE_DEVFSD_VERBOSE)
|
|
|
|
msg = "user";
|
|
|
|
|
|
|
|
if (flag == GID) {
|
|
|
|
if ((grp_ent = getgrnam(string)) != NULL)
|
|
|
|
return grp_ent->gr_gid;
|
|
|
|
if (ENABLE_DEVFSD_VERBOSE)
|
|
|
|
msg = "group";
|
|
|
|
}
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (ENABLE_DEVFSD_VERBOSE)
|
2008-06-26 20:02:57 +05:30
|
|
|
msg_logger(LOG_ERR, "unknown %s: %s, defaulting to %cid=0", msg, string, msg[0]);
|
2006-11-27 22:19:31 +05:30
|
|
|
return 0;
|
2003-10-09 17:16:23 +05:30
|
|
|
}/* End Function get_uid_gid */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static mode_t get_mode(const char *string)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Convert a string to a mode value.
|
|
|
|
<string> The string.
|
|
|
|
[RETURNS] The mode value.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
mode_t mode;
|
2003-12-01 05:16:06 +05:30
|
|
|
int i;
|
2005-10-08 23:12:35 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (isdigit(string[0]))
|
2006-11-27 22:19:55 +05:30
|
|
|
return strtoul(string, NULL, 8);
|
2007-06-26 04:25:34 +05:30
|
|
|
if (strlen(string) != 9)
|
2005-10-08 23:12:35 +05:30
|
|
|
msg_logger_and_die(LOG_ERR, "bad mode: %s", string);
|
2006-01-25 05:38:53 +05:30
|
|
|
|
2003-10-09 17:16:23 +05:30
|
|
|
mode = 0;
|
2007-06-26 04:25:34 +05:30
|
|
|
i = S_IRUSR;
|
|
|
|
while (i > 0) {
|
|
|
|
if (string[0] == 'r' || string[0] == 'w' || string[0] == 'x')
|
|
|
|
mode += i;
|
2007-06-27 05:50:38 +05:30
|
|
|
i = i / 2;
|
2003-12-01 05:16:06 +05:30
|
|
|
string++;
|
|
|
|
}
|
2006-11-27 22:19:55 +05:30
|
|
|
return mode;
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function get_mode */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void signal_handler(int sig)
|
2003-10-09 17:16:23 +05:30
|
|
|
{
|
|
|
|
caught_signal = TRUE;
|
|
|
|
if (sig == SIGHUP)
|
|
|
|
caught_sighup = TRUE;
|
2005-10-08 23:12:35 +05:30
|
|
|
|
2007-07-02 03:55:33 +05:30
|
|
|
info_logger(LOG_INFO, "Caught signal %d", sig);
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function signal_handler */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static const char *get_variable(const char *variable, void *info)
|
2003-10-09 17:16:23 +05:30
|
|
|
{
|
2008-02-26 04:53:58 +05:30
|
|
|
static char *hostname;
|
2007-07-24 21:24:42 +05:30
|
|
|
|
2003-10-09 17:16:23 +05:30
|
|
|
struct get_variable_info *gv_info = info;
|
2007-07-24 21:24:42 +05:30
|
|
|
const char *field_names[] = {
|
2015-10-09 21:46:40 +05:30
|
|
|
"hostname", "mntpt", "devpath", "devname", "uid", "gid", "mode",
|
|
|
|
NULL, mount_point, gv_info->devpath, gv_info->devname, NULL
|
2007-07-24 21:24:42 +05:30
|
|
|
};
|
2005-12-06 17:30:39 +05:30
|
|
|
int i;
|
2005-10-08 23:12:35 +05:30
|
|
|
|
2008-02-26 04:53:58 +05:30
|
|
|
if (!hostname)
|
|
|
|
hostname = safe_gethostname();
|
2015-10-09 21:46:40 +05:30
|
|
|
field_names[7] = hostname;
|
|
|
|
|
2006-11-05 23:35:09 +05:30
|
|
|
/* index_in_str_array returns i>=0 */
|
2007-06-26 04:25:34 +05:30
|
|
|
i = index_in_str_array(field_names, variable);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i > 6 || i < 0 || (i > 1 && gv_info == NULL))
|
2007-07-24 21:24:42 +05:30
|
|
|
return NULL;
|
|
|
|
if (i >= 0 && i <= 3)
|
2007-06-26 04:25:34 +05:30
|
|
|
return field_names[i + 7];
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 4)
|
2015-10-09 21:46:40 +05:30
|
|
|
return auto_string(xasprintf("%u", gv_info->info->uid));
|
|
|
|
if (i == 5)
|
|
|
|
return auto_string(xasprintf("%u", gv_info->info->gid));
|
|
|
|
/* i == 6 */
|
|
|
|
return auto_string(xasprintf("%o", gv_info->info->mode));
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function get_variable */
|
|
|
|
|
2003-12-01 05:16:06 +05:30
|
|
|
static void service(struct stat statbuf, char *path)
|
|
|
|
{
|
|
|
|
struct devfsd_notify_struct info;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
memset(&info, 0, sizeof info);
|
2003-12-01 05:16:06 +05:30
|
|
|
info.type = DEVFSD_NOTIFY_REGISTERED;
|
|
|
|
info.mode = statbuf.st_mode;
|
2007-06-26 04:25:34 +05:30
|
|
|
info.major = major(statbuf.st_rdev);
|
|
|
|
info.minor = minor(statbuf.st_rdev);
|
2003-12-01 05:16:06 +05:30
|
|
|
info.uid = statbuf.st_uid;
|
|
|
|
info.gid = statbuf.st_gid;
|
2007-06-26 04:25:34 +05:30
|
|
|
snprintf(info.devname, sizeof(info.devname), "%s", path + strlen(mount_point) + 1);
|
|
|
|
info.namelen = strlen(info.devname);
|
|
|
|
service_name(&info);
|
|
|
|
if (S_ISDIR(statbuf.st_mode))
|
|
|
|
dir_operation(SERVICE, path, 0, NULL);
|
2003-12-01 05:16:06 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
static void dir_operation(int type, const char * dir_name, int var, unsigned long *event_mask)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Scan a directory tree and generate register events on leaf nodes.
|
2003-12-01 05:16:06 +05:30
|
|
|
<flag> To choose which function to perform
|
|
|
|
<dp> The directory pointer. This is closed upon completion.
|
2003-10-09 17:16:23 +05:30
|
|
|
<dir_name> The name of the directory.
|
2003-12-01 05:16:06 +05:30
|
|
|
<rootlen> string length parameter.
|
2003-10-09 17:16:23 +05:30
|
|
|
[RETURNS] Nothing.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
struct stat statbuf;
|
|
|
|
DIR *dp;
|
|
|
|
struct dirent *de;
|
2007-06-27 05:50:38 +05:30
|
|
|
char *path;
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-11-06 08:35:54 +05:30
|
|
|
dp = warn_opendir(dir_name);
|
|
|
|
if (dp == NULL)
|
2003-10-09 17:16:23 +05:30
|
|
|
return;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
while ((de = readdir(dp)) != NULL) {
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (de->d_name && DOT_OR_DOTDOT(de->d_name))
|
2003-10-09 17:16:23 +05:30
|
|
|
continue;
|
2007-06-27 05:50:38 +05:30
|
|
|
path = concat_path_file(dir_name, de->d_name);
|
|
|
|
if (lstat(path, &statbuf) == 0) {
|
|
|
|
switch (type) {
|
|
|
|
case SERVICE:
|
|
|
|
service(statbuf, path);
|
|
|
|
break;
|
|
|
|
case RESTORE:
|
|
|
|
restore(path, statbuf, var);
|
|
|
|
break;
|
|
|
|
case READ_CONFIG:
|
|
|
|
read_config_file(path, var, event_mask);
|
|
|
|
break;
|
|
|
|
}
|
2003-12-01 05:16:06 +05:30
|
|
|
}
|
2007-06-27 05:50:38 +05:30
|
|
|
free(path);
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
closedir(dp);
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function do_scan_and_service */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static int mksymlink(const char *oldpath, const char *newpath)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Create a symlink, creating intervening directories as required.
|
|
|
|
<oldpath> The string contained in the symlink.
|
|
|
|
<newpath> The name of the new symlink.
|
|
|
|
[RETURNS] 0 on success, else -1.
|
|
|
|
*/
|
|
|
|
{
|
2007-06-26 04:25:34 +05:30
|
|
|
if (!make_dir_tree(newpath))
|
2006-11-27 22:19:31 +05:30
|
|
|
return -1;
|
2003-10-09 17:16:23 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (symlink(oldpath, newpath) != 0) {
|
2007-06-27 05:50:38 +05:30
|
|
|
if (errno != EEXIST)
|
2006-11-27 22:19:31 +05:30
|
|
|
return -1;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2006-11-27 22:19:31 +05:30
|
|
|
return 0;
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function mksymlink */
|
|
|
|
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static int make_dir_tree(const char *path)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Creating intervening directories for a path as required.
|
2007-06-26 04:25:34 +05:30
|
|
|
<path> The full pathname(including the leaf node).
|
2003-10-09 17:16:23 +05:30
|
|
|
[RETURNS] TRUE on success, else FALSE.
|
|
|
|
*/
|
|
|
|
{
|
2007-06-27 05:50:38 +05:30
|
|
|
if (bb_make_directory(dirname((char *)path), -1, FILEUTILS_RECUR) == -1)
|
2006-11-27 22:19:55 +05:30
|
|
|
return FALSE;
|
2006-11-27 22:19:31 +05:30
|
|
|
return TRUE;
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function make_dir_tree */
|
|
|
|
|
|
|
|
static int expand_expression(char *output, unsigned int outsize,
|
2013-01-15 18:28:01 +05:30
|
|
|
const char *input,
|
|
|
|
const char *(*get_variable_func)(const char *variable, void *info),
|
|
|
|
void *info,
|
|
|
|
const char *devname,
|
|
|
|
const regmatch_t *ex, unsigned int numexp)
|
2004-04-14 23:21:38 +05:30
|
|
|
/* [SUMMARY] Expand environment variables and regular subexpressions in string.
|
2003-10-09 17:16:23 +05:30
|
|
|
<output> The output expanded expression is written here.
|
|
|
|
<length> The size of the output buffer.
|
|
|
|
<input> The input expression. This may equal <<output>>.
|
|
|
|
<get_variable> A function which will be used to get variable values. If
|
|
|
|
this returns NULL, the environment is searched instead. If this is NULL,
|
|
|
|
only the environment is searched.
|
|
|
|
<info> An arbitrary pointer passed to <<get_variable>>.
|
|
|
|
<devname> Device name; specifically, this is the string that contains all
|
|
|
|
of the regular subexpressions.
|
|
|
|
<ex> Array of start / end offsets into info->devname for each subexpression
|
|
|
|
<numexp> Number of regular subexpressions found in <<devname>>.
|
|
|
|
[RETURNS] TRUE on success, else FALSE.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
char temp[STRING_LENGTH];
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (!st_expr_expand(temp, STRING_LENGTH, input, get_variable_func, info))
|
2006-11-27 22:19:55 +05:30
|
|
|
return FALSE;
|
2007-06-26 04:25:34 +05:30
|
|
|
expand_regexp(output, outsize, temp, devname, ex, numexp);
|
2006-11-27 22:19:55 +05:30
|
|
|
return TRUE;
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function expand_expression */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static void expand_regexp(char *output, size_t outsize, const char *input,
|
2013-01-15 18:28:01 +05:30
|
|
|
const char *devname,
|
|
|
|
const regmatch_t *ex, unsigned int numex)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Expand all occurrences of the regular subexpressions \0 to \9.
|
|
|
|
<output> The output expanded expression is written here.
|
|
|
|
<outsize> The size of the output buffer.
|
|
|
|
<input> The input expression. This may NOT equal <<output>>, because
|
|
|
|
supporting that would require yet another string-copy. However, it's not
|
|
|
|
hard to write a simple wrapper function to add this functionality for those
|
|
|
|
few cases that need it.
|
|
|
|
<devname> Device name; specifically, this is the string that contains all
|
|
|
|
of the regular subexpressions.
|
|
|
|
<ex> An array of start and end offsets into <<devname>>, one for each
|
|
|
|
subexpression
|
|
|
|
<numex> Number of subexpressions in the offset-array <<ex>>.
|
|
|
|
[RETURNS] Nothing.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
const char last_exp = '0' - 1 + numex;
|
|
|
|
int c = -1;
|
|
|
|
|
|
|
|
/* Guarantee NULL termination by writing an explicit '\0' character into
|
|
|
|
the very last byte */
|
|
|
|
if (outsize)
|
|
|
|
output[--outsize] = '\0';
|
|
|
|
/* Copy the input string into the output buffer, replacing '\\' with '\'
|
|
|
|
and '\0' .. '\9' with subexpressions 0 .. 9, if they exist. Other \x
|
|
|
|
codes are deleted */
|
2007-06-26 04:25:34 +05:30
|
|
|
while ((c != '\0') && (outsize != 0)) {
|
2003-10-09 17:16:23 +05:30
|
|
|
c = *input;
|
|
|
|
++input;
|
2007-06-26 04:25:34 +05:30
|
|
|
if (c == '\\') {
|
2003-10-09 17:16:23 +05:30
|
|
|
c = *input;
|
|
|
|
++input;
|
2007-06-26 04:25:34 +05:30
|
|
|
if (c != '\\') {
|
|
|
|
if ((c >= '0') && (c <= last_exp)) {
|
2003-10-09 17:16:23 +05:30
|
|
|
const regmatch_t *subexp = ex + (c - '0');
|
|
|
|
unsigned int sublen = subexp->rm_eo - subexp->rm_so;
|
|
|
|
|
|
|
|
/* Range checking */
|
|
|
|
if (sublen > outsize)
|
|
|
|
sublen = outsize;
|
2007-06-26 04:25:34 +05:30
|
|
|
strncpy(output, devname + subexp->rm_so, sublen);
|
2003-10-09 17:16:23 +05:30
|
|
|
output += sublen;
|
|
|
|
outsize -= sublen;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*output = c;
|
|
|
|
++output;
|
|
|
|
--outsize;
|
|
|
|
} /* while */
|
|
|
|
} /* End Function expand_regexp */
|
|
|
|
|
|
|
|
|
|
|
|
/* from compat_name.c */
|
|
|
|
|
2009-06-05 15:36:05 +05:30
|
|
|
struct translate_struct {
|
2007-06-26 04:25:34 +05:30
|
|
|
const char *match; /* The string to match to(up to length) */
|
2007-01-30 05:13:18 +05:30
|
|
|
const char *format; /* Format of output, "%s" takes data past match string,
|
2007-06-26 04:25:34 +05:30
|
|
|
NULL is effectively "%s"(just more efficient) */
|
2003-10-09 17:16:23 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
static struct translate_struct translate_table[] =
|
|
|
|
{
|
|
|
|
{"sound/", NULL},
|
|
|
|
{"printers/", "lp%s"},
|
|
|
|
{"v4l/", NULL},
|
|
|
|
{"parports/", "parport%s"},
|
|
|
|
{"fb/", "fb%s"},
|
|
|
|
{"netlink/", NULL},
|
|
|
|
{"loop/", "loop%s"},
|
|
|
|
{"floppy/", "fd%s"},
|
|
|
|
{"rd/", "ram%s"},
|
|
|
|
{"md/", "md%s"}, /* Meta-devices */
|
|
|
|
{"vc/", "tty%s"},
|
|
|
|
{"misc/", NULL},
|
|
|
|
{"isdn/", NULL},
|
|
|
|
{"pg/", "pg%s"}, /* Parallel port generic ATAPI interface*/
|
|
|
|
{"i2c/", "i2c-%s"},
|
|
|
|
{"staliomem/", "staliomem%s"}, /* Stallion serial driver control */
|
|
|
|
{"tts/E", "ttyE%s"}, /* Stallion serial driver */
|
|
|
|
{"cua/E", "cue%s"}, /* Stallion serial driver callout */
|
|
|
|
{"tts/R", "ttyR%s"}, /* Rocketport serial driver */
|
|
|
|
{"cua/R", "cur%s"}, /* Rocketport serial driver callout */
|
|
|
|
{"ip2/", "ip2%s"}, /* Computone serial driver control */
|
|
|
|
{"tts/F", "ttyF%s"}, /* Computone serial driver */
|
|
|
|
{"cua/F", "cuf%s"}, /* Computone serial driver callout */
|
|
|
|
{"tts/C", "ttyC%s"}, /* Cyclades serial driver */
|
|
|
|
{"cua/C", "cub%s"}, /* Cyclades serial driver callout */
|
|
|
|
{"tts/", "ttyS%s"}, /* Generic serial: must be after others */
|
|
|
|
{"cua/", "cua%s"}, /* Generic serial: must be after others */
|
|
|
|
{"input/js", "js%s"}, /* Joystick driver */
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
const char *get_old_name(const char *devname, unsigned int namelen,
|
2013-01-15 18:28:01 +05:30
|
|
|
char *buffer, unsigned int major, unsigned int minor)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Translate a kernel-supplied name into an old name.
|
|
|
|
<devname> The device name provided by the kernel.
|
|
|
|
<namelen> The length of the name.
|
|
|
|
<buffer> A buffer that may be used. This should be at least 128 bytes long.
|
|
|
|
<major> The major number for the device.
|
|
|
|
<minor> The minor number for the device.
|
|
|
|
[RETURNS] A pointer to the old name if known, else NULL.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
const char *compat_name = NULL;
|
2007-06-30 13:34:05 +05:30
|
|
|
const char *ptr;
|
2003-10-09 17:16:23 +05:30
|
|
|
struct translate_struct *trans;
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
unsigned int i;
|
|
|
|
char mode;
|
|
|
|
int indexx;
|
|
|
|
const char *pty1;
|
|
|
|
const char *pty2;
|
|
|
|
/* 1 to 5 "scsi/" , 6 to 9 "ide/host", 10 sbp/, 11 vcc/, 12 pty/ */
|
2022-02-07 00:37:12 +05:30
|
|
|
static const char *const fmt[] ALIGN_PTR = {
|
2006-02-22 22:31:00 +05:30
|
|
|
NULL ,
|
|
|
|
"sg%u", /* scsi/generic */
|
|
|
|
NULL, /* scsi/disc */
|
|
|
|
"sr%u", /* scsi/cd */
|
|
|
|
NULL, /* scsi/part */
|
|
|
|
"nst%u%c", /* scsi/mt */
|
|
|
|
"hd%c" , /* ide/host/disc */
|
|
|
|
"hd%c" , /* ide/host/cd */
|
|
|
|
"hd%c%s", /* ide/host/part */
|
|
|
|
"%sht%d", /* ide/host/mt */
|
|
|
|
"sbpcd%u", /* sbp/ */
|
|
|
|
"vcs%s", /* vcc/ */
|
|
|
|
"%cty%c%c", /* pty/ */
|
|
|
|
NULL
|
|
|
|
};
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
for (trans = translate_table; trans->match != NULL; ++trans) {
|
2015-03-12 22:18:34 +05:30
|
|
|
char *after_match = is_prefixed_with(devname, trans->match);
|
|
|
|
if (after_match) {
|
2003-10-09 17:16:23 +05:30
|
|
|
if (trans->format == NULL)
|
2015-03-12 22:18:34 +05:30
|
|
|
return after_match;
|
|
|
|
sprintf(buffer, trans->format, after_match);
|
2006-11-27 22:19:55 +05:30
|
|
|
return buffer;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
}
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
2007-06-30 13:34:05 +05:30
|
|
|
ptr = bb_basename(devname);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
i = scan_dev_name(devname, namelen, ptr);
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i > 0 && i < 13)
|
2003-10-09 17:16:23 +05:30
|
|
|
compat_name = buffer;
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
else
|
|
|
|
return NULL;
|
2006-01-25 05:38:53 +05:30
|
|
|
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
/* 1 == scsi/generic, 3 == scsi/cd, 10 == sbp/ */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 1 || i == 3 || i == 10)
|
|
|
|
sprintf(buffer, fmt[i], minor);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
|
|
|
/* 2 ==scsi/disc, 4 == scsi/part */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 2 || i == 4)
|
2010-01-28 17:00:24 +05:30
|
|
|
compat_name = write_old_sd_name(buffer, major, minor, ((i == 2) ? "" : (ptr + 4)));
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
|
|
|
/* 5 == scsi/mt */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 5) {
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
mode = ptr[2];
|
|
|
|
if (mode == 'n')
|
|
|
|
mode = '\0';
|
2007-06-26 04:25:34 +05:30
|
|
|
sprintf(buffer, fmt[i], minor & 0x1f, mode);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
if (devname[namelen - 1] != 'n')
|
|
|
|
++compat_name;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
/* 6 == ide/host/disc, 7 == ide/host/cd, 8 == ide/host/part */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 6 || i == 7 || i == 8)
|
2005-10-08 23:12:35 +05:30
|
|
|
/* last arg should be ignored for i == 6 or i== 7 */
|
2007-06-26 04:25:34 +05:30
|
|
|
sprintf(buffer, fmt[i] , get_old_ide_name(major, minor), ptr + 4);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
|
|
|
/* 9 == ide/host/mt */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 9)
|
|
|
|
sprintf(buffer, fmt[i], ptr + 2, minor & 0x7f);
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
|
|
|
|
/* 11 == vcc/ */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 11) {
|
|
|
|
sprintf(buffer, fmt[i], devname + 4);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (buffer[3] == '0')
|
|
|
|
buffer[3] = '\0';
|
|
|
|
}
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
/* 12 == pty/ */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == 12) {
|
Tito writes:
Hi to all,
here is a new patch for bb's devfsd. The news are:
1) Size reduction for the basic setup with no options compiled in from :
text data bss dec hex filename
10591 392 543 11526 2d06 devfsd.o
rw-r--r-- 1 root root 18536 Dec 18 21:52 devfsd.o
to:
text data bss dec hex filename
9303 392 543 10238 27fe devfsd.o
rw-r--r-- 1 root root 16528 Dec 18 22:02 devfsd.o
With this setup you should not expect much output from devfsd
( just at start or with -v) and if some error occurs it only exits 1.
To have more output enable: " Increases logging (and size)" (+1568 b).
2) The option "Adds function names to program output" was removed from config menu
and now to enable debug output you can use bb's standard option:
"Build BusyBox with Debugging symbols".
Be careful as with this option enabled a lot of data are outputted to /dev/log and/or to stderr.
3) A new option: "Enables the -fg and -np option" was added to config menu (+128 b).
BTW: option "Adds support for MODLOAD keyword in devsfd.conf" adds 268 b.
4) The following keywords in devsfd.conf are supported:
"CLEAR_CONFIG", "INCLUDE", "OPTIONAL_INCLUDE", "RESTORE",
"PERMISSIONS", "EXECUTE", "COPY", "IGNORE", "MKOLDCOMPAT",
"MKNEWCOMPAT","RMOLDCOMPAT", "RMNEWCOMPAT".
But only if they are written UPPERCASE!!!!!!!!
5)Help text in usage.h was modified.
6)Something that I have forgotten..........
I've tested this for the last week on my box and it seems to work as expected.
Thanks in advance and please apply.
Ciao,
Tito
2003-12-19 16:37:59 +05:30
|
|
|
pty1 = "pqrstuvwxyzabcde";
|
|
|
|
pty2 = "0123456789abcdef";
|
2007-06-26 04:25:34 +05:30
|
|
|
indexx = atoi(devname + 5);
|
|
|
|
sprintf(buffer, fmt[i], (devname[4] == 'm') ? 'p' : 't', pty1[indexx >> 4], pty2[indexx & 0x0f]);
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2006-11-27 22:19:55 +05:30
|
|
|
return compat_name;
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function get_old_name */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static char get_old_ide_name(unsigned int major, unsigned int minor)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Get the old IDE name for a device.
|
|
|
|
<major> The major number for the device.
|
|
|
|
<minor> The minor number for the device.
|
|
|
|
[RETURNS] The drive letter.
|
|
|
|
*/
|
|
|
|
{
|
2007-06-26 04:25:34 +05:30
|
|
|
char letter = 'y'; /* 121 */
|
|
|
|
char c = 'a'; /* 97 */
|
|
|
|
int i = IDE0_MAJOR;
|
2003-10-09 17:16:23 +05:30
|
|
|
|
|
|
|
/* I hope it works like the previous code as it saves a few bytes. Tito ;P */
|
|
|
|
do {
|
2007-06-26 04:25:34 +05:30
|
|
|
if (i == IDE0_MAJOR || i == IDE1_MAJOR || i == IDE2_MAJOR
|
|
|
|
|| i == IDE3_MAJOR || i == IDE4_MAJOR || i == IDE5_MAJOR
|
|
|
|
|| i == IDE6_MAJOR || i == IDE7_MAJOR || i == IDE8_MAJOR
|
|
|
|
|| i == IDE9_MAJOR
|
|
|
|
) {
|
|
|
|
if ((unsigned int)i == major) {
|
|
|
|
letter = c;
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
c += 2;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
i++;
|
2007-06-26 04:25:34 +05:30
|
|
|
} while (i <= IDE9_MAJOR);
|
2003-10-09 17:16:23 +05:30
|
|
|
|
|
|
|
if (minor > 63)
|
|
|
|
++letter;
|
2006-11-27 22:19:55 +05:30
|
|
|
return letter;
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function get_old_ide_name */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static char *write_old_sd_name(char *buffer,
|
2003-10-09 17:16:23 +05:30
|
|
|
unsigned int major, unsigned int minor,
|
2007-01-30 05:13:18 +05:30
|
|
|
const char *part)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Write the old SCSI disc name to a buffer.
|
|
|
|
<buffer> The buffer to write to.
|
|
|
|
<major> The major number for the device.
|
|
|
|
<minor> The minor number for the device.
|
|
|
|
<part> The partition string. Must be "" for a whole-disc entry.
|
|
|
|
[RETURNS] A pointer to the buffer on success, else NULL.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
unsigned int disc_index;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (major == 8) {
|
|
|
|
sprintf(buffer, "sd%c%s", 'a' + (minor >> 4), part);
|
2006-11-27 22:19:55 +05:30
|
|
|
return buffer;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
if ((major > 64) && (major < 72)) {
|
2022-08-30 20:11:17 +05:30
|
|
|
disc_index = ((major - 64) << 4) + (minor >> 4);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (disc_index < 26)
|
2007-06-26 04:25:34 +05:30
|
|
|
sprintf(buffer, "sd%c%s", 'a' + disc_index, part);
|
2003-10-09 17:16:23 +05:30
|
|
|
else
|
2022-08-30 20:11:17 +05:30
|
|
|
sprintf(buffer, "sd%c%c%s", 'a' + (disc_index / 26) - 1, 'a' + disc_index % 26, part);
|
2006-11-27 22:19:55 +05:30
|
|
|
return buffer;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2006-11-27 22:19:55 +05:30
|
|
|
return NULL;
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function write_old_sd_name */
|
|
|
|
|
|
|
|
|
|
|
|
/* expression.c */
|
|
|
|
|
|
|
|
/*EXPERIMENTAL_FUNCTION*/
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
int st_expr_expand(char *output, unsigned int length, const char *input,
|
2013-01-15 18:28:01 +05:30
|
|
|
const char *(*get_variable_func)(const char *variable,
|
|
|
|
void *info),
|
|
|
|
void *info)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Expand an expression using Borne Shell-like unquoted rules.
|
|
|
|
<output> The output expanded expression is written here.
|
|
|
|
<length> The size of the output buffer.
|
|
|
|
<input> The input expression. This may equal <<output>>.
|
|
|
|
<get_variable> A function which will be used to get variable values. If
|
|
|
|
this returns NULL, the environment is searched instead. If this is NULL,
|
|
|
|
only the environment is searched.
|
|
|
|
<info> An arbitrary pointer passed to <<get_variable>>.
|
|
|
|
[RETURNS] TRUE on success, else FALSE.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
char ch;
|
|
|
|
unsigned int len;
|
|
|
|
unsigned int out_pos = 0;
|
|
|
|
const char *env;
|
|
|
|
const char *ptr;
|
|
|
|
struct passwd *pwent;
|
|
|
|
char buffer[BUFFER_SIZE], tmp[STRING_LENGTH];
|
|
|
|
|
|
|
|
if (length > BUFFER_SIZE)
|
|
|
|
length = BUFFER_SIZE;
|
2007-06-26 04:25:34 +05:30
|
|
|
for (; TRUE; ++input) {
|
|
|
|
switch (ch = *input) {
|
2003-10-09 17:16:23 +05:30
|
|
|
case '$':
|
|
|
|
/* Variable expansion */
|
2007-06-26 04:25:34 +05:30
|
|
|
input = expand_variable(buffer, length, &out_pos, ++input, get_variable_func, info);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (input == NULL)
|
2006-11-27 22:19:55 +05:30
|
|
|
return FALSE;
|
2003-10-09 17:16:23 +05:30
|
|
|
break;
|
|
|
|
case '~':
|
|
|
|
/* Home directory expansion */
|
|
|
|
ch = input[1];
|
2007-06-26 04:25:34 +05:30
|
|
|
if (isspace(ch) ||(ch == '/') ||(ch == '\0')) {
|
2003-10-09 17:16:23 +05:30
|
|
|
/* User's own home directory: leave separator for next time */
|
2007-11-06 08:35:54 +05:30
|
|
|
env = getenv("HOME");
|
|
|
|
if (env == NULL) {
|
2007-07-02 03:55:33 +05:30
|
|
|
info_logger(LOG_INFO, bb_msg_variable_not_found, "HOME");
|
2006-11-27 22:19:55 +05:30
|
|
|
return FALSE;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
len = strlen(env);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (len + out_pos >= length)
|
|
|
|
goto st_expr_expand_out;
|
2007-06-26 04:25:34 +05:30
|
|
|
memcpy(buffer + out_pos, env, len + 1);
|
2003-10-09 17:16:23 +05:30
|
|
|
out_pos += len;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* Someone else's home directory */
|
2007-06-26 04:25:34 +05:30
|
|
|
for (ptr = ++input; !isspace(ch) && (ch != '/') && (ch != '\0'); ch = *++ptr)
|
2007-07-21 20:38:09 +05:30
|
|
|
/* VOID */;
|
2003-10-09 17:16:23 +05:30
|
|
|
len = ptr - input;
|
|
|
|
if (len >= sizeof tmp)
|
|
|
|
goto st_expr_expand_out;
|
2007-06-26 04:25:34 +05:30
|
|
|
safe_memcpy(tmp, input, len);
|
2003-10-09 17:16:23 +05:30
|
|
|
input = ptr - 1;
|
2007-11-06 08:35:54 +05:30
|
|
|
pwent = getpwnam(tmp);
|
|
|
|
if (pwent == NULL) {
|
2007-07-02 03:55:33 +05:30
|
|
|
info_logger(LOG_INFO, "no pwent for: %s", tmp);
|
2006-11-27 22:19:55 +05:30
|
|
|
return FALSE;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
len = strlen(pwent->pw_dir);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (len + out_pos >= length)
|
|
|
|
goto st_expr_expand_out;
|
2007-06-26 04:25:34 +05:30
|
|
|
memcpy(buffer + out_pos, pwent->pw_dir, len + 1);
|
2003-10-09 17:16:23 +05:30
|
|
|
out_pos += len;
|
|
|
|
break;
|
|
|
|
case '\0':
|
|
|
|
/* Falltrough */
|
|
|
|
default:
|
|
|
|
if (out_pos >= length)
|
|
|
|
goto st_expr_expand_out;
|
|
|
|
buffer[out_pos++] = ch;
|
2007-06-26 04:25:34 +05:30
|
|
|
if (ch == '\0') {
|
|
|
|
memcpy(output, buffer, out_pos);
|
2006-11-27 22:19:55 +05:30
|
|
|
return TRUE;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* esac */
|
|
|
|
}
|
|
|
|
}
|
2006-11-27 22:19:55 +05:30
|
|
|
return FALSE;
|
2003-10-09 17:16:23 +05:30
|
|
|
st_expr_expand_out:
|
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 15:05:03 +05:30
|
|
|
simple_info_logger(LOG_INFO, bb_msg_small_buffer);
|
2006-11-27 22:19:55 +05:30
|
|
|
return FALSE;
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function st_expr_expand */
|
|
|
|
|
|
|
|
|
|
|
|
/* Private functions follow */
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static const char *expand_variable(char *buffer, unsigned int length,
|
2013-01-14 20:27:44 +05:30
|
|
|
unsigned int *out_pos, const char *input,
|
|
|
|
const char *(*func)(const char *variable,
|
2013-01-15 18:28:01 +05:30
|
|
|
void *info),
|
2013-01-14 20:27:44 +05:30
|
|
|
void *info)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Expand a variable.
|
|
|
|
<buffer> The buffer to write to.
|
|
|
|
<length> The length of the output buffer.
|
|
|
|
<out_pos> The current output position. This is updated.
|
|
|
|
<input> A pointer to the input character pointer.
|
|
|
|
<func> A function which will be used to get variable values. If this
|
|
|
|
returns NULL, the environment is searched instead. If this is NULL, only
|
|
|
|
the environment is searched.
|
|
|
|
<info> An arbitrary pointer passed to <<func>>.
|
|
|
|
<errfp> Diagnostic messages are written here.
|
|
|
|
[RETURNS] A pointer to the end of this subexpression on success, else NULL.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
char ch;
|
|
|
|
int len;
|
|
|
|
unsigned int open_braces;
|
|
|
|
const char *env, *ptr;
|
|
|
|
char tmp[STRING_LENGTH];
|
|
|
|
|
|
|
|
ch = input[0];
|
2007-06-26 04:25:34 +05:30
|
|
|
if (ch == '$') {
|
2003-10-09 17:16:23 +05:30
|
|
|
/* Special case for "$$": PID */
|
2010-01-28 17:00:24 +05:30
|
|
|
sprintf(tmp, "%d", (int) getpid());
|
2007-06-26 04:25:34 +05:30
|
|
|
len = strlen(tmp);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (len + *out_pos >= length)
|
|
|
|
goto expand_variable_out;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
memcpy(buffer + *out_pos, tmp, len + 1);
|
2003-10-09 17:16:23 +05:30
|
|
|
out_pos += len;
|
2006-11-27 22:19:55 +05:30
|
|
|
return input;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
/* Ordinary variable expansion, possibly in braces */
|
2007-06-26 04:25:34 +05:30
|
|
|
if (ch != '{') {
|
2003-10-09 17:16:23 +05:30
|
|
|
/* Simple variable expansion */
|
2007-06-26 04:25:34 +05:30
|
|
|
for (ptr = input; isalnum(ch) || (ch == '_') || (ch == ':'); ch = *++ptr)
|
2007-07-21 20:38:09 +05:30
|
|
|
/* VOID */;
|
2003-10-09 17:16:23 +05:30
|
|
|
len = ptr - input;
|
2006-02-01 18:26:19 +05:30
|
|
|
if ((size_t)len >= sizeof tmp)
|
2003-10-09 17:16:23 +05:30
|
|
|
goto expand_variable_out;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
safe_memcpy(tmp, input, len);
|
2003-10-09 17:16:23 +05:30
|
|
|
input = ptr - 1;
|
2007-11-06 08:35:54 +05:30
|
|
|
env = get_variable_v2(tmp, func, info);
|
|
|
|
if (env == NULL) {
|
2007-07-02 03:55:33 +05:30
|
|
|
info_logger(LOG_INFO, bb_msg_variable_not_found, tmp);
|
2006-11-27 22:19:55 +05:30
|
|
|
return NULL;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
len = strlen(env);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (len + *out_pos >= length)
|
|
|
|
goto expand_variable_out;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
memcpy(buffer + *out_pos, env, len + 1);
|
2003-10-09 17:16:23 +05:30
|
|
|
*out_pos += len;
|
2006-11-27 22:19:55 +05:30
|
|
|
return input;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
/* Variable in braces: check for ':' tricks */
|
|
|
|
ch = *++input;
|
2007-06-26 04:25:34 +05:30
|
|
|
for (ptr = input; isalnum(ch) || (ch == '_'); ch = *++ptr)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* VOID */;
|
2007-06-26 04:25:34 +05:30
|
|
|
if (ch == '}') {
|
2003-10-09 17:16:23 +05:30
|
|
|
/* Must be simple variable expansion with "${var}" */
|
|
|
|
len = ptr - input;
|
2006-02-01 18:26:19 +05:30
|
|
|
if ((size_t)len >= sizeof tmp)
|
2003-10-09 17:16:23 +05:30
|
|
|
goto expand_variable_out;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
safe_memcpy(tmp, input, len);
|
|
|
|
ptr = expand_variable(buffer, length, out_pos, tmp, func, info);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (ptr == NULL)
|
2006-11-27 22:19:55 +05:30
|
|
|
return NULL;
|
|
|
|
return input + len;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2007-06-26 04:25:34 +05:30
|
|
|
if (ch != ':' || ptr[1] != '-') {
|
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 15:05:03 +05:30
|
|
|
simple_info_logger(LOG_INFO, "illegal char in var name");
|
2006-11-27 22:19:55 +05:30
|
|
|
return NULL;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
/* It's that handy "${var:-word}" expression. Check if var is defined */
|
|
|
|
len = ptr - input;
|
2006-02-01 18:26:19 +05:30
|
|
|
if ((size_t)len >= sizeof tmp)
|
2003-10-09 17:16:23 +05:30
|
|
|
goto expand_variable_out;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
safe_memcpy(tmp, input, len);
|
2003-10-09 17:16:23 +05:30
|
|
|
/* Move input pointer to ':' */
|
|
|
|
input = ptr;
|
|
|
|
/* First skip to closing brace, taking note of nested expressions */
|
|
|
|
ptr += 2;
|
|
|
|
ch = ptr[0];
|
2007-06-26 04:25:34 +05:30
|
|
|
for (open_braces = 1; open_braces > 0; ch = *++ptr) {
|
|
|
|
switch (ch) {
|
2003-10-09 17:16:23 +05:30
|
|
|
case '{':
|
|
|
|
++open_braces;
|
|
|
|
break;
|
|
|
|
case '}':
|
|
|
|
--open_braces;
|
|
|
|
break;
|
|
|
|
case '\0':
|
2008-06-26 20:02:57 +05:30
|
|
|
info_logger(LOG_INFO, "\"}\" not found in: %s", input);
|
2006-11-27 22:19:55 +05:30
|
|
|
return NULL;
|
2003-10-09 17:16:23 +05:30
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--ptr;
|
|
|
|
/* At this point ptr should point to closing brace of "${var:-word}" */
|
2007-11-06 08:35:54 +05:30
|
|
|
env = get_variable_v2(tmp, func, info);
|
|
|
|
if (env != NULL) {
|
2003-10-09 17:16:23 +05:30
|
|
|
/* Found environment variable, so skip the input to the closing brace
|
|
|
|
and return the variable */
|
|
|
|
input = ptr;
|
2007-06-26 04:25:34 +05:30
|
|
|
len = strlen(env);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (len + *out_pos >= length)
|
|
|
|
goto expand_variable_out;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
memcpy(buffer + *out_pos, env, len + 1);
|
2003-10-09 17:16:23 +05:30
|
|
|
*out_pos += len;
|
2006-11-27 22:19:55 +05:30
|
|
|
return input;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
|
|
|
/* Environment variable was not found, so process word. Advance input
|
|
|
|
pointer to start of word in "${var:-word}" */
|
|
|
|
input += 2;
|
|
|
|
len = ptr - input;
|
2006-02-01 18:26:19 +05:30
|
|
|
if ((size_t)len >= sizeof tmp)
|
2003-10-09 17:16:23 +05:30
|
|
|
goto expand_variable_out;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
safe_memcpy(tmp, input, len);
|
2003-10-09 17:16:23 +05:30
|
|
|
input = ptr;
|
2007-06-26 04:25:34 +05:30
|
|
|
if (!st_expr_expand(tmp, STRING_LENGTH, tmp, func, info))
|
2006-11-27 22:19:55 +05:30
|
|
|
return NULL;
|
2007-06-26 04:25:34 +05:30
|
|
|
len = strlen(tmp);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (len + *out_pos >= length)
|
|
|
|
goto expand_variable_out;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
memcpy(buffer + *out_pos, tmp, len + 1);
|
2003-10-09 17:16:23 +05:30
|
|
|
*out_pos += len;
|
2006-11-27 22:19:55 +05:30
|
|
|
return input;
|
2003-10-09 17:16:23 +05:30
|
|
|
expand_variable_out:
|
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02 15:05:03 +05:30
|
|
|
simple_info_logger(LOG_INFO, bb_msg_small_buffer);
|
2006-11-27 22:19:55 +05:30
|
|
|
return NULL;
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function expand_variable */
|
|
|
|
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
static const char *get_variable_v2(const char *variable,
|
2013-01-14 20:27:44 +05:30
|
|
|
const char *(*func)(const char *variable, void *info),
|
|
|
|
void *info)
|
2003-10-09 17:16:23 +05:30
|
|
|
/* [SUMMARY] Get a variable from the environment or .
|
|
|
|
<variable> The variable name.
|
|
|
|
<func> A function which will be used to get the variable. If this returns
|
|
|
|
NULL, the environment is searched instead. If this is NULL, only the
|
|
|
|
environment is searched.
|
|
|
|
[RETURNS] The value of the variable on success, else NULL.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
const char *value;
|
|
|
|
|
2007-06-26 04:25:34 +05:30
|
|
|
if (func != NULL) {
|
|
|
|
value = (*func)(variable, info);
|
2003-10-09 17:16:23 +05:30
|
|
|
if (value != NULL)
|
2006-11-27 22:19:55 +05:30
|
|
|
return value;
|
2003-10-09 17:16:23 +05:30
|
|
|
}
|
2006-11-27 22:19:55 +05:30
|
|
|
return getenv(variable);
|
2003-10-09 17:16:23 +05:30
|
|
|
} /* End Function get_variable */
|
|
|
|
|
|
|
|
/* END OF CODE */
|