/* vi: set sw=4 ts=4: */
/*
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
/*
#define DEVFS_PATHLEN 1024
/* Never change this otherwise the binary interface will change */
-struct devfsd_notify_struct
-{ /* Use native C types to ensure same types in kernel and user space */
+struct devfsd_notify_struct {
+ /* Use native C types to ensure same types in kernel and user space */
unsigned int type; /* DEVFSD_NOTIFY_* value */
unsigned int mode; /* Mode of the inode or device entry */
unsigned int major; /* Major number of device entry */
#define AC_RMNEWCOMPAT 10
#define AC_RESTORE 11
-struct permissions_type
-{
+struct permissions_type {
mode_t mode;
uid_t uid;
gid_t gid;
};
-struct execute_type
-{
+struct execute_type {
char *argv[MAX_ARGS + 1]; /* argv[0] must always be the programme */
};
-struct copy_type
-{
+struct copy_type {
const char *source;
const char *destination;
};
-struct action_type
-{
+struct action_type {
unsigned int what;
unsigned int when;
};
-struct config_entry_struct
-{
+struct config_entry_struct {
struct action_type action;
regex_t preg;
union
struct config_entry_struct *next;
};
-struct get_variable_info
-{
+struct get_variable_info {
const struct devfsd_notify_struct *info;
const char *devname;
char devpath[STRING_LENGTH];
#else
#define info_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(EXIT_FAILURE)
#define error_logger(p, fmt, args...)
-#define error_logger_and_die(p, fmt, args...) exit(1)
+#define error_logger_and_die(p, fmt, args...) exit(EXIT_FAILURE)
#endif
static void safe_memcpy(char *dest, const char *src, int len)
dir_operation(SERVICE, mount_point, 0, NULL);
if (ENABLE_DEVFSD_FG_NP && no_polling)
- exit(0);
+ exit(EXIT_SUCCESS);
if (ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG)
logmode = LOGMODE_BOTH;
free(p);
return;
}
- fp = fopen(path, "r");
+ fp = fopen_for_read(path);
if (fp != NULL) {
while (fgets(buf, STRING_LENGTH, fp) != NULL) {
/* Skip whitespace */
xioctl(fd, DEVFSDIOC_SET_EVENT_MASK, (void*)event_mask);
while (!caught_signal) {
errno = 0;
- bytes = read(fd,(char *) &info, sizeof info);
+ bytes = read(fd, (char *) &info, sizeof info);
if (caught_signal)
break; /* Must test for this first */
if (errno == EINTR)
} /* End Function action_permissions */
static void action_modload(const struct devfsd_notify_struct *info,
- const struct config_entry_struct *entry ATTRIBUTE_UNUSED)
+ const struct config_entry_struct *entry UNUSED_PARAM)
/* [SUMMARY] Load a module.
<info> The devfs change.
<entry> The config file entry.
argv[4] = concat_path_file("/dev", info->devname); /* device */
argv[5] = NULL;
- wait4pid(xspawn(argv));
+ spawn_and_wait(argv);
free(argv[4]);
} /* End Function action_modload */
argv[count] = largv[count];
}
argv[count] = NULL;
- wait4pid(spawn(argv));
+ spawn_and_wait(argv);
} /* End Function action_execute */
lstat(dpath, &dest_stat);
free(dpath);
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);
if (S_ISDIR(source_stat.st_mode))
- dir_operation(RESTORE, spath, rootlen,NULL);
+ dir_operation(RESTORE, spath, rootlen, NULL);
}
break;
un_addr.sun_family = AF_UNIX;
snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s", destpath);
- val = bind(fd,(struct sockaddr *) &un_addr,(int) sizeof un_addr);
+ val = bind(fd, (struct sockaddr *) &un_addr, (int) sizeof un_addr);
close(fd);
if (val != 0 || chmod(destpath, new_mode & ~S_IFMT) != 0)
break;
msg = "group";
if (ENABLE_DEVFSD_VERBOSE)
- msg_logger(LOG_ERR,"unknown %s: %s, defaulting to %cid=0", msg, string, msg[0]);
+ msg_logger(LOG_ERR, "unknown %s: %s, defaulting to %cid=0", msg, string, msg[0]);
return 0;
}/* End Function get_uid_gid */
/* from compat_name.c */
-struct translate_struct
-{
+struct translate_struct {
const char *match; /* The string to match to(up to length) */
const char *format; /* Format of output, "%s" takes data past match string,
NULL is effectively "%s"(just more efficient) */
/* 2 ==scsi/disc, 4 == scsi/part */
if (i == 2 || i == 4)
- compat_name = write_old_sd_name(buffer, major, minor,((i == 2) ? "" : (ptr + 4)));
+ compat_name = write_old_sd_name(buffer, major, minor, ((i == 2) ? "" : (ptr + 4)));
/* 5 == scsi/mt */
if (i == 5) {
ch = input[0];
if (ch == '$') {
/* Special case for "$$": PID */
- sprintf(tmp, "%d",(int) getpid());
+ sprintf(tmp, "%d", (int) getpid());
len = strlen(tmp);
if (len + *out_pos >= length)
goto expand_variable_out;
--open_braces;
break;
case '\0':
- info_logger(LOG_INFO,"\"}\" not found in: %s", input);
+ info_logger(LOG_INFO, "\"}\" not found in: %s", input);
return NULL;
default:
break;