devfsd: style cleanup; size reduction (Tito <farmatito@tiscali.it>)
traceroute: suppress warning
This commit is contained in:
parent
e8240f19bd
commit
c965f4b141
@ -322,13 +322,7 @@ static void msg_logger_and_die(int pri, const char* fmt, ...)
|
|||||||
#define devfsd_error_msg(fmt, args...) bb_error_msg(fmt, ## args)
|
#define devfsd_error_msg(fmt, args...) bb_error_msg(fmt, ## args)
|
||||||
#define devfsd_perror_msg_and_die(fmt, args...) bb_perror_msg_and_die(fmt, ## args)
|
#define devfsd_perror_msg_and_die(fmt, args...) bb_perror_msg_and_die(fmt, ## args)
|
||||||
#define devfsd_error_msg_and_die(fmt, args...) bb_error_msg_and_die(fmt, ## args)
|
#define devfsd_error_msg_and_die(fmt, args...) bb_error_msg_and_die(fmt, ## args)
|
||||||
#if defined(CONFIG_DEBUG)
|
|
||||||
#define debug_msg_logger(x, fmt, args...) msg_logger(x, fmt, ## args)
|
|
||||||
#else
|
#else
|
||||||
#define debug_msg_logger(x, fmt, args...)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define debug_msg_logger(x, fmt, args...)
|
|
||||||
#define msg_logger(p, fmt, args...)
|
#define msg_logger(p, fmt, args...)
|
||||||
#define msg_logger_and_die(p, fmt, args...) exit(1)
|
#define msg_logger_and_die(p, fmt, args...) exit(1)
|
||||||
#define devfsd_perror_msg_and_die(fmt, args...) exit(1)
|
#define devfsd_perror_msg_and_die(fmt, args...) exit(1)
|
||||||
@ -448,8 +442,7 @@ int devfsd_main(int argc, char **argv)
|
|||||||
|
|
||||||
mount_point = argv[1];
|
mount_point = argv[1];
|
||||||
|
|
||||||
if (chdir(mount_point) != 0)
|
xchdir(mount_point);
|
||||||
devfsd_perror_msg_and_die(mount_point);
|
|
||||||
|
|
||||||
fd = xopen(".devfsd", O_RDONLY);
|
fd = xopen(".devfsd", O_RDONLY);
|
||||||
|
|
||||||
@ -530,8 +523,6 @@ static void read_config_file(char *path, int optional, unsigned long *event_mask
|
|||||||
char buf[STRING_LENGTH];
|
char buf[STRING_LENGTH];
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, path);
|
|
||||||
|
|
||||||
if (stat(path, &statbuf) == 0) {
|
if (stat(path, &statbuf) == 0) {
|
||||||
/* Don't read 0 length files: ignored */
|
/* Don't read 0 length files: ignored */
|
||||||
/*if (statbuf.st_size == 0)
|
/*if (statbuf.st_size == 0)
|
||||||
@ -588,9 +579,8 @@ static void process_config_line(const char *line, unsigned long *event_mask)
|
|||||||
"RMOLDCOMPAT", "RMNEWCOMPAT", 0
|
"RMOLDCOMPAT", "RMNEWCOMPAT", 0
|
||||||
};
|
};
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
for (count = 0; count < MAX_ARGS; ++count)
|
||||||
|
p[count][0] = '\0';
|
||||||
for (count = 0; count < MAX_ARGS; ++count) p[count][0] = '\0';
|
|
||||||
num_args = sscanf(line, "%s %s %s %s %s %s %s %s %s %s",
|
num_args = sscanf(line, "%s %s %s %s %s %s %s %s %s %s",
|
||||||
when, name, what,
|
when, name, what,
|
||||||
p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
|
p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
|
||||||
@ -622,8 +612,7 @@ static void process_config_line(const char *line, unsigned long *event_mask)
|
|||||||
if (num_args < 3)
|
if (num_args < 3)
|
||||||
goto process_config_line_err;
|
goto process_config_line_err;
|
||||||
|
|
||||||
new = xmalloc(sizeof *new);
|
new = xzalloc(sizeof *new);
|
||||||
memset(new, 0, sizeof *new);
|
|
||||||
|
|
||||||
for (count = 0; event_types[count].config_name != NULL; ++count) {
|
for (count = 0; event_types[count].config_name != NULL; ++count) {
|
||||||
if (strcasecmp(when, event_types[count].config_name) != 0)
|
if (strcasecmp(when, event_types[count].config_name) != 0)
|
||||||
@ -725,8 +714,6 @@ static int do_servicing(int fd, unsigned long event_mask)
|
|||||||
struct devfsd_notify_struct info;
|
struct devfsd_notify_struct info;
|
||||||
unsigned long tmp_event_mask;
|
unsigned long tmp_event_mask;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
/* Tell devfs what events we care about */
|
/* Tell devfs what events we care about */
|
||||||
tmp_event_mask = event_mask;
|
tmp_event_mask = event_mask;
|
||||||
do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask);
|
do_ioctl_and_die(fd, DEVFSDIOC_SET_EVENT_MASK, tmp_event_mask);
|
||||||
@ -761,9 +748,8 @@ static void service_name(const struct devfsd_notify_struct *info)
|
|||||||
regmatch_t mbuf[MAX_SUBEXPR];
|
regmatch_t mbuf[MAX_SUBEXPR];
|
||||||
struct config_entry_struct *entry;
|
struct config_entry_struct *entry;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
if (ENABLE_DEBUG && info->overrun_count > 0)
|
if (ENABLE_DEBUG && info->overrun_count > 0)
|
||||||
debug_msg_logger(LOG_ERR, "lost %u events", info->overrun_count);
|
msg_logger(LOG_ERR, "lost %u events", info->overrun_count);
|
||||||
|
|
||||||
/* Discard lookups on "/dev/log" and "/dev/initctl" */
|
/* Discard lookups on "/dev/log" and "/dev/initctl" */
|
||||||
if (info->type == DEVFSD_NOTIFY_LOOKUP
|
if (info->type == DEVFSD_NOTIFY_LOOKUP
|
||||||
@ -784,8 +770,6 @@ static void service_name(const struct devfsd_notify_struct *info)
|
|||||||
for (n = 0;(n < MAX_SUBEXPR) && (mbuf[n].rm_so != -1); ++n)
|
for (n = 0;(n < MAX_SUBEXPR) && (mbuf[n].rm_so != -1); ++n)
|
||||||
/* VOID */;
|
/* VOID */;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, "%s: action.what %d", __FUNCTION__, entry->action.what);
|
|
||||||
|
|
||||||
switch (entry->action.what) {
|
switch (entry->action.what) {
|
||||||
case AC_PERMISSIONS:
|
case AC_PERMISSIONS:
|
||||||
action_permissions(info, entry);
|
action_permissions(info, entry);
|
||||||
@ -825,13 +809,11 @@ static void action_permissions(const struct devfsd_notify_struct *info,
|
|||||||
{
|
{
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
if (stat(info->devname, &statbuf) != 0 ||
|
if (stat(info->devname, &statbuf) != 0 ||
|
||||||
chmod(info->devname,(statbuf.st_mode & S_IFMT) |(entry->u.permissions.mode & ~S_IFMT)) != 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) {
|
chown(info->devname, entry->u.permissions.uid, entry->u.permissions.gid) != 0
|
||||||
|
)
|
||||||
msg_logger(LOG_ERR, "Can't chmod or chown: %s: %m", info->devname);
|
msg_logger(LOG_ERR, "Can't chmod or chown: %s: %m", info->devname);
|
||||||
}
|
|
||||||
} /* End Function action_permissions */
|
} /* End Function action_permissions */
|
||||||
|
|
||||||
static void action_modload(const struct devfsd_notify_struct *info,
|
static void action_modload(const struct devfsd_notify_struct *info,
|
||||||
@ -843,18 +825,16 @@ static void action_modload(const struct devfsd_notify_struct *info,
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
char *argv[6];
|
char *argv[6];
|
||||||
char device[STRING_LENGTH];
|
|
||||||
|
|
||||||
argv[0] =(char*)MODPROBE;
|
argv[0] =(char*)MODPROBE;
|
||||||
argv[1] =(char*)MODPROBE_SWITCH_1; /* "-k" */
|
argv[1] =(char*)MODPROBE_SWITCH_1; /* "-k" */
|
||||||
argv[2] =(char*)MODPROBE_SWITCH_2; /* "-C" */
|
argv[2] =(char*)MODPROBE_SWITCH_2; /* "-C" */
|
||||||
argv[3] =(char*)CONFIG_MODULES_DEVFS;
|
argv[3] =(char*)CONFIG_MODULES_DEVFS;
|
||||||
argv[4] = device;
|
argv[4] = concat_path_file("/dev", info->devname); /* device */
|
||||||
argv[5] = NULL;
|
argv[5] = NULL;
|
||||||
|
|
||||||
snprintf(device, sizeof(device), "/dev/%s", info->devname);
|
|
||||||
debug_msg_logger(LOG_INFO, "%s: %s %s %s %s %s",__FUNCTION__, argv[0],argv[1],argv[2],argv[3],argv[4]);
|
|
||||||
fork_and_execute(DIE, argv[0], argv);
|
fork_and_execute(DIE, argv[0], argv);
|
||||||
|
free(argv[4]);
|
||||||
} /* End Function action_modload */
|
} /* End Function action_modload */
|
||||||
|
|
||||||
static void action_execute(const struct devfsd_notify_struct *info,
|
static void action_execute(const struct devfsd_notify_struct *info,
|
||||||
@ -874,7 +854,6 @@ static void action_execute(const struct devfsd_notify_struct *info,
|
|||||||
char *argv[MAX_ARGS + 1];
|
char *argv[MAX_ARGS + 1];
|
||||||
char largv[MAX_ARGS + 1][STRING_LENGTH];
|
char largv[MAX_ARGS + 1][STRING_LENGTH];
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO ,__FUNCTION__);
|
|
||||||
gv_info.info = info;
|
gv_info.info = info;
|
||||||
gv_info.devname = info->devname;
|
gv_info.devname = info->devname;
|
||||||
snprintf(gv_info.devpath, sizeof(gv_info.devpath), "%s/%s", mount_point, info->devname);
|
snprintf(gv_info.devpath, sizeof(gv_info.devpath), "%s/%s", mount_point, info->devname);
|
||||||
@ -908,8 +887,6 @@ static void action_copy(const struct devfsd_notify_struct *info,
|
|||||||
char source[STRING_LENGTH], destination[STRING_LENGTH];
|
char source[STRING_LENGTH], destination[STRING_LENGTH];
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
dest_stat.st_mode = 0;
|
dest_stat.st_mode = 0;
|
||||||
|
|
||||||
if ((info->type == DEVFSD_NOTIFY_CHANGE) && S_ISLNK(info->mode))
|
if ((info->type == DEVFSD_NOTIFY_CHANGE) && S_ISLNK(info->mode))
|
||||||
@ -936,7 +913,7 @@ static void action_copy(const struct devfsd_notify_struct *info,
|
|||||||
new_mode |= S_ISVTX;
|
new_mode |= S_ISVTX;
|
||||||
ret = copy_inode(destination, &dest_stat, new_mode, source, &source_stat);
|
ret = copy_inode(destination, &dest_stat, new_mode, source, &source_stat);
|
||||||
if (ENABLE_DEBUG && ret && (errno != EEXIST))
|
if (ENABLE_DEBUG && ret && (errno != EEXIST))
|
||||||
debug_msg_logger(LOG_ERR, "copy_inode: %s to %s: %m", source, destination);
|
msg_logger(LOG_ERR, "copy_inode: %s to %s: %m", source, destination);
|
||||||
} /* End Function action_copy */
|
} /* End Function action_copy */
|
||||||
|
|
||||||
static void action_compat(const struct devfsd_notify_struct *info, unsigned int action)
|
static void action_compat(const struct devfsd_notify_struct *info, unsigned int action)
|
||||||
@ -980,8 +957,6 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int
|
|||||||
ptr = strrchr(info->devname, '/') + 1;
|
ptr = strrchr(info->devname, '/') + 1;
|
||||||
i = scan_dev_name(info->devname, info->namelen, ptr);
|
i = scan_dev_name(info->devname, info->namelen, ptr);
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, "%s: scan_dev_name = %d", __FUNCTION__, i);
|
|
||||||
|
|
||||||
/* nothing found */
|
/* nothing found */
|
||||||
if (i == 0 || i > 9)
|
if (i == 0 || i > 9)
|
||||||
return;
|
return;
|
||||||
@ -1022,8 +997,6 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int
|
|||||||
if (compat_name == NULL)
|
if (compat_name == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, compat_name);
|
|
||||||
|
|
||||||
/* Now decide what to do with it */
|
/* Now decide what to do with it */
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case AC_MKOLDCOMPAT:
|
case AC_MKOLDCOMPAT:
|
||||||
@ -1034,7 +1007,7 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int
|
|||||||
case AC_RMNEWCOMPAT:
|
case AC_RMNEWCOMPAT:
|
||||||
ret = unlink(compat_name);
|
ret = unlink(compat_name);
|
||||||
if (ENABLE_DEBUG && ret)
|
if (ENABLE_DEBUG && ret)
|
||||||
debug_msg_logger(LOG_ERR, "unlink: %s: %m", compat_name);
|
msg_logger(LOG_ERR, "unlink: %s: %m", compat_name);
|
||||||
break;
|
break;
|
||||||
/*esac*/
|
/*esac*/
|
||||||
} /* switch (action) */
|
} /* switch (action) */
|
||||||
@ -1042,15 +1015,13 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int
|
|||||||
|
|
||||||
static void restore(char *spath, struct stat source_stat, int rootlen)
|
static void restore(char *spath, struct stat source_stat, int rootlen)
|
||||||
{
|
{
|
||||||
char dpath[STRING_LENGTH];
|
char *dpath;
|
||||||
struct stat dest_stat;
|
struct stat dest_stat;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
dest_stat.st_mode = 0;
|
dest_stat.st_mode = 0;
|
||||||
snprintf(dpath, sizeof dpath, "%s%s", mount_point, spath + rootlen);
|
dpath = concat_path_file(mount_point, spath + rootlen);
|
||||||
lstat(dpath, &dest_stat);
|
lstat(dpath, &dest_stat);
|
||||||
|
free(dpath);
|
||||||
if (S_ISLNK(source_stat.st_mode) ||(source_stat.st_mode & S_ISVTX))
|
if (S_ISLNK(source_stat.st_mode) ||(source_stat.st_mode & S_ISVTX))
|
||||||
copy_inode(dpath, &dest_stat,(source_stat.st_mode & ~S_ISVTX) , spath, &source_stat);
|
copy_inode(dpath, &dest_stat,(source_stat.st_mode & ~S_ISVTX) , spath, &source_stat);
|
||||||
|
|
||||||
@ -1077,8 +1048,6 @@ static int copy_inode(const char *destpath, const struct stat *dest_stat,
|
|||||||
struct sockaddr_un un_addr;
|
struct sockaddr_un un_addr;
|
||||||
char symlink_val[STRING_LENGTH];
|
char symlink_val[STRING_LENGTH];
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
if ((source_stat->st_mode & S_IFMT) ==(dest_stat->st_mode & S_IFMT)) {
|
if ((source_stat->st_mode & S_IFMT) ==(dest_stat->st_mode & S_IFMT)) {
|
||||||
/* Same type */
|
/* Same type */
|
||||||
if (S_ISLNK(source_stat->st_mode)) {
|
if (S_ISLNK(source_stat->st_mode)) {
|
||||||
@ -1150,8 +1119,6 @@ static void free_config(void)
|
|||||||
struct config_entry_struct *c_entry;
|
struct config_entry_struct *c_entry;
|
||||||
void *next;
|
void *next;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
for (c_entry = first_config; c_entry != NULL; c_entry = next) {
|
for (c_entry = first_config; c_entry != NULL; c_entry = next) {
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
|
||||||
@ -1184,11 +1151,6 @@ static int get_uid_gid(int flag, const char *string)
|
|||||||
if (ENABLE_DEVFSD_VERBOSE)
|
if (ENABLE_DEVFSD_VERBOSE)
|
||||||
msg = "user";
|
msg = "user";
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
if (ENABLE_DEBUG && flag != UID && flag != GID)
|
|
||||||
msg_logger_and_die(LOG_ERR,"%s: flag != UID && flag != GID", __FUNCTION__);
|
|
||||||
|
|
||||||
if (isdigit(string[0]) ||((string[0] == '-') && isdigit(string[1])))
|
if (isdigit(string[0]) ||((string[0] == '-') && isdigit(string[1])))
|
||||||
return atoi(string);
|
return atoi(string);
|
||||||
|
|
||||||
@ -1214,8 +1176,6 @@ static mode_t get_mode(const char *string)
|
|||||||
mode_t mode;
|
mode_t mode;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
if (isdigit(string[0]))
|
if (isdigit(string[0]))
|
||||||
return strtoul(string, NULL, 8);
|
return strtoul(string, NULL, 8);
|
||||||
if (strlen(string) != 9)
|
if (strlen(string) != 9)
|
||||||
@ -1234,8 +1194,6 @@ static mode_t get_mode(const char *string)
|
|||||||
|
|
||||||
static void signal_handler(int sig)
|
static void signal_handler(int sig)
|
||||||
{
|
{
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
caught_signal = TRUE;
|
caught_signal = TRUE;
|
||||||
if (sig == SIGHUP)
|
if (sig == SIGHUP)
|
||||||
caught_sighup = TRUE;
|
caught_sighup = TRUE;
|
||||||
@ -1252,8 +1210,6 @@ static const char *get_variable(const char *variable, void *info)
|
|||||||
gv_info->devpath, gv_info->devname, 0 };
|
gv_info->devpath, gv_info->devname, 0 };
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
if (gethostname(hostname, STRING_LENGTH - 1) != 0)
|
if (gethostname(hostname, STRING_LENGTH - 1) != 0)
|
||||||
msg_logger_and_die(LOG_ERR, "gethostname: %m");
|
msg_logger_and_die(LOG_ERR, "gethostname: %m");
|
||||||
|
|
||||||
@ -1266,7 +1222,6 @@ static const char *get_variable(const char *variable, void *info)
|
|||||||
if (i > 6 || i < 0 || (i > 1 && gv_info == NULL))
|
if (i > 6 || i < 0 || (i > 1 && gv_info == NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (i >= 0 && i <= 3) {
|
if (i >= 0 && i <= 3) {
|
||||||
debug_msg_logger(LOG_INFO, "%s: i=%d %s", __FUNCTION__, i, field_names[i + 7]);
|
|
||||||
return field_names[i + 7];
|
return field_names[i + 7];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1276,9 +1231,6 @@ static const char *get_variable(const char *variable, void *info)
|
|||||||
sprintf(sbuf, "%u", gv_info->info->gid);
|
sprintf(sbuf, "%u", gv_info->info->gid);
|
||||||
else if (i == 6)
|
else if (i == 6)
|
||||||
sprintf(sbuf, "%o", gv_info->info->mode);
|
sprintf(sbuf, "%o", gv_info->info->mode);
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, "%s: %s", __FUNCTION__, sbuf);
|
|
||||||
|
|
||||||
return sbuf;
|
return sbuf;
|
||||||
} /* End Function get_variable */
|
} /* End Function get_variable */
|
||||||
|
|
||||||
@ -1286,8 +1238,6 @@ static void service(struct stat statbuf, char *path)
|
|||||||
{
|
{
|
||||||
struct devfsd_notify_struct info;
|
struct devfsd_notify_struct info;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
memset(&info, 0, sizeof info);
|
memset(&info, 0, sizeof info);
|
||||||
info.type = DEVFSD_NOTIFY_REGISTERED;
|
info.type = DEVFSD_NOTIFY_REGISTERED;
|
||||||
info.mode = statbuf.st_mode;
|
info.mode = statbuf.st_mode;
|
||||||
@ -1314,26 +1264,17 @@ static void dir_operation(int type, const char * dir_name, int var, unsigned lon
|
|||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
char path[STRING_LENGTH];
|
char *path;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
if ((dp = warn_opendir(dir_name)) == NULL)
|
||||||
|
|
||||||
if ((dp = opendir(dir_name))==NULL) {
|
|
||||||
debug_msg_logger(LOG_ERR, "opendir: %s: %m", dir_name);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
while ((de = readdir(dp)) != NULL) {
|
while ((de = readdir(dp)) != NULL) {
|
||||||
|
|
||||||
if (de->d_name && DOT_OR_DOTDOT(de->d_name))
|
if (de->d_name && DOT_OR_DOTDOT(de->d_name))
|
||||||
continue;
|
continue;
|
||||||
snprintf(path, sizeof(path), "%s/%s", dir_name, de->d_name);
|
path = concat_path_file(dir_name, de->d_name);
|
||||||
debug_msg_logger(LOG_ERR, "%s: %s", __FUNCTION__, path);
|
if (lstat(path, &statbuf) == 0) {
|
||||||
|
|
||||||
if (lstat(path, &statbuf) != 0) {
|
|
||||||
debug_msg_logger(LOG_ERR, "%s: %s: %m", __FUNCTION__, path);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SERVICE:
|
case SERVICE:
|
||||||
service(statbuf, path);
|
service(statbuf, path);
|
||||||
@ -1346,6 +1287,8 @@ static void dir_operation(int type, const char * dir_name, int var, unsigned lon
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(path);
|
||||||
|
}
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
} /* End Function do_scan_and_service */
|
} /* End Function do_scan_and_service */
|
||||||
|
|
||||||
@ -1356,17 +1299,13 @@ static int mksymlink(const char *oldpath, const char *newpath)
|
|||||||
[RETURNS] 0 on success, else -1.
|
[RETURNS] 0 on success, else -1.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
if (!make_dir_tree(newpath))
|
if (!make_dir_tree(newpath))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (symlink(oldpath, newpath) != 0) {
|
if (symlink(oldpath, newpath) != 0) {
|
||||||
if (errno != EEXIST) {
|
if (errno != EEXIST)
|
||||||
debug_msg_logger(LOG_ERR, "%s: %s to %s: %m", __FUNCTION__, oldpath, newpath);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
} /* End Function mksymlink */
|
} /* End Function mksymlink */
|
||||||
|
|
||||||
@ -1377,12 +1316,8 @@ static int make_dir_tree(const char *path)
|
|||||||
[RETURNS] TRUE on success, else FALSE.
|
[RETURNS] TRUE on success, else FALSE.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
if (bb_make_directory(dirname((char *)path), -1, FILEUTILS_RECUR) == -1)
|
||||||
|
|
||||||
if (bb_make_directory(dirname((char *)path), -1, FILEUTILS_RECUR) == -1) {
|
|
||||||
debug_msg_logger(LOG_ERR, "%s: %s: %m",__FUNCTION__, path);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} /* End Function make_dir_tree */
|
} /* End Function make_dir_tree */
|
||||||
|
|
||||||
@ -1409,8 +1344,6 @@ static int expand_expression(char *output, unsigned int outsize,
|
|||||||
{
|
{
|
||||||
char temp[STRING_LENGTH];
|
char temp[STRING_LENGTH];
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
if (!st_expr_expand(temp, STRING_LENGTH, input, get_variable_func, info))
|
if (!st_expr_expand(temp, STRING_LENGTH, input, get_variable_func, info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
expand_regexp(output, outsize, temp, devname, ex, numexp);
|
expand_regexp(output, outsize, temp, devname, ex, numexp);
|
||||||
@ -1438,8 +1371,6 @@ static void expand_regexp(char *output, size_t outsize, const char *input,
|
|||||||
const char last_exp = '0' - 1 + numex;
|
const char last_exp = '0' - 1 + numex;
|
||||||
int c = -1;
|
int c = -1;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
/* Guarantee NULL termination by writing an explicit '\0' character into
|
/* Guarantee NULL termination by writing an explicit '\0' character into
|
||||||
the very last byte */
|
the very last byte */
|
||||||
if (outsize)
|
if (outsize)
|
||||||
@ -1555,8 +1486,6 @@ const char *get_old_name(const char *devname, unsigned int namelen,
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
for (trans = translate_table; trans->match != NULL; ++trans) {
|
for (trans = translate_table; trans->match != NULL; ++trans) {
|
||||||
len = strlen(trans->match);
|
len = strlen(trans->match);
|
||||||
|
|
||||||
@ -1576,8 +1505,6 @@ const char *get_old_name(const char *devname, unsigned int namelen,
|
|||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, "%s: scan_dev_name = %d", __FUNCTION__, i);
|
|
||||||
|
|
||||||
/* 1 == scsi/generic, 3 == scsi/cd, 10 == sbp/ */
|
/* 1 == scsi/generic, 3 == scsi/cd, 10 == sbp/ */
|
||||||
if (i == 1 || i == 3 || i == 10)
|
if (i == 1 || i == 3 || i == 10)
|
||||||
sprintf(buffer, fmt[i], minor);
|
sprintf(buffer, fmt[i], minor);
|
||||||
@ -1617,10 +1544,6 @@ const char *get_old_name(const char *devname, unsigned int namelen,
|
|||||||
indexx = atoi(devname + 5);
|
indexx = atoi(devname + 5);
|
||||||
sprintf(buffer, fmt[i], (devname[4] == 'm') ? 'p' : 't', pty1[indexx >> 4], pty2[indexx & 0x0f]);
|
sprintf(buffer, fmt[i], (devname[4] == 'm') ? 'p' : 't', pty1[indexx >> 4], pty2[indexx & 0x0f]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ENABLE_DEBUG && compat_name != NULL)
|
|
||||||
msg_logger(LOG_INFO, "%s: compat_name %s", __FUNCTION__, compat_name);
|
|
||||||
|
|
||||||
return compat_name;
|
return compat_name;
|
||||||
} /* End Function get_old_name */
|
} /* End Function get_old_name */
|
||||||
|
|
||||||
@ -1635,8 +1558,6 @@ static char get_old_ide_name(unsigned int major, unsigned int minor)
|
|||||||
char c = 'a'; /* 97 */
|
char c = 'a'; /* 97 */
|
||||||
int i = IDE0_MAJOR;
|
int i = IDE0_MAJOR;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
/* I hope it works like the previous code as it saves a few bytes. Tito ;P */
|
/* I hope it works like the previous code as it saves a few bytes. Tito ;P */
|
||||||
do {
|
do {
|
||||||
if (i == IDE0_MAJOR || i == IDE1_MAJOR || i == IDE2_MAJOR
|
if (i == IDE0_MAJOR || i == IDE1_MAJOR || i == IDE2_MAJOR
|
||||||
@ -1671,8 +1592,6 @@ static char *write_old_sd_name(char *buffer,
|
|||||||
{
|
{
|
||||||
unsigned int disc_index;
|
unsigned int disc_index;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
if (major == 8) {
|
if (major == 8) {
|
||||||
sprintf(buffer, "sd%c%s", 'a' + (minor >> 4), part);
|
sprintf(buffer, "sd%c%s", 'a' + (minor >> 4), part);
|
||||||
return buffer;
|
return buffer;
|
||||||
@ -1716,8 +1635,6 @@ int st_expr_expand(char *output, unsigned int length, const char *input,
|
|||||||
struct passwd *pwent;
|
struct passwd *pwent;
|
||||||
char buffer[BUFFER_SIZE], tmp[STRING_LENGTH];
|
char buffer[BUFFER_SIZE], tmp[STRING_LENGTH];
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
if (length > BUFFER_SIZE)
|
if (length > BUFFER_SIZE)
|
||||||
length = BUFFER_SIZE;
|
length = BUFFER_SIZE;
|
||||||
for (; TRUE; ++input) {
|
for (; TRUE; ++input) {
|
||||||
@ -1809,8 +1726,6 @@ static const char *expand_variable(char *buffer, unsigned int length,
|
|||||||
const char *env, *ptr;
|
const char *env, *ptr;
|
||||||
char tmp[STRING_LENGTH];
|
char tmp[STRING_LENGTH];
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
ch = input[0];
|
ch = input[0];
|
||||||
if (ch == '$') {
|
if (ch == '$') {
|
||||||
/* Special case for "$$": PID */
|
/* Special case for "$$": PID */
|
||||||
@ -1943,8 +1858,6 @@ static const char *get_variable_v2(const char *variable,
|
|||||||
{
|
{
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
debug_msg_logger(LOG_INFO, __FUNCTION__);
|
|
||||||
|
|
||||||
if (func != NULL) {
|
if (func != NULL) {
|
||||||
value = (*func)(variable, info);
|
value = (*func)(variable, info);
|
||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
|
@ -397,8 +397,8 @@ ifaddrlist(struct IFADDRLIST **ipaddrp)
|
|||||||
) {
|
) {
|
||||||
if (errno == EINVAL)
|
if (errno == EINVAL)
|
||||||
bb_error_msg_and_die(
|
bb_error_msg_and_die(
|
||||||
"SIOCGIFCONF: ifreq struct too small (%d bytes)",
|
"SIOCGIFCONF: ifreq struct too small (%u bytes)",
|
||||||
IFREQ_BUFSIZE * sizeof(ibuf[0]));
|
(unsigned)(IFREQ_BUFSIZE * sizeof(ibuf[0])));
|
||||||
bb_perror_msg_and_die("SIOCGIFCONF");
|
bb_perror_msg_and_die("SIOCGIFCONF");
|
||||||
}
|
}
|
||||||
ifrp = ibuf;
|
ifrp = ibuf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user