node = argv[optind];
if (node == NULL) {
- err("no node specified");
+ err("no node specified\n");
rc = 1;
goto exit;
}
fd = open(node, O_RDONLY|O_NONBLOCK);
if (fd < 0) {
- err("unable to open '%s'", node);
+ err("unable to open '%s'\n", node);
rc = 1;
goto exit;
}
if (ioctl(fd, HDIO_GET_IDENTITY, &id)) {
if (errno == ENOTTY) {
- info("HDIO_GET_IDENTITY unsupported for '%s'", node);
+ info("HDIO_GET_IDENTITY unsupported for '%s'\n", node);
rc = 2;
} else {
- err("HDIO_GET_IDENTITY failed for '%s'", node);
+ err("HDIO_GET_IDENTITY failed for '%s'\n", node);
rc = 3;
}
goto close;
if (debug) {
fprintf(stderr, "[%d] ", (int) getpid());
vfprintf(stderr, format, args);
- fprintf(stderr, "\n");
} else
vsyslog(priority, format, args);
va_end(args);
static void info_scsi_cmd_err(const char *cmd, int err)
{
if (err == -1) {
- info("%s failed", cmd);
+ info("%s failed\n", cmd);
return;
}
- info("%s failed with SK=%Xh/ASC=%02Xh/ACQ=%02Xh", cmd, SK(err), ASC(err), ASCQ(err));
+ info("%s failed with SK=%Xh/ASC=%02Xh/ACQ=%02Xh\n", cmd, SK(err), ASC(err), ASCQ(err));
}
struct scsi_cmd {
capabilty = ioctl(fd, CDROM_GET_CAPABILITY, NULL);
if (capabilty < 0) {
- info("CDROM_GET_CAPABILITY failed");
+ info("CDROM_GET_CAPABILITY failed\n");
return -1;
}
}
if ((inq[0] & 0x1F) != 5) {
- info("not an MMC unit");
+ info("not an MMC unit\n");
return -1;
}
- info("INQUIRY: [%.8s][%.16s][%.4s]", inq + 8, inq + 16, inq + 32);
+ info("INQUIRY: [%.8s][%.16s][%.4s]\n", inq + 8, inq + 16, inq + 32);
return 0;
}
}
len = 4 + (header[0] << 24 | header[1] << 16 | header[2] << 8 | header[3]);
- info("GET CONFIGURATION: number of profiles %i", len);
+ info("GET CONFIGURATION: number of profiles %i\n", len);
if (len > sizeof(profiles)) {
- info("invalid number of profiles");
+ info("invalid number of profiles\n");
return -1;
}
unsigned int profile = (profiles[i] << 8 | profiles[i + 1]);
if (profile == 0)
continue;
- info("profile 0x%02x", profile);
+ info("profile 0x%02x\n", profile);
switch (profile) {
case 0x03:
/* current media profile */
cur_profile = header[6] << 8 | header[7];
- info("current profile 0x%02x", cur_profile);
+ info("current profile 0x%02x\n", cur_profile);
if (cur_profile == 0) {
- info("no current profile, assuming no media");
+ info("no current profile, assuming no media\n");
return -1;
}
return -1;
};
- info("disk type %02x", header[8]);
+ info("disk type %02x\n", header[8]);
if ((header[2] & 3) < 4)
cd_media_state = media_status[header[2] & 3];
}
len = (header[0] << 8 | header[1]) + 2;
- info("READ TOC: len: %d", len);
+ info("READ TOC: len: %d\n", len);
if (len > sizeof(toc))
return -1;
/* check if we have a data track */
- info("ctl %02x (0x04 is data/audio)", header[5]);
+ info("ctl %02x (0x04 is data/audio)\n", header[5]);
cd_media_has_audio = (header[5] & 0x04) == 0;
scsi_cmd_set(&sc, 0, 0x43);
unsigned int block;
block = p[4] << 24 | p[5] << 16 | p[6] << 8 | p[7];
- info("track %u starts at block %u", p[2], block);
+ info("track %u starts at block %u\n", p[2], block);
}
scsi_cmd_set(&sc, 0, 0x43);
return -1;
}
len = header[4+4] << 24 | header[4+5] << 16 | header[4+6] << 8 | header[4+7];
- info("last track %u starts at block %u", header[4+2], len);
+ info("last track %u starts at block %u\n", header[4+2], len);
cd_media_session_last_offset = (unsigned long long int)len * 2048;
return 0;
}
node = argv[optind];
if (!node) {
- err("no device");
+ err("no device\n");
fprintf(stderr, "no device\n");
rc = 1;
goto exit;
fd = open(node, O_RDONLY | O_NONBLOCK);
if (fd < 0) {
- info("unable to open '%s'", node);
+ info("unable to open '%s'\n", node);
rc = 1;
goto exit;
}
- info("probing: '%s'", node);
+ info("probing: '%s'\n", node);
/* same data as original cdrom_id */
if (cd_capability_compat(fd) < 0) {
node = arg;
}
if (node == NULL) {
- err("no node specified");
+ err("no node specified\n");
fprintf(stderr, "no node specified\n");
goto exit;
}
/* check for kernel support */
dir = opendir("/sys/firmware/edd");
if (dir == NULL) {
- info("no kernel EDD support");
+ info("no kernel EDD support\n");
fprintf(stderr, "no kernel EDD support\n");
rc = 2;
goto exit;
disk_fd = open(node, O_RDONLY);
if (disk_fd < 0) {
- info("unable to open '%s'", node);
+ info("unable to open '%s'\n", node);
fprintf(stderr, "unable to open '%s'\n", node);
rc = 3;
goto closedir;
/* check for valid MBR signature */
if (lseek(disk_fd, 510, SEEK_SET) < 0) {
- info("seek to MBR validity failed '%s'", node);
+ info("seek to MBR validity failed '%s'\n", node);
rc = 4;
goto close;
}
if (read(disk_fd, &mbr_valid, sizeof(mbr_valid)) != sizeof(mbr_valid)) {
- info("read MBR validity failed '%s'", node);
+ info("read MBR validity failed '%s'\n", node);
rc = 5;
goto close;
}
if (mbr_valid != 0xAA55) {
fprintf(stderr, "no valid MBR signature '%s'\n", node);
- info("no valid MBR signature '%s'", node);
+ info("no valid MBR signature '%s'\n", node);
rc=6;
goto close;
}
/* read EDD signature */
if (lseek(disk_fd, 440, SEEK_SET) < 0) {
- info("seek to signature failed '%s'", node);
+ info("seek to signature failed '%s'\n", node);
rc = 7;
goto close;
}
if (read(disk_fd, &disk_id, sizeof(disk_id)) != sizeof(disk_id)) {
- info("read signature failed '%s'", node);
+ info("read signature failed '%s'\n", node);
rc = 8;
goto close;
}
/* all zero is invalid */
- info("read id 0x%08x from '%s'", disk_id, node);
+ info("read id 0x%08x from '%s'\n", disk_id, node);
if (disk_id == 0) {
fprintf(stderr, "no EDD signature '%s'\n", node);
- info("'%s' signature is zero", node);
+ info("'%s' signature is zero\n", node);
rc = 9;
goto close;
}
sysfs_fd = open(file, O_RDONLY);
if (sysfs_fd < 0) {
- info("unable to open sysfs '%s'", file);
+ info("unable to open sysfs '%s'\n", file);
continue;
}
size = read(sysfs_fd, sysfs_id_buf, sizeof(sysfs_id_buf)-1);
close(sysfs_fd);
if (size <= 0) {
- info("read sysfs '%s' failed", file);
+ info("read sysfs '%s' failed\n", file);
continue;
}
sysfs_id_buf[size] = '\0';
- info("read '%s' from '%s'", sysfs_id_buf, file);
+ info("read '%s' from '%s'\n", sysfs_id_buf, file);
sysfs_id = strtoul(sysfs_id_buf, NULL, 16);
/* look for matching value, that appears only once */
strlcpy(match, dent->d_name, sizeof(match));
} else {
/* error, same signature for another device */
- info("'%s' does not have a unique signature", node);
+ info("'%s' does not have a unique signature\n", node);
fprintf(stderr, "'%s' does not have a unique signature\n", node);
rc = 10;
goto exit;
unsigned int maj, min;
const char *attr;
- dbg("%s", devpath);
+ dbg("%s\n", devpath);
attr = sysfs_attr_get_value(devpath, "dev");
if (attr == NULL) {
- dbg("%s: could not get dev attribute: %s", devpath, strerror(errno));
+ dbg("%s: could not get dev attribute: %s\n", devpath, strerror(errno));
return -1;
}
- dbg("dev value %s", attr);
+ dbg("dev value %s\n", attr);
if (sscanf(attr, "%u:%u", &maj, &min) != 2) {
- err("%s: invalid dev major/minor", devpath);
+ err("%s: invalid dev major/minor\n", devpath);
return -1;
}
snprintf(tmpdev, MAX_PATH_LEN, "%s/%s-maj%d-min%d-%u",
TMP_DIR, TMP_PREFIX, maj, min, getpid());
- dbg("tmpdev '%s'", tmpdev);
+ dbg("tmpdev '%s'\n", tmpdev);
if (mknod(tmpdev, 0600 | dev_type, makedev(maj, min))) {
- err("mknod failed: %s", strerror(errno));
+ err("mknod failed: %s\n", strerror(errno));
return -1;
}
return 0;
if (errno == ENOENT) {
return 1;
} else {
- err("can't open %s: %s", config_file, strerror(errno));
+ err("can't open %s: %s\n", config_file, strerror(errno));
return -1;
}
}
*/
buffer = malloc(MAX_BUFFER_LEN);
if (!buffer) {
- err("Can't allocate memory.");
+ err("can't allocate memory\n");
return -1;
}
break;
lineno++;
if (buf[strlen(buffer) - 1] != '\n') {
- info("Config file line %d too long.\n", lineno);
+ info("Config file line %d too long\n", lineno);
break;
}
}
options_in = str1;
}
- dbg("config file line %d:"
+ dbg("config file line %d:\n"
" vendor '%s'; model '%s'; options '%s'\n",
lineno, vendor_in, model_in, options_in);
/*
* Only allow: [vendor=foo[,model=bar]]options=stuff
*/
if (!options_in || (!vendor_in && model_in)) {
- info("Error parsing config file line %d '%s'", lineno, buffer);
+ info("Error parsing config file line %d '%s'\n", lineno, buffer);
retval = -1;
break;
}
c = argc_count(buffer) + 2;
*newargv = calloc(c, sizeof(**newargv));
if (!*newargv) {
- err("Can't allocate memory.");
+ err("can't allocate memory\n");
retval = -1;
} else {
*argc = c;
} else if (strcmp(optarg, "pre-spc3-83") == 0) {
default_page_code = PAGE_83_PRE_SPC3;
} else {
- info("Unknown page code '%s'", optarg);
+ info("Unknown page code '%s'\n", optarg);
return -1;
}
break;
} else if (strcmp(optarg, "pre-spc3-83") == 0) {
*page_code = PAGE_83_PRE_SPC3;
} else {
- info("Unknown page code '%s'", optarg);
+ info("Unknown page code '%s'\n", optarg);
retval = -1;
}
break;
default:
- info("Unknown or bad option '%c' (0x%x)", option, option);
+ info("Unknown or bad option '%c' (0x%x)\n", option, option);
retval = -1;
break;
}
vendor = sysfs_attr_get_value(dev_scsi->devpath, "vendor");
if (!vendor) {
- info("%s: cannot get vendor attribute", dev_scsi->devpath);
+ info("%s: cannot get vendor attribute\n", dev_scsi->devpath);
return -1;
}
set_str(vendor_str, vendor, sizeof(vendor_str)-1);
type = sysfs_attr_get_value(dev_scsi->devpath, "type");
if (!type) {
- info("%s: cannot get type attribute", dev_scsi->devpath);
+ info("%s: cannot get type attribute\n", dev_scsi->devpath);
return -1;
}
set_type(type_str, type, sizeof(type_str));
dev = sysfs_device_get(devpath);
if (dev == NULL) {
- err("unable to access '%s'", devpath);
+ err("unable to access '%s'\n", devpath);
return 1;
}
/* get scsi parent device */
dev_scsi = sysfs_device_get_parent_with_subsystem(dev, "scsi");
if (dev_scsi == NULL) {
- err("unable to access parent device of '%s'", devpath);
+ err("unable to access parent device of '%s'\n", devpath);
return 1;
}
set_sysfs_values(dev_scsi);
/* get per device (vendor + model) options from the config file */
retval = per_dev_options(dev_scsi, &good_dev, &page_code);
- dbg("per dev options: good %d; page code 0x%x", good_dev, page_code);
+ dbg("per dev options: good %d; page code 0x%x\n", good_dev, page_code);
if (!good_dev) {
retval = 1;
sb_len = io->sb_len_wr;
if (sb_len < 1) {
- info("%s: sense buffer empty", dev_scsi->kernel);
+ info("%s: sense buffer empty\n", dev_scsi->kernel);
return -1;
}
*/
s = sense_buffer[7] + 8;
if (sb_len < s) {
- info("%s: sense buffer too small %d bytes, %d bytes too short",
+ info("%s: sense buffer too small %d bytes, %d bytes too short\n",
dev_scsi->kernel, sb_len, s - sb_len);
return -1;
}
/*
* Possible?
*/
- info("%s: sense result too" " small %d bytes",
+ info("%s: sense result too" " small %d bytes\n",
dev_scsi->kernel, s);
return -1;
}
asc = sense_buffer[2];
ascq = sense_buffer[3];
} else {
- info("%s: invalid sense code 0x%x",
+ info("%s: invalid sense code 0x%x\n",
dev_scsi->kernel, code);
return -1;
}
- info("%s: sense key 0x%x ASC 0x%x ASCQ 0x%x",
+ info("%s: sense key 0x%x ASC 0x%x ASCQ 0x%x\n",
dev_scsi->kernel, sense_key, asc, ascq);
} else {
if (sb_len < 4) {
- info("%s: sense buffer too small %d bytes, %d bytes too short",
+ info("%s: sense buffer too small %d bytes, %d bytes too short\n",
dev_scsi->kernel, sb_len, 4 - sb_len);
return -1;
}
if (sense_buffer[0] < 15)
- info("%s: old sense key: 0x%x", dev_scsi->kernel, sense_buffer[0] & 0x0f);
+ info("%s: old sense key: 0x%x\n", dev_scsi->kernel, sense_buffer[0] & 0x0f);
else
- info("%s: sense = %2x %2x",
+ info("%s: sense = %2x %2x\n",
dev_scsi->kernel, sense_buffer[0], sense_buffer[2]);
- info("%s: non-extended sense class %d code 0x%0x",
+ info("%s: non-extended sense class %d code 0x%0x\n",
dev_scsi->kernel, sense_class, code);
}
out_buffer[j++] = ' ';
}
out_buffer[j] = '\0';
- info("%s: sense dump:", dev_scsi->kernel);
- info("%s: %s", dev_scsi->kernel, out_buffer);
+ info("%s: sense dump:\n", dev_scsi->kernel);
+ info("%s: %s\n", dev_scsi->kernel, out_buffer);
#endif
return -1;
/*
* Impossible, should not be called.
*/
- info("%s: called with no error", __FUNCTION__);
+ info("%s: called with no error\n", __FUNCTION__);
return -1;
}
- info("%s: sg_io failed status 0x%x 0x%x 0x%x 0x%x",
+ info("%s: sg_io failed status 0x%x 0x%x 0x%x 0x%x\n",
dev_scsi->kernel, io->driver_status, io->host_status, io->msg_status, io->status);
if (io->status == SCSI_CHECK_CONDITION)
return scsi_dump_sense(dev_scsi, io);
int retry = 3; /* rather random */
if (buflen > SCSI_INQ_BUFF_LEN) {
- info("buflen %d too long", buflen);
+ info("buflen %d too long\n", buflen);
return -1;
}
io_hdr.timeout = DEF_TIMEOUT;
if (ioctl(fd, SG_IO, &io_hdr) < 0) {
- info("%s: ioctl failed: %s", dev_scsi->kernel, strerror(errno));
+ info("%s: ioctl failed: %s\n", dev_scsi->kernel, strerror(errno));
retval = -1;
goto error;
}
error:
if (retval < 0)
- info("%s: Unable to get INQUIRY vpd %d page 0x%x.",
+ info("%s: Unable to get INQUIRY vpd %d page 0x%x.\n",
dev_scsi->kernel, evpd, page);
return retval;
return 1;
if (buffer[1] != 0) {
- info("%s: page 0 not available.", dev_scsi->kernel);
+ info("%s: page 0 not available.\n", dev_scsi->kernel);
return 1;
}
if (buffer[3] > len) {
- info("%s: page 0 buffer too long %d", dev_scsi->kernel, buffer[3]);
+ info("%s: page 0 buffer too long %d\n", dev_scsi->kernel, buffer[3]);
return 1;
}
*/
vendor = sysfs_attr_get_value(dev_scsi->devpath, "vendor");
if (!vendor) {
- info("%s: cannot get model attribute", dev_scsi->kernel);
+ info("%s: cannot get model attribute\n", dev_scsi->kernel);
return 1;
}
if (!strncmp((char *)&buffer[VENDOR_LENGTH], vendor, VENDOR_LENGTH)) {
- info("%s: invalid page0 data", dev_scsi->kernel);
+ info("%s: invalid page0 data\n", dev_scsi->kernel);
return 1;
}
}
attr = sysfs_attr_get_value(dev_scsi->devpath, "vendor");
if (!attr) {
- info("%s: cannot get vendor attribute", dev_scsi->kernel);
+ info("%s: cannot get vendor attribute\n", dev_scsi->kernel);
return 1;
}
strncpy(serial, attr, VENDOR_LENGTH);
attr = sysfs_attr_get_value(dev_scsi->devpath, "model");
if (!attr) {
- info("%s: cannot get model attribute", dev_scsi->kernel);
+ info("%s: cannot get model attribute\n", dev_scsi->kernel);
return 1;
}
strncat(serial, attr, MODEL_LENGTH);
* above, ind will never be too large.
*/
if (ind != (VENDOR_LENGTH + MODEL_LENGTH)) {
- info("%s: expected length %d, got length %d",
+ info("%s: expected length %d, got length %d\n",
dev_scsi->kernel, (VENDOR_LENGTH + MODEL_LENGTH), ind);
return 1;
}
len += VENDOR_LENGTH + MODEL_LENGTH;
if (max_len < len) {
- info("%s: length %d too short - need %d",
+ info("%s: length %d too short - need %d\n",
dev_scsi->kernel, max_len, len);
return 1;
}
{
int i, j;
- dbg("using pre-spc3-83 for %s.\n", dev_scsi->kernel);
+ dbg("using pre-spc3-83 for %s\n", dev_scsi->kernel);
serial[0] = hex_str[id_search->id_type];
/* serial has been memset to zero before */
j = strlen(serial); /* j = 1; */
return 1;
if (page_83[1] != PAGE_83) {
- info("%s: Invalid page 0x83", dev_scsi->kernel);
+ info("%s: Invalid page 0x83\n", dev_scsi->kernel);
return 1;
}
id_search_list[id_ind].naa_type,
id_search_list[id_ind].code_set);
if (!retval) {
- dbg(" used\n");
+ dbg(" used\n");
return retval;
} else if (retval < 0) {
- dbg(" failed\n");
+ dbg(" failed\n");
return retval;
} else {
- dbg(" not used\n");
+ dbg(" not used\n");
}
}
}
return 1;
if (page_83[1] != PAGE_83) {
- info("%s: Invalid page 0x83", dev_scsi->kernel);
+ info("%s: Invalid page 0x83\n", dev_scsi->kernel);
return 1;
}
/*
serial[j++] = hex_str[page_83[i] & 0x0f];
i++;
}
- dbg("using pre-spc3-83 for %s.\n", dev_scsi->kernel);
+ dbg("using pre-spc3-83 for %s\n", dev_scsi->kernel);
return 0;
}
return retval;
if (buf[1] != PAGE_80) {
- info("%s: Invalid page 0x80", dev_scsi->kernel);
+ info("%s: Invalid page 0x80\n", dev_scsi->kernel);
return 1;
}
len = 1 + VENDOR_LENGTH + MODEL_LENGTH + buf[3];
if (max_len < len) {
- info("%s: length %d too short - need %d",
+ info("%s: length %d too short - need %d\n",
dev_scsi->kernel, max_len, len);
return 1;
}
dbg("opening %s\n", devname);
fd = open(devname, O_RDONLY | O_NONBLOCK);
if (fd < 0) {
- info("%s: cannot open %s: %s",
+ info("%s: cannot open %s: %s\n",
dev_scsi->kernel, devname, strerror(errno));
return 1;
}
sprintf(type,"%x", buf[0] & 0x1f);
if (close(fd) < 0)
- info("%s: close failed: %s", dev_scsi->kernel, strerror(errno));
+ info("%s: close failed: %s\n", dev_scsi->kernel, strerror(errno));
return 0;
}
dbg("opening %s\n", devname);
fd = open(devname, O_RDONLY | O_NONBLOCK);
if (fd < 0) {
- info("%s: cannot open %s: %s",
+ info("%s: cannot open %s: %s\n",
dev_scsi->kernel, devname, strerror(errno));
return 1;
}
goto completed;
}
} else if (page_code != 0x00) {
- info("%s: unsupported page code 0x%d", dev_scsi->kernel, page_code);
+ info("%s: unsupported page code 0x%d\n", dev_scsi->kernel, page_code);
return 1;
}
retval = 1;
completed:
if (close(fd) < 0)
- info("%s: close failed: %s", dev_scsi->kernel, strerror(errno));
+ info("%s: close failed: %s\n", dev_scsi->kernel, strerror(errno));
return retval;
}
/* get all usb specific information: dev_interface, if_class, dev_usb */
dev = sysfs_device_get(devpath);
if (dev == NULL) {
- err("unable to access '%s'", devpath);
+ err("unable to access '%s'\n", devpath);
return 1;
}
/* usb interface directory */
dev_interface = sysfs_device_get_parent_with_subsystem(dev, "usb");
if (dev_interface == NULL) {
- info("unable to access usb_interface device of '%s'", devpath);
+ info("unable to access usb_interface device of '%s'\n", devpath);
return 1;
}
if_class = sysfs_attr_get_value(dev_interface->devpath, "bInterfaceClass");
if (!if_class) {
- info("%s: cannot get bInterfaceClass attribute", dev_interface->kernel);
+ info("%s: cannot get bInterfaceClass attribute\n", dev_interface->kernel);
return 1;
}
if_class_num = strtoul(if_class, NULL, 16);
/* usb device directory */
dev_usb = sysfs_device_get_parent_with_subsystem(dev_interface, "usb");
if (!dev_usb) {
- info("unable to find parent 'usb' device of '%s'", devpath);
+ info("unable to find parent 'usb' device of '%s'\n", devpath);
return 1;
}
/* get scsi device */
dev_scsi = sysfs_device_get_parent_with_subsystem(dev, "scsi");
if (dev_scsi == NULL) {
- info("unable to find parent 'scsi' device of '%s'", devpath);
+ info("unable to find parent 'scsi' device of '%s'\n", devpath);
goto fallback;
}
if (sscanf(dev_scsi->kernel, "%d:%d:%d:%d", &host, &bus, &target, &lun) != 4) {
- info("invalid scsi device '%s'", dev_scsi->kernel);
+ info("invalid scsi device '%s'\n", dev_scsi->kernel);
goto fallback;
}
/* Generic SPC-2 device */
scsi_vendor = sysfs_attr_get_value(dev_scsi->devpath, "vendor");
if (!scsi_vendor) {
- info("%s: cannot get SCSI vendor attribute", dev_scsi->kernel);
+ info("%s: cannot get SCSI vendor attribute\n", dev_scsi->kernel);
goto fallback;
}
set_str(vendor_str, scsi_vendor, sizeof(vendor_str)-1);
scsi_model = sysfs_attr_get_value(dev_scsi->devpath, "model");
if (!scsi_model) {
- info("%s: cannot get SCSI model attribute", dev_scsi->kernel);
+ info("%s: cannot get SCSI model attribute\n", dev_scsi->kernel);
goto fallback;
}
set_str(model_str, scsi_model, sizeof(model_str)-1);
scsi_type = sysfs_attr_get_value(dev_scsi->devpath, "type");
if (!scsi_type) {
- info("%s: cannot get SCSI type attribute", dev_scsi->kernel);
+ info("%s: cannot get SCSI type attribute\n", dev_scsi->kernel);
goto fallback;
}
set_scsi_type(type_str, scsi_type, sizeof(type_str)-1);
scsi_rev = sysfs_attr_get_value(dev_scsi->devpath, "rev");
if (!scsi_rev) {
- info("%s: cannot get SCSI revision attribute", dev_scsi->kernel);
+ info("%s: cannot get SCSI revision attribute\n", dev_scsi->kernel);
goto fallback;
}
set_str(revision_str, scsi_rev, sizeof(revision_str)-1);
usb_vendor = sysfs_attr_get_value(dev_usb->devpath, "idVendor");
if (!usb_vendor) {
- info("No USB vendor information available");
+ info("No USB vendor information available\n");
return 1;
}
set_str(vendor_str, usb_vendor, sizeof(vendor_str)-1);
usb_model = sysfs_attr_get_value(dev_usb->devpath, "idProduct");
if (!usb_model) {
- dbg("No USB model information available");
+ dbg("No USB model information available\n");
return 1;
}
set_str(model_str, usb_model, sizeof(model_str)-1);
uint64_t meta_off;
struct adaptec_meta *ad;
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
if (size < 0x10000)
{
struct cramfs_super *cs;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
cs = (struct cramfs_super *) volume_id_get_buffer(id, off, 0x200);
if (cs == NULL)
uint64_t ddf_off = ((size / 0x200)-1) * 0x200;
const uint8_t *buf;
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
if (size < 0x10000)
return -1;
uint32_t feature_incompat;
uint32_t flags;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
es = (struct ext2_super_block *) volume_id_get_buffer(id, off + EXT_SUPERBLOCK_OFFSET, 0x200);
if (es == NULL)
return -1;
bsize = 0x400 << le32_to_cpu(es->s_log_block_size);
- dbg("ext blocksize 0x%zx", bsize);
+ dbg("ext blocksize 0x%zx\n", bsize);
if (bsize < EXT3_MIN_BLOCK_SIZE || bsize > EXT3_MAX_BLOCK_SIZE) {
- dbg("invalid ext blocksize");
+ dbg("invalid ext blocksize\n");
return -1;
}
for (i = 0; i < count; i++) {
/* end marker */
if (dir[i].name[0] == 0x00) {
- dbg("end of dir");
+ dbg("end of dir\n");
break;
}
if (dir[i].cluster_high != 0 || dir[i].cluster_low != 0)
continue;
- dbg("found ATTR_VOLUME_ID id in root dir");
+ dbg("found ATTR_VOLUME_ID id in root dir\n");
return fat_read_filename(filename, fnsize, dir, &dir[i]);
}
- dbg("skip dir entry");
+ dbg("skip dir entry\n");
}
return 0;
int maxloop;
size_t fnlen;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
buf = volume_id_get_buffer(id, off, 0x400);
if (buf == NULL)
if (sector_size == 0 || ((sector_size & (sector_size-1)) != 0))
return -1;
- dbg("sector_size 0x%x", sector_size);
- dbg("sectors_per_cluster 0x%x", vs->sectors_per_cluster);
+ dbg("sector_size 0x%x\n", sector_size);
+ dbg("sectors_per_cluster 0x%x\n", vs->sectors_per_cluster);
dir_entries = le16_to_cpu(vs->dir_entries);
reserved = le16_to_cpu(vs->reserved);
- dbg("reserved 0x%x", reserved);
+ dbg("reserved 0x%x\n", reserved);
sect_count = le16_to_cpu(vs->sectors);
if (sect_count == 0)
sect_count = le32_to_cpu(vs->total_sect);
- dbg("sect_count 0x%x", sect_count);
+ dbg("sect_count 0x%x\n", sect_count);
fat_length = le16_to_cpu(vs->fat_length);
- dbg("fat_length 0x%x", fat_length);
+ dbg("fat_length 0x%x\n", fat_length);
fat32_length = le32_to_cpu(vs->type.fat32.fat32_length);
- dbg("fat32_length 0x%x", fat32_length);
+ dbg("fat32_length 0x%x\n", fat32_length);
if (fat_length)
fat_size = fat_length * vs->fats;
fat_size = fat32_length * vs->fats;
else
return -1;
- dbg("fat_size 0x%x", fat_size);
+ dbg("fat_size 0x%x\n", fat_size);
dir_size = ((dir_entries * sizeof(struct vfat_dir_entry)) +
(sector_size-1)) / sector_size;
- dbg("dir_size 0x%x", dir_size);
+ dbg("dir_size 0x%x\n", dir_size);
cluster_count = sect_count - (reserved + fat_size + dir_size);
cluster_count /= vs->sectors_per_cluster;
- dbg("cluster_count 0x%x", cluster_count);
+ dbg("cluster_count 0x%x\n", cluster_count);
/* must be FAT32 */
if (!fat_length && fat32_length)
/* the label may be an attribute in the root directory */
root_start = (reserved + fat_size) * sector_size;
- dbg("root dir start 0x%llx", (unsigned long long) root_start);
+ dbg("root dir start 0x%llx\n", (unsigned long long) root_start);
root_dir_entries = le16_to_cpu(vs->dir_entries);
- dbg("expected entries 0x%x", root_dir_entries);
+ dbg("expected entries 0x%x\n", root_dir_entries);
buf_size = root_dir_entries * sizeof(struct vfat_dir_entry);
buf = volume_id_get_buffer(id, off + root_start, buf_size);
/* FAT32 root dir is a cluster chain like any other directory */
buf_size = vs->sectors_per_cluster * sector_size;
root_cluster = le32_to_cpu(vs->type.fat32.root_cluster);
- dbg("root dir cluster %u", root_cluster);
+ dbg("root dir cluster %u\n", root_cluster);
start_data_sect = reserved + fat_size;
next = root_cluster;
uint64_t fat_entry_off;
int count;
- dbg("next cluster %u", next);
+ dbg("next cluster %u\n", next);
next_sect_off = (next - 2) * vs->sectors_per_cluster;
next_off = (start_data_sect + next_sect_off) * sector_size;
- dbg("cluster offset 0x%llx", (unsigned long long) next_off);
+ dbg("cluster offset 0x%llx\n", (unsigned long long) next_off);
/* get cluster */
buf = volume_id_get_buffer(id, off + next_off, buf_size);
dir = (struct vfat_dir_entry*) buf;
count = buf_size / sizeof(struct vfat_dir_entry);
- dbg("expected entries 0x%x", count);
+ dbg("expected entries 0x%x\n", count);
fnlen = get_fat_attr_volume_id(filename, sizeof(filename), dir, count);
if (fnlen > 0)
break;
}
if (maxloop == 0)
- dbg("reached maximum follow count of root cluster chain, give up");
+ dbg("reached maximum follow count of root cluster chain, give up\n");
vs = (struct vfat_super_block *) volume_id_get_buffer(id, off, 0x200);
if (vs == NULL)
{
struct gfs2_sb *sbd;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
sbd = (struct gfs2_sb *)
volume_id_get_buffer(id, off + GFS_SUPERBLOCK_OFFSET, sizeof(struct gfs2_sb));
struct hfsplus_extent extents[HFSPLUS_EXTENT_COUNT];
const uint8_t *buf;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
buf = volume_id_get_buffer(id, off + HFS_SUPERBLOCK_OFFSET, 0x200);
if (buf == NULL)
/* it may be just a hfs wrapper for hfs+ */
if (memcmp(hfs->embed_sig, "H+", 2) == 0) {
alloc_block_size = be32_to_cpu(hfs->al_blk_size);
- dbg("alloc_block_size 0x%x", alloc_block_size);
+ dbg("alloc_block_size 0x%x\n", alloc_block_size);
alloc_first_block = be16_to_cpu(hfs->al_bl_st);
- dbg("alloc_first_block 0x%x", alloc_first_block);
+ dbg("alloc_first_block 0x%x\n", alloc_first_block);
embed_first_block = be16_to_cpu(hfs->embed_startblock);
- dbg("embed_first_block 0x%x", embed_first_block);
+ dbg("embed_first_block 0x%x\n", embed_first_block);
off += (alloc_first_block * 512) +
(embed_first_block * alloc_block_size);
- dbg("hfs wrapped hfs+ found at offset 0x%llx", (unsigned long long) off);
+ dbg("hfs wrapped hfs+ found at offset 0x%llx\n", (unsigned long long) off);
buf = volume_id_get_buffer(id, off + HFS_SUPERBLOCK_OFFSET, 0x200);
if (buf == NULL)
hfsid_set_uuid(id, hfsplus->finder_info.id);
blocksize = be32_to_cpu(hfsplus->blocksize);
- dbg("blocksize %u", blocksize);
+ dbg("blocksize %u\n", blocksize);
memcpy(extents, hfsplus->cat_file.extents, sizeof(extents));
cat_block = be32_to_cpu(extents[0].start_block);
- dbg("catalog start block 0x%x", cat_block);
+ dbg("catalog start block 0x%x\n", cat_block);
buf = volume_id_get_buffer(id, off + (cat_block * blocksize), 0x2000);
if (buf == NULL)
&buf[sizeof(struct hfsplus_bnode_descriptor)];
leaf_node_head = be32_to_cpu(bnode->leaf_head);
- dbg("catalog leaf node 0x%x", leaf_node_head);
+ dbg("catalog leaf node 0x%x\n", leaf_node_head);
leaf_node_size = be16_to_cpu(bnode->node_size);
- dbg("leaf node size 0x%x", leaf_node_size);
+ dbg("leaf node size 0x%x\n", leaf_node_size);
leaf_node_count = be32_to_cpu(bnode->leaf_count);
- dbg("leaf node count 0x%x", leaf_node_count);
+ dbg("leaf node count 0x%x\n", leaf_node_count);
if (leaf_node_count == 0)
goto found;
for (ext = 0; ext < HFSPLUS_EXTENT_COUNT; ext++) {
ext_block_start = be32_to_cpu(extents[ext].start_block);
ext_block_count = be32_to_cpu(extents[ext].block_count);
- dbg("extent start block 0x%x, count 0x%x", ext_block_start, ext_block_count);
+ dbg("extent start block 0x%x, count 0x%x\n", ext_block_start, ext_block_count);
if (ext_block_count == 0)
goto found;
}
if (ext == HFSPLUS_EXTENT_COUNT)
goto found;
- dbg("found block in extent %i", ext);
+ dbg("found block in extent %i\n", ext);
leaf_off = (ext_block_start + leaf_block) * blocksize;
goto found;
descr = (struct hfsplus_bnode_descriptor *) buf;
- dbg("descriptor type 0x%x", descr->type);
+ dbg("descriptor type 0x%x\n", descr->type);
record_count = be16_to_cpu(descr->num_recs);
- dbg("number of records %u", record_count);
+ dbg("number of records %u\n", record_count);
if (record_count == 0)
goto found;
key = (struct hfsplus_catalog_key *)
&buf[sizeof(struct hfsplus_bnode_descriptor)];
- dbg("parent id 0x%x", be32_to_cpu(key->parent_id));
+ dbg("parent id 0x%x\n", be32_to_cpu(key->parent_id));
if (be32_to_cpu(key->parent_id) != HFSPLUS_POR_CNID)
goto found;
label_len = be16_to_cpu(key->unicode_len) * 2;
- dbg("label unicode16 len %i", label_len);
+ dbg("label unicode16 len %i\n", label_len);
volume_id_set_label_raw(id, key->unicode, label_len);
volume_id_set_label_unicode16(id, key->unicode, BE, label_len);
struct hpt37x_meta *hpt;
uint32_t magic;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
buf = volume_id_get_buffer(id, off + HPT37X_CONFIG_OFF, 0x200);
if (buf == NULL)
uint64_t meta_off;
uint32_t magic;
- dbg("probing at offset 0x%llx, size 0x%llx",
+ dbg("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
if (size < 0x10000)
{
struct hpfs_super *hs;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
hs = (struct hpfs_super *) volume_id_get_buffer(id, off + HPFS_SUPERBLOCK_OFFSET, 0x200);
if (hs == NULL)
struct iso_volume_descriptor *is;
struct high_sierra_volume_descriptor *hs;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
buf = volume_id_get_buffer(id, off + ISO_SUPERBLOCK_OFFSET, 0x200);
if (buf == NULL)
int vd_offset;
int i;
- dbg("read label from PVD");
+ dbg("read label from PVD\n");
volume_id_set_label_raw(id, is->volume_id, 32);
volume_id_set_label_string(id, is->volume_id, 32);
- dbg("looking for SVDs");
+ dbg("looking for SVDs\n");
vd_offset = ISO_VD_OFFSET;
for (i = 0; i < ISO_VD_MAX; i++) {
uint8_t svd_label[64];
if (is->type != ISO_VD_SUPPLEMENTARY)
continue;
- dbg("found SVD at offset 0x%llx", (unsigned long long) (off + vd_offset));
+ dbg("found SVD at offset 0x%llx\n", (unsigned long long) (off + vd_offset));
if (memcmp(is->escape_sequences, "%/@", 3) == 0||
memcmp(is->escape_sequences, "%/C", 3) == 0||
memcmp(is->escape_sequences, "%/E", 3) == 0) {
- dbg("Joliet extension found");
+ dbg("Joliet extension found\n");
volume_id_set_unicode16(svd_label, sizeof(svd_label), is->volume_id, BE, 32);
if (memcmp(id->label, svd_label, 16) == 0) {
- dbg("SVD label is identical, use the possibly longer PVD one");
+ dbg("SVD label is identical, use the possibly longer PVD one\n");
break;
}
uint64_t meta_off;
struct isw_meta *isw;
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
if (size < 0x10000)
{
struct jfs_super_block *js;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
js = (struct jfs_super_block *) volume_id_get_buffer(id, off + JFS_SUPERBLOCK_OFFSET, 0x200);
if (js == NULL)
uint64_t meta_off;
struct jmicron_meta *jm;
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
if (size < 0x10000)
uint8_t bytes[16];
} uuid;
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
if (size < 0x10000)
return -1;
{
const uint8_t *buf;
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
buf = volume_id_get_buffer(id, off, 0x800);
unsigned int page;
struct swap_header_v1_2 *sw;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
/* eek, the swap signature is at the end of the PAGE_SIZE */
for (page = 0x1000; page <= LARGEST_PAGESIZE; page <<= 1) {
uint64_t meta_off;
struct lsi_meta *lsi;
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
if (size < 0x10000)
const uint8_t *buf;
struct lvm1_super_block *lvm;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
buf = volume_id_get_buffer(id, off + LVM1_SB_OFF, 0x800);
if (buf == NULL)
struct lvm2_super_block *lvm;
struct lvm2_pv_header *pvhdr;
- dbg("probing at offset 0x%llx", (unsigned long long) off);
+ dbg("probing at offset 0x%llx\n", (unsigned long long) off);
buf = volume_id_get_buffer(id, off, LVM2LABEL_SCAN_SECTORS * 0x200);
if (buf == NULL)
return -1;
found:
- dbg("found at offset 0x%x (pv hdr offset 0x%x)",
+ dbg("found at offset 0x%x (pv hdr offset 0x%x)\n",
soff, cpu_to_le32(lvm->offset_xl));
soff += cpu_to_le32(lvm->offset_xl);
pvhdr = (struct lvm2_pv_header *) &buf[soff];
struct minix_super_block *ms;
struct minix3_super_block *m3s;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
buf = volume_id_get_buffer(id, off + MINIX_SUPERBLOCK_OFFSET, 0x200);
if (buf == NULL)
{
struct netware_super_block *nw;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
nw = (struct netware_super_block *) volume_id_get_buffer(id, off + NW_SUPERBLOCK_OFFSET, 0x200);
if (nw == NULL)
const uint8_t *buf;
const uint8_t *val;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
ns = (struct ntfs_super_block *) volume_id_get_buffer(id, off, 0x200);
if (ns == NULL)
else
mft_record_size = ns->cluster_per_mft_record * cluster_size;
- dbg("sectorsize 0x%x", sector_size);
- dbg("clustersize 0x%x", cluster_size);
- dbg("mftcluster %llu", (unsigned long long) mft_cluster);
- dbg("mftoffset 0x%llx", (unsigned long long) mft_off);
- dbg("cluster per mft_record %i", ns->cluster_per_mft_record);
- dbg("mft record size %i", mft_record_size);
+ dbg("sectorsize 0x%x\n", sector_size);
+ dbg("clustersize 0x%x\n", cluster_size);
+ dbg("mftcluster %llu\n", (unsigned long long) mft_cluster);
+ dbg("mftoffset 0x%llx\n", (unsigned long long) mft_off);
+ dbg("cluster per mft_record %i\n", ns->cluster_per_mft_record);
+ dbg("mft record size %i\n", mft_record_size);
buf = volume_id_get_buffer(id, off + mft_off + (MFT_RECORD_VOLUME * mft_record_size),
mft_record_size);
return -1;
mftr = (struct master_file_table_record*) buf;
- dbg("mftr->magic '%c%c%c%c'", mftr->magic[0], mftr->magic[1], mftr->magic[2], mftr->magic[3]);
+ dbg("mftr->magic '%c%c%c%c'\n", mftr->magic[0], mftr->magic[1], mftr->magic[2], mftr->magic[3]);
if (memcmp(mftr->magic, "FILE", 4) != 0)
return -1;
attr_off = le16_to_cpu(mftr->attrs_offset);
- dbg("file $Volume's attributes are at offset %i", attr_off);
+ dbg("file $Volume's attributes are at offset %i\n", attr_off);
while (1) {
attr = (struct file_attribute*) &buf[attr_off];
if (attr_type == MFT_RECORD_ATTR_END)
break;
- dbg("found attribute type 0x%x, len %i, at offset %i",
+ dbg("found attribute type 0x%x, len %i, at offset %i\n",
attr_type, attr_len, attr_off);
if (attr_type == MFT_RECORD_ATTR_VOLUME_INFO) {
- dbg("found info, len %i", val_len);
+ dbg("found info, len %i\n", val_len);
info = (struct volume_info*) (((uint8_t *) attr) + val_off);
snprintf(id->type_version, sizeof(id->type_version)-1,
"%u.%u", info->major_ver, info->minor_ver);
}
if (attr_type == MFT_RECORD_ATTR_VOLUME_NAME) {
- dbg("found label, len %i", val_len);
+ dbg("found label, len %i\n", val_len);
if (val_len > VOLUME_ID_LABEL_SIZE)
val_len = VOLUME_ID_LABEL_SIZE;
uint64_t meta_off;
struct nvidia_meta *nv;
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
if (size < 0x10000)
struct ocfs1_super_block_header *osh;
struct ocfs1_super_block_label *osl;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
buf = volume_id_get_buffer(id, off, 0x200);
if (buf == NULL)
snprintf(id->type_version, sizeof(id->type_version)-1,
"%u.%u", osh->major_version, osh->minor_version);
- dbg("found OracleCFS signature, now reading label");
+ dbg("found OracleCFS signature, now reading label\n");
buf = volume_id_get_buffer(id, off + 0x200, 0x200);
if (buf == NULL)
return -1;
struct ocfs2_super_block *os;
size_t blksize;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
for (blksize = 0x200; blksize <= OCFS2_MAX_BLOCKSIZE; blksize <<= 1) {
buf = volume_id_get_buffer(id, off + OCFS2_SUPER_BLOCK_BLKNO * blksize, 0x200);
63, 255, 256, 16, 399, 0
};
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
if (size < 0x40000)
struct reiser4_super_block *rs4;
uint8_t *buf;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
buf = volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200);
if (buf == NULL)
{
struct romfs_super *rfs;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
rfs = (struct romfs_super *) volume_id_get_buffer(id, off, 0x200);
if (rfs == NULL)
uint64_t meta_off;
struct silicon_meta *sil;
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
if (size < 0x10000)
{
struct squashfs_super *sqs;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
sqs = (struct squashfs_super *) volume_id_get_buffer(id, off, 0x200);
if (sqs == NULL)
struct xenix_super *xs;
unsigned int boff;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
for (boff = 0x200; boff <= SYSV_MAX_BLOCKSIZE; boff <<= 1) {
vs = (struct sysv_super *)
unsigned int loc;
unsigned int clen;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
vsd = (struct volume_structure_descriptor *) volume_id_get_buffer(id, off + UDF_VSD_OFFSET, 0x200);
if (vsd == NULL)
vsd = (struct volume_structure_descriptor *) volume_id_get_buffer(id, off + UDF_VSD_OFFSET + bs, 0x800);
if (vsd == NULL)
return -1;
- dbg("test for blocksize: 0x%x", bs);
+ dbg("test for blocksize: 0x%x\n", bs);
if (vsd->id[0] != '\0')
goto nsr;
}
if (vsd == NULL)
return -1;
- dbg("vsd: %c%c%c%c%c",
+ dbg("vsd: %c%c%c%c%c\n",
vsd->id[0], vsd->id[1], vsd->id[2], vsd->id[3], vsd->id[4]);
if (vsd->id[0] == '\0')
/* get desriptor list address and block count */
count = le32_to_cpu(vd->type.anchor.length) / bs;
loc = le32_to_cpu(vd->type.anchor.location);
- dbg("0x%x descriptors starting at logical secor 0x%x", count, loc);
+ dbg("0x%x descriptors starting at logical secor 0x%x\n", count, loc);
/* pick the primary descriptor from the list */
for (b = 0; b < count; b++) {
return -1;
type = le16_to_cpu(vd->tag.id);
- dbg("descriptor type %i", type);
+ dbg("descriptor type %i\n", type);
/* check validity */
if (type == 0)
volume_id_set_label_raw(id, &(vd->type.primary.ident.clen), 32);
clen = vd->type.primary.ident.clen;
- dbg("label string charsize=%i bit", clen);
+ dbg("label string charsize=%i bit\n", clen);
if (clen == 8)
volume_id_set_label_string(id, vd->type.primary.ident.c, 31);
else if (clen == 16)
struct ufs_super_block *ufs;
int offsets[] = {0, 8, 64, 256, -1};
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
for (i = 0; offsets[i] >= 0; i++) {
ufs = (struct ufs_super_block *) volume_id_get_buffer(id, off + (offsets[i] * 0x400), 0x800);
if (ufs == NULL)
return -1;
- dbg("offset 0x%x", offsets[i] * 0x400);
+ dbg("offset 0x%x\n", offsets[i] * 0x400);
magic = be32_to_cpu(ufs->fs_magic);
if ((magic == UFS_MAGIC) ||
(magic == UFS2_MAGIC) ||
(magic == UFS_MAGIC_FEA) ||
(magic == UFS_MAGIC_LFN)) {
- dbg("magic 0x%08x(be)", magic);
+ dbg("magic 0x%08x(be)\n", magic);
goto found;
}
magic = le32_to_cpu(ufs->fs_magic);
(magic == UFS2_MAGIC) ||
(magic == UFS_MAGIC_FEA) ||
(magic == UFS_MAGIC_LFN)) {
- dbg("magic 0x%08x(le)", magic);
+ dbg("magic 0x%08x(le)\n", magic);
goto found;
}
}
{
ssize_t buf_len;
- info("get buffer off 0x%llx(%llu), len 0x%zx", (unsigned long long) off, (unsigned long long) off, len);
+ info("get buffer off 0x%llx(%llu), len 0x%zx\n", (unsigned long long) off, (unsigned long long) off, len);
/* check if requested area fits in superblock buffer */
if (off + len <= SB_BUFFER_SIZE) {
if (id->sbbuf == NULL) {
id->sbbuf = malloc(SB_BUFFER_SIZE);
if (id->sbbuf == NULL) {
- dbg("error malloc");
+ dbg("error malloc\n");
return NULL;
}
}
/* check if we need to read */
if ((off + len) > id->sbbuf_len) {
- info("read sbbuf len:0x%llx", (unsigned long long) (off + len));
+ info("read sbbuf len:0x%llx\n", (unsigned long long) (off + len));
if (lseek(id->fd, 0, SEEK_SET) < 0) {
- dbg("lseek failed (%s)", strerror(errno));
+ dbg("lseek failed (%s)\n", strerror(errno));
return NULL;
}
buf_len = read(id->fd, id->sbbuf, off + len);
if (buf_len < 0) {
- dbg("read failed (%s)", strerror(errno));
+ dbg("read failed (%s)\n", strerror(errno));
return NULL;
}
- dbg("got 0x%zx (%zi) bytes", buf_len, buf_len);
+ dbg("got 0x%zx (%zi) bytes\n", buf_len, buf_len);
id->sbbuf_len = buf_len;
if ((size_t)buf_len < off + len) {
- dbg("requested 0x%zx bytes, got only 0x%zx bytes", len, buf_len);
+ dbg("requested 0x%zx bytes, got only 0x%zx bytes\n", len, buf_len);
return NULL;
}
}
return &(id->sbbuf[off]);
} else {
if (len > SEEK_BUFFER_SIZE) {
- dbg("seek buffer too small %d", SEEK_BUFFER_SIZE);
+ dbg("seek buffer too small %d\n", SEEK_BUFFER_SIZE);
return NULL;
}
if (id->seekbuf == NULL) {
id->seekbuf = malloc(SEEK_BUFFER_SIZE);
if (id->seekbuf == NULL) {
- dbg("error malloc");
+ dbg("error malloc\n");
return NULL;
}
}
/* check if we need to read */
if ((off < id->seekbuf_off) || ((off + len) > (id->seekbuf_off + id->seekbuf_len))) {
- info("read seekbuf off:0x%llx len:0x%zx", (unsigned long long) off, len);
+ info("read seekbuf off:0x%llx len:0x%zx\n", (unsigned long long) off, len);
if (lseek(id->fd, off, SEEK_SET) < 0) {
- dbg("lseek failed (%s)", strerror(errno));
+ dbg("lseek failed (%s)\n", strerror(errno));
return NULL;
}
buf_len = read(id->fd, id->seekbuf, len);
if (buf_len < 0) {
- dbg("read failed (%s)", strerror(errno));
+ dbg("read failed (%s)\n", strerror(errno));
return NULL;
}
- dbg("got 0x%zx (%zi) bytes", buf_len, buf_len);
+ dbg("got 0x%zx (%zi) bytes\n", buf_len, buf_len);
id->seekbuf_off = off;
id->seekbuf_len = buf_len;
if ((size_t)buf_len < len) {
- dbg("requested 0x%zx bytes, got only 0x%zx bytes", len, buf_len);
+ dbg("requested 0x%zx bytes, got only 0x%zx bytes\n", len, buf_len);
return NULL;
}
}
uint64_t meta_off;
struct via_meta *via;
- dbg("probing at offset 0x%llx, size 0x%llx",
+ dbg("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
if (size < 0x10000)
if (!device_is_readable(id, off))
return -1;
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
for (i = 0; i < ARRAY_SIZE(prober_raid); i++)
if (!device_is_readable(id, off))
return -1;
- info("probing at offset 0x%llx, size 0x%llx",
+ info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
for (i = 0; i < ARRAY_SIZE(prober_filesystem); i++)
fd = open(path, O_RDONLY);
if (fd < 0) {
- dbg("unable to open '%s'", path);
+ dbg("unable to open '%s'\n", path);
return NULL;
}
{
struct vxfs_super *vxs;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
vxs = (struct vxfs_super *) volume_id_get_buffer(id, off + 0x200, 0x200);
if (vxs == NULL)
{
struct xfs_super_block *xs;
- info("probing at offset 0x%llx", (unsigned long long) off);
+ info("probing at offset 0x%llx\n", (unsigned long long) off);
xs = (struct xfs_super_block *) volume_id_get_buffer(id, off, 0x200);
if (xs == NULL)
node = argv[optind];
if (!node) {
- err("no device");
+ err("no device\n");
fprintf(stderr, "no device\n");
rc = 1;
goto exit;
if (ioctl(fd, BLKGETSIZE64, &size) != 0)
size = 0;
- dbg("BLKGETSIZE64=%llu", (unsigned long long)size);
+ dbg("BLKGETSIZE64=%llu\n", (unsigned long long)size);
/* try to drop all privileges before reading disk content */
if (getuid() == 0) {
if (setgroups(0, NULL) != 0 ||
setgid(pw->pw_gid) != 0 ||
setuid(pw->pw_uid) != 0)
- info("unable to drop privileges: %s\n", strerror(errno));
+ info("unable to drop privileges: %s\n\n", strerror(errno));
}
}
logging_init("udev");
if (devnull < 0)
- err("open /dev/null failed: %s", strerror(errno));
+ err("open /dev/null failed: %s\n", strerror(errno));
udev_config_init();
selinux_init();
- dbg("version %s", UDEV_VERSION);
+ dbg("version %s\n", UDEV_VERSION);
/* set signal handlers */
memset(&act, 0x00, sizeof(act));
subsystem = argv[1];
if (action == NULL || subsystem == NULL || devpath == NULL) {
- err("action, subsystem or devpath missing");
+ err("action, subsystem or devpath missing\n");
goto exit;
}
dev = sysfs_device_get(devpath);
if (dev == NULL) {
- info("unable to open '%s'", devpath);
+ info("unable to open '%s'\n", devpath);
goto fail;
}
int retval = 0;
if (file_map(udev_config_filename, &buf, &bufsize) != 0) {
- err("can't open '%s' as config file: %s", udev_config_filename, strerror(errno));
+ err("can't open '%s' as config file: %s\n", udev_config_filename, strerror(errno));
return -ENODEV;
}
continue;
if (count >= sizeof(line)) {
- err("line too long, conf line skipped %s, line %d", udev_config_filename, lineno);
+ err("line too long, conf line skipped %s, line %d\n", udev_config_filename, lineno);
continue;
}
linepos = line;
retval = get_key(&linepos, &variable, &value);
if (retval != 0) {
- err("error parsing %s, line %d:%d", udev_config_filename, lineno, (int)(linepos-line));
+ err("error parsing %s, line %d:%d\n", udev_config_filename, lineno, (int)(linepos-line));
continue;
}
if (env)
udev_log_priority = log_priority(env);
- dbg("UDEV_CONFIG_FILE='%s'", udev_config_filename);
- dbg("udev_root='%s'", udev_root);
- dbg("udev_rules='%s'", udev_rules_dir);
- dbg("udev_log=%d", udev_log_priority);
+ dbg("UDEV_CONFIG_FILE='%s'\n", udev_config_filename);
+ dbg("udev_root='%s'\n", udev_root);
+ dbg("udev_rules='%s'\n", udev_rules_dir);
+ dbg("udev_log=%d\n", udev_log_priority);
}
strlcat(filename, device, sizeof(filename));
if (add) {
- info("creating index: '%s'", filename);
+ info("creating index: '%s'\n", filename);
create_path(filename);
fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644);
if (fd > 0)
close(fd);
} else {
- info("removing index: '%s'", filename);
+ info("removing index: '%s'\n", filename);
unlink(filename);
delete_path(filename);
}
dir = opendir(dirname);
if (dir == NULL) {
- info("no index directory '%s': %s", dirname, strerror(errno));
+ info("no index directory '%s': %s\n", dirname, strerror(errno));
rc = -1;
goto out;
}
- info("found index directory '%s'", dirname);
+ info("found index directory '%s'\n", dirname);
while (1) {
struct dirent *ent;
char device[PATH_SIZE];
if (list_empty(&udev->symlink_list) && list_empty(&udev->env_list) &&
!udev->partitions && !udev->ignore_remove) {
int ret;
- dbg("nothing interesting to store, create symlink");
+ dbg("nothing interesting to store, create symlink\n");
selinux_setfscreatecon(filename, NULL, S_IFLNK);
ret = symlink(udev->name, filename);
selinux_resetfscreatecon();
if (ret != 0) {
- err("unable to create db link '%s': %s", filename, strerror(errno));
+ err("unable to create db link '%s': %s\n", filename, strerror(errno));
return -1;
}
} else {
f = fopen(filename, "w");
if (f == NULL) {
- err("unable to create db file '%s': %s", filename, strerror(errno));
+ err("unable to create db file '%s': %s\n", filename, strerror(errno));
return -1;
}
- dbg("storing data for device '%s' in '%s'", udev->dev->devpath, filename);
+ dbg("storing data for device '%s' in '%s'\n", udev->dev->devpath, filename);
fprintf(f, "N:%s\n", udev->name);
list_for_each_entry(name_loop, &udev->symlink_list, node) {
devpath_to_db_path(devpath, filename, sizeof(filename));
if (lstat(filename, &stats) != 0) {
- info("no db file to read %s: %s", filename, strerror(errno));
+ info("no db file to read %s: %s\n", filename, strerror(errno));
return -1;
}
if ((stats.st_mode & S_IFMT) == S_IFLNK) {
char target[NAME_SIZE];
int target_len;
- info("found a symlink as db file");
+ info("found a symlink as db file\n");
target_len = readlink(filename, target, sizeof(target));
if (target_len > 0)
target[target_len] = '\0';
else {
- info("error reading db link %s: %s", filename, strerror(errno));
+ info("error reading db link %s: %s\n", filename, strerror(errno));
return -1;
}
- dbg("db link points to '%s'", target);
+ dbg("db link points to '%s'\n", target);
strlcpy(udev->name, target, sizeof(udev->name));
return 0;
}
if (file_map(filename, &buf, &bufsize) != 0) {
- info("error reading db file %s: %s", filename, strerror(errno));
+ info("error reading db file %s: %s\n", filename, strerror(errno));
return -1;
}
strlcat(dbpath, "/"DB_DIR, sizeof(dbpath));
dir = opendir(dbpath);
if (dir == NULL) {
- info("no udev_db available '%s': %s", dbpath, strerror(errno));
+ info("no udev_db available '%s': %s\n", dbpath, strerror(errno));
return -1;
}
strlcpy(device, ent->d_name, sizeof(device));
path_decode(device);
name_list_add(name_list, device, 1);
- dbg("added '%s'", device);
+ dbg("added '%s'\n", device);
}
closedir(dir);
struct ifreq ifr;
int retval;
- info("changing net interface name from '%s' to '%s'", udev->dev->kernel, udev->name);
+ info("changing net interface name from '%s' to '%s'\n", udev->dev->kernel, udev->name);
if (udev->test_run)
return 0;
sk = socket(PF_INET, SOCK_DGRAM, 0);
if (sk < 0) {
- err("error opening socket: %s", strerror(errno));
+ err("error opening socket: %s\n", strerror(errno));
return -1;
}
/* see if the destination interface name already exists */
if (errno != EEXIST) {
- err("error changing netif name %s to %s: %s", ifr.ifr_name, ifr.ifr_newname, strerror(errno));
+ err("error changing netif name %s to %s: %s\n", ifr.ifr_name, ifr.ifr_newname, strerror(errno));
goto exit;
}
strlcat(ifr.ifr_newname, "_rename", IFNAMSIZ);
retval = ioctl(sk, SIOCSIFNAME, &ifr);
if (retval != 0) {
- err("error changing netif name %s to %s: %s", ifr.ifr_name, ifr.ifr_newname, strerror(errno));
+ err("error changing netif name %s to %s: %s\n", ifr.ifr_name, ifr.ifr_newname, strerror(errno));
goto exit;
}
}
if (errno != EEXIST) {
- err("error changing net interface name %s to %s: %s",
+ err("error changing net interface name %s to %s: %s\n",
ifr.ifr_name, ifr.ifr_newname, strerror(errno));
break;
}
- dbg("wait for netif '%s' to become free, loop=%i", udev->name, (30 * 20) - loop);
+ dbg("wait for netif '%s' to become free, loop=%i\n", udev->name, (30 * 20) - loop);
usleep(1000 * 1000 / 20);
}
}
if (udev->devpath_old != NULL)
if (udev_db_rename(udev->devpath_old, udev->dev->devpath) == 0)
- info("moved database from '%s' to '%s'", udev->devpath_old, udev->dev->devpath);
+ info("moved database from '%s' to '%s'\n", udev->devpath_old, udev->dev->devpath);
/* add device node */
if (major(udev->devt) != 0 &&
(strcmp(udev->action, "add") == 0 || strcmp(udev->action, "change") == 0)) {
struct udevice *udev_old;
- dbg("device node add '%s'", udev->dev->devpath);
+ dbg("device node add '%s'\n", udev->dev->devpath);
udev_rules_get_name(rules, udev);
if (udev->ignore_device) {
- info("device event will be ignored");
+ info("device event will be ignored\n");
goto exit;
}
if (udev->name[0] == '\0') {
- info("device node creation supressed");
+ info("device node creation supressed\n");
goto exit;
}
if (udev_old != NULL) {
udev_old->test_run = udev->test_run;
if (udev_db_get_device(udev_old, udev->dev->devpath) == 0) {
- info("device '%s' already in database, cleanup", udev->dev->devpath);
+ info("device '%s' already in database, cleanup\n", udev->dev->devpath);
udev_db_delete_device(udev_old);
} else {
udev_device_cleanup(udev_old);
/* add netif */
if (strcmp(udev->dev->subsystem, "net") == 0 && strcmp(udev->action, "add") == 0) {
- dbg("netif add '%s'", udev->dev->devpath);
+ dbg("netif add '%s'\n", udev->dev->devpath);
udev_rules_get_name(rules, udev);
if (udev->ignore_device) {
- info("device event will be ignored");
+ info("device event will be ignored\n");
goto exit;
}
if (udev->name[0] == '\0') {
- info("device renaming supressed");
+ info("device renaming supressed\n");
goto exit;
}
retval = rename_netif(udev);
if (retval != 0)
goto exit;
- info("renamed netif to '%s'", udev->name);
+ info("renamed netif to '%s'\n", udev->name);
/* export old name */
setenv("INTERFACE_OLD", udev->dev->kernel, 1);
sysfs_device_set_values(udev->dev, devpath, NULL, NULL);
setenv("DEVPATH", udev->dev->devpath, 1);
setenv("INTERFACE", udev->name, 1);
- info("changed devpath to '%s'", udev->dev->devpath);
+ info("changed devpath to '%s'\n", udev->dev->devpath);
}
}
goto exit;
list_for_each_entry(name_loop, &udev->env_list, node)
putenv(name_loop->name);
} else {
- dbg("'%s' not found in database, using kernel name '%s'",
+ dbg("'%s' not found in database, using kernel name '%s'\n",
udev->dev->devpath, udev->dev->kernel);
strlcpy(udev->name, udev->dev->kernel, sizeof(udev->name));
}
udev_rules_get_run(rules, udev);
if (udev->ignore_device) {
- info("device event will be ignored");
+ info("device event will be ignored\n");
goto exit;
}
if (udev->ignore_remove) {
- info("ignore_remove for '%s'", udev->name);
+ info("ignore_remove for '%s'\n", udev->name);
goto exit;
}
/* remove the node */
/* default devices */
udev_rules_get_run(rules, udev);
if (udev->ignore_device)
- info("device event will be ignored");
+ info("device event will be ignored\n");
exit:
return retval;
if (lstat(file, &stats) == 0) {
if ((stats.st_mode & S_IFMT) == (mode & S_IFMT) && (stats.st_rdev == devt)) {
- info("preserve file '%s', because it has correct dev_t", file);
+ info("preserve file '%s', because it has correct dev_t\n", file);
selinux_setfilecon(file, udev->dev->kernel, stats.st_mode);
goto perms;
}
goto perms;
}
- info("atomically replace '%s'", file);
+ info("atomically replace '%s'\n", file);
strlcpy(file_tmp, file, sizeof(file_tmp));
strlcat(file_tmp, TMP_FILE_EXT, sizeof(file_tmp));
unlink(file_tmp);
retval = mknod(file_tmp, mode, devt);
selinux_resetfscreatecon();
if (retval != 0) {
- err("mknod(%s, %#o, %u, %u) failed: %s",
+ err("mknod(%s, %#o, %u, %u) failed: %s\n",
file_tmp, mode, major(devt), minor(devt), strerror(errno));
goto exit;
}
retval = rename(file_tmp, file);
if (retval != 0) {
- err("rename(%s, %s) failed: %s",
+ err("rename(%s, %s) failed: %s\n",
file_tmp, file, strerror(errno));
unlink(file_tmp);
goto exit;
}
perms:
- dbg("chmod(%s, %#o)", file, mode);
+ dbg("chmod(%s, %#o)\n", file, mode);
if (chmod(file, mode) != 0) {
- err("chmod(%s, %#o) failed: %s", file, mode, strerror(errno));
+ err("chmod(%s, %#o) failed: %s\n", file, mode, strerror(errno));
goto exit;
}
if (uid != 0 || gid != 0) {
- dbg("chown(%s, %u, %u)", file, uid, gid);
+ dbg("chown(%s, %u, %u)\n", file, uid, gid);
if (chown(file, uid, gid) != 0) {
- err("chown(%s, %u, %u) failed: %s",
+ err("chown(%s, %u, %u) failed: %s\n",
file, uid, gid, strerror(errno));
goto exit;
}
if (S_ISBLK(stats.st_mode) || S_ISCHR(stats.st_mode)) {
struct stat stats2;
- info("found existing node instead of symlink '%s'", slink);
+ info("found existing node instead of symlink '%s'\n", slink);
if (lstat(node, &stats2) == 0) {
if ((stats.st_mode & S_IFMT) == (stats2.st_mode & S_IFMT) &&
stats.st_rdev == stats2.st_rdev) {
- info("replace device node '%s' with symlink to our node '%s'", slink, node);
+ info("replace device node '%s' with symlink to our node '%s'\n", slink, node);
} else {
- err("device node '%s' already exists, link to '%s' will not overwrite it", slink, node);
+ err("device node '%s' already exists, link to '%s' will not overwrite it\n", slink, node);
goto exit;
}
}
} else if (S_ISLNK(stats.st_mode)) {
char buf[PATH_SIZE];
- info("found existing symlink '%s'", slink);
+ info("found existing symlink '%s'\n", slink);
len = readlink(slink, buf, sizeof(buf));
if (len > 0) {
buf[len] = '\0';
if (strcmp(target, buf) == 0) {
- info("preserve already existing symlink '%s' to '%s'", slink, target);
+ info("preserve already existing symlink '%s' to '%s'\n", slink, target);
selinux_setfilecon(slink, NULL, S_IFLNK);
goto exit;
}
}
}
} else {
- info("creating symlink '%s' to '%s'", slink, target);
+ info("creating symlink '%s' to '%s'\n", slink, target);
selinux_setfscreatecon(slink, NULL, S_IFLNK);
retval = symlink(target, slink);
selinux_resetfscreatecon();
goto exit;
}
- info("atomically replace '%s'", slink);
+ info("atomically replace '%s'\n", slink);
strlcpy(slink_tmp, slink, sizeof(slink_tmp));
strlcat(slink_tmp, TMP_FILE_EXT, sizeof(slink_tmp));
unlink(slink_tmp);
retval = symlink(target, slink_tmp);
selinux_resetfscreatecon();
if (retval != 0) {
- err("symlink(%s, %s) failed: %s", target, slink_tmp, strerror(errno));
+ err("symlink(%s, %s) failed: %s\n", target, slink_tmp, strerror(errno));
goto exit;
}
retval = rename(slink_tmp, slink);
if (retval != 0) {
- err("rename(%s, %s) failed: %s", slink_tmp, slink, strerror(errno));
+ err("rename(%s, %s) failed: %s\n", slink_tmp, slink, strerror(errno));
unlink(slink_tmp);
goto exit;
}
strlcat(slink, name, sizeof(slink));
count = udev_db_get_devices_by_name(name, &name_list);
- info("found %i devices with name '%s'", count, name);
+ info("found %i devices with name '%s'\n", count, name);
/* if we don't have a reference, delete it */
if (count <= 0) {
- info("no reference left, remove '%s'", name);
+ info("no reference left, remove '%s'\n", name);
if (!udev->test_run) {
unlink(slink);
delete_path(slink);
/* find the device with the highest priority */
list_for_each_entry(device, &name_list, node) {
- info("found '%s' for '%s'", device->name, name);
+ info("found '%s' for '%s'\n", device->name, name);
/* did we find ourself? we win, if we have the same priority */
if (strcmp(udev->dev->devpath, device->name) == 0) {
- info("compare (our own) priority of '%s' %i >= %i",
+ info("compare (our own) priority of '%s' %i >= %i\n",
udev->dev->devpath, udev->link_priority, priority);
if (strcmp(udev->name, name) == 0) {
- info("'%s' is our device node, database inconsistent, skip link update", udev->name);
+ info("'%s' is our device node, database inconsistent, skip link update\n", udev->name);
} else if (target[0] == '\0' || udev->link_priority >= priority) {
priority = udev->link_priority;
strlcpy(target, udev->name, sizeof(target));
continue;
if (udev_db_get_device(udev_db, device->name) == 0) {
if (strcmp(udev_db->name, name) == 0) {
- info("'%s' is a device node of '%s', skip link update", udev_db->name, device->name);
+ info("'%s' is a device node of '%s', skip link update\n", udev_db->name, device->name);
} else {
- info("compare priority of '%s' %i > %i",
+ info("compare priority of '%s' %i > %i\n",
udev_db->dev->devpath, udev_db->link_priority, priority);
if (target[0] == '\0' || udev_db->link_priority > priority) {
priority = udev_db->link_priority;
name_list_cleanup(&name_list);
if (target[0] == '\0') {
- info("no current target for '%s' found", name);
+ info("no current target for '%s' found\n", name);
rc = 1;
goto out;
}
strlcpy(node, udev_root, sizeof(node));
strlcat(node, "/", sizeof(node));
strlcat(node, target, sizeof(node));
- info("'%s' with target '%s' has the highest priority %i, create it", name, target, priority);
+ info("'%s' with target '%s' has the highest priority %i, create it\n", name, target, priority);
if (!udev->test_run) {
create_path(slink);
node_symlink(node, slink);
char symlinks[PATH_SIZE] = "";
list_for_each_entry(name_loop, &udev->symlink_list, node) {
- info("update symlink '%s' of '%s'", name_loop->name, udev->dev->devpath);
+ info("update symlink '%s' of '%s'\n", name_loop->name, udev->dev->devpath);
update_link(udev, name_loop->name);
strlcat(symlinks, udev_root, sizeof(symlinks));
strlcat(symlinks, "/", sizeof(symlinks));
}
if (!found) {
/* link does no longer belong to this device */
- info("update old symlink '%s' no longer belonging to '%s'",
+ info("update old symlink '%s' no longer belonging to '%s'\n",
link_old_loop->name, udev->dev->devpath);
update_link(udev, link_old_loop->name);
}
gid = lookup_group(udev->group);
}
- info("creating device node '%s', major=%d, minor=%d, mode=%#o, uid=%d, gid=%d",
+ info("creating device node '%s', major=%d, minor=%d, mode=%#o, uid=%d, gid=%d\n",
filename, major(udev->devt), minor(udev->devt), udev->mode, uid, gid);
if (!udev->test_run)
if (range > 1)
udev->partitions = range-1;
}
- info("creating device partition nodes '%s[1-%i]'", filename, udev->partitions);
+ info("creating device partition nodes '%s[1-%i]'\n", filename, udev->partitions);
if (!udev->test_run) {
for (i = 1; i <= udev->partitions; i++) {
dev_t part_devt;
strlcat(filename, "/", sizeof(filename));
strlcat(filename, udev->name, sizeof(filename));
if (stat(filename, &stats) != 0) {
- info("device node '%s' not found", filename);
+ info("device node '%s' not found\n", filename);
return 0;
}
if (udev->devt && stats.st_rdev != udev->devt) {
- info("device node '%s' points to a different device, skip removal", filename);
+ info("device node '%s' points to a different device, skip removal\n", filename);
return -1;
}
- info("removing device node '%s'", filename);
+ info("removing device node '%s'\n", filename);
if (!udev->test_run)
retval = unlink_secure(filename);
if (retval)
if (num > 0) {
int i;
- info("removing all_partitions '%s[1-%i]'", filename, num);
+ info("removing all_partitions '%s[1-%i]'\n", filename, num);
if (num > 255)
return -1;
for (i = 1; i <= num; i++) {
if (*str[0] == '{') {
pos = strchr(*str, '}');
if (pos == NULL) {
- err("missing closing brace for format");
+ err("missing closing brace for format\n");
return NULL;
}
pos[0] = '\0';
attr = *str+1;
*str = pos+1;
- dbg("attribute='%s', str='%s'", attr, *str);
+ dbg("attribute='%s', str='%s'\n", attr, *str);
}
return attr;
}
num = (int) strtoul(*str, &tail, 10);
if (num > 0) {
*str = tail;
- dbg("format length=%i", num);
+ dbg("format length=%i\n", num);
return num;
} else {
- err("format parsing error '%s'", *str);
+ err("format parsing error '%s'\n", *str);
}
}
return -1;
} else {
argv[i] = strsep(&pos, " ");
}
- dbg("arg[%i] '%s'", i, argv[i]);
+ dbg("arg[%i] '%s'\n", i, argv[i]);
i++;
}
argv[i] = NULL;
argv[0] = arg;
argv[1] = NULL;
}
- info("'%s'", command);
+ info("'%s'\n", command);
/* prepare pipes from child to parent */
if (result != NULL || udev_log_priority >= LOG_INFO) {
if (pipe(outpipe) != 0) {
- err("pipe failed: %s", strerror(errno));
+ err("pipe failed: %s\n", strerror(errno));
return -1;
}
}
if (udev_log_priority >= LOG_INFO) {
if (pipe(errpipe) != 0) {
- err("pipe failed: %s", strerror(errno));
+ err("pipe failed: %s\n", strerror(errno));
return -1;
}
}
dup2(devnull, STDERR_FILENO);
close(devnull);
} else
- err("open /dev/null failed: %s", strerror(errno));
+ err("open /dev/null failed: %s\n", strerror(errno));
if (outpipe[WRITE_END] > 0) {
dup2(outpipe[WRITE_END], STDOUT_FILENO);
close(outpipe[WRITE_END]);
execv(argv[0], argv);
if (errno == ENOENT || errno == ENOTDIR) {
/* may be on a filesytem which is not mounted right now */
- info("program '%s' not found", argv[0]);
+ info("program '%s' not found\n", argv[0]);
} else {
/* other problems */
- err("exec of program '%s' failed", argv[0]);
+ err("exec of program '%s' failed\n", argv[0]);
}
_exit(1);
case -1:
- err("fork of '%s' failed: %s", argv[0], strerror(errno));
+ err("fork of '%s' failed: %s\n", argv[0], strerror(errno));
return -1;
default:
/* read from child if requested */
close(outpipe[READ_END]);
outpipe[READ_END] = -1;
if (count < 0) {
- err("stdin read failed: %s", strerror(errno));
+ err("stdin read failed: %s\n", strerror(errno));
retval = -1;
}
continue;
memcpy(&result[respos], inbuf, count);
respos += count;
} else {
- err("ressize %ld too short", (long)ressize);
+ err("ressize %ld too short\n", (long)ressize);
retval = -1;
}
}
pos = inbuf;
while ((line = strsep(&pos, "\n")))
if (pos || line[0] != '\0')
- info("'%s' (stdout) '%s'", argv[0], line);
+ info("'%s' (stdout) '%s'\n", argv[0], line);
}
/* get stderr */
close(errpipe[READ_END]);
errpipe[READ_END] = -1;
if (count < 0)
- err("stderr read failed: %s", strerror(errno));
+ err("stderr read failed: %s\n", strerror(errno));
continue;
}
errbuf[count] = '\0';
pos = errbuf;
while ((line = strsep(&pos, "\n")))
if (pos || line[0] != '\0')
- info("'%s' (stderr) '%s'", argv[0], line);
+ info("'%s' (stderr) '%s'\n", argv[0], line);
}
}
if (outpipe[READ_END] > 0)
/* return the childs stdout string */
if (result) {
result[respos] = '\0';
- dbg("result='%s'", result);
+ dbg("result='%s'\n", result);
if (reslen)
*reslen = respos;
}
}
waitpid(pid, &status, 0);
if (WIFEXITED(status)) {
- info("'%s' returned with status %i", argv[0], WEXITSTATUS(status));
+ info("'%s' returned with status %i\n", argv[0], WEXITSTATUS(status));
if (WEXITSTATUS(status) != 0)
retval = -1;
} else {
- err("'%s' abnormal exit", argv[0]);
+ err("'%s' abnormal exit\n", argv[0]);
retval = -1;
}
}
continue;
if (count >= sizeof(line)) {
- err("line too long, conf line skipped %s, line %d", udev_config_filename, lineno);
+ err("line too long, conf line skipped %s, line %d\n", udev_config_filename, lineno);
continue;
}
linepos = line;
if (get_key(&linepos, &variable, &value) == 0) {
- dbg("import '%s=%s'", variable, value);
+ dbg("import '%s=%s'\n", variable, value);
/* handle device, renamed by external tool, returning new path */
if (strcmp(variable, "DEVPATH") == 0) {
- info("updating devpath from '%s' to '%s'", udev->dev->devpath, value);
+ info("updating devpath from '%s' to '%s'\n", udev->dev->devpath, value);
sysfs_device_set_values(udev->dev, value, NULL, NULL);
} else
name_list_key_add(&udev->env_list, variable, value);
size_t bufsize;
if (file_map(filename, &buf, &bufsize) != 0) {
- err("can't open '%s': %s", filename, strerror(errno));
+ err("can't open '%s': %s\n", filename, strerror(errno));
return -1;
}
import_keys_into_env(udev, buf, bufsize);
struct udevice *udev_parent;
struct name_entry *name_loop;
- dbg("found parent '%s', get the node name", dev_parent->devpath);
+ dbg("found parent '%s', get the node name\n", dev_parent->devpath);
udev_parent = udev_device_init(NULL);
if (udev_parent == NULL)
return -1;
/* import the udev_db of the parent */
if (udev_db_get_device(udev_parent, dev_parent->devpath) == 0) {
- dbg("import stored parent env '%s'", udev_parent->name);
+ dbg("import stored parent env '%s'\n", udev_parent->name);
list_for_each_entry(name_loop, &udev_parent->env_list, node) {
char name[NAME_SIZE];
char *pos;
pos[0] = '\0';
pos++;
if (fnmatch(filter, name, 0) == 0) {
- dbg("import key '%s'", name_loop->name);
+ dbg("import key '%s'\n", name_loop->name);
name_list_add(&udev->env_list, name_loop->name, 0);
setenv(name, pos, 1);
} else
- dbg("skip key '%s'", name_loop->name);
+ dbg("skip key '%s'\n", name_loop->name);
}
}
rc = 0;
} else
- dbg("parent not found in database");
+ dbg("parent not found in database\n");
udev_device_cleanup(udev_parent);
}
ssize_t count;
int retval = 0;
- dbg("pass environment to socket '%s'", sockpath);
+ dbg("pass environment to socket '%s'\n", sockpath);
sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
memset(&saddr, 0x00, sizeof(struct sockaddr_un));
saddr.sun_family = AF_LOCAL;
count = sendto(sock, &buf, bufpos, 0, (struct sockaddr *)&saddr, saddrlen);
if (count < 0)
retval = -1;
- info("passed %zi bytes to socket '%s', ", count, sockpath);
+ info("passed %zi bytes to socket '%s', \n", count, sockpath);
close(sock);
return retval;
struct name_entry *name_loop;
int retval = 0;
- dbg("executing run list");
+ dbg("executing run list\n");
list_for_each_entry(name_loop, &udev->run_list, node) {
if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0) {
pass_env_to_socket(&name_loop->name[strlen("socket:")], udev->dev->devpath, udev->action);
strlcat(filepath, "/", sizeof(filepath));
strlcat(filepath, file, sizeof(filepath));
- dbg("will wait %i sec for '%s'", timeout, filepath);
+ dbg("will wait %i sec for '%s'\n", timeout, filepath);
while (--loop) {
/* lookup file */
if (stat(filepath, &stats) == 0) {
- info("file '%s' appeared after %i loops", filepath, (timeout * WAIT_LOOP_PER_SECOND) - loop-1);
+ info("file '%s' appeared after %i loops\n", filepath, (timeout * WAIT_LOOP_PER_SECOND) - loop-1);
return 0;
}
/* make sure, the device did not disappear in the meantime */
if (stat(devicepath, &stats) != 0) {
- info("device disappeared while waiting for '%s'", filepath);
+ info("device disappeared while waiting for '%s'\n", filepath);
return -2;
}
- info("wait for '%s' for %i mseconds", filepath, 1000 / WAIT_LOOP_PER_SECOND);
+ info("wait for '%s' for %i mseconds\n", filepath, 1000 / WAIT_LOOP_PER_SECOND);
usleep(1000 * 1000 / WAIT_LOOP_PER_SECOND);
}
- info("waiting for '%s' failed", filepath);
+ info("waiting for '%s' failed\n", filepath);
return -1;
}
if (strncasecmp(&head[1], subst->name, strlen(subst->name)) == 0) {
type = subst->type;
tail = head + strlen(subst->name)+1;
- dbg("will substitute format name '%s'", subst->name);
+ dbg("will substitute format name '%s'\n", subst->name);
goto found;
}
}
head[0] = '$';
- err("unknown format variable '%s'", head);
+ err("unknown format variable '%s'\n", head);
} else if (head[0] == '%') {
/* substitute format char */
if (head[1] == '\0')
if (tail[0] == subst->fmt) {
type = subst->type;
tail++;
- dbg("will substitute format char '%c'", subst->fmt);
+ dbg("will substitute format char '%c'\n", subst->fmt);
goto found;
}
}
head[0] = '%';
- err("unknown format char '%c'", tail[0]);
+ err("unknown format char '%c'\n", tail[0]);
}
head++;
}
found:
attr = get_format_attribute(&tail);
strlcpy(temp, tail, sizeof(temp));
- dbg("format=%i, string='%s', tail='%s'", type ,string, tail);
+ dbg("format=%i, string='%s', tail='%s'\n", type ,string, tail);
switch (type) {
case SUBST_DEVPATH:
strlcat(string, udev->dev->devpath, maxsize);
- dbg("substitute devpath '%s'", udev->dev->devpath);
+ dbg("substitute devpath '%s'\n", udev->dev->devpath);
break;
case SUBST_KERNEL:
strlcat(string, udev->dev->kernel, maxsize);
- dbg("substitute kernel name '%s'", udev->dev->kernel);
+ dbg("substitute kernel name '%s'\n", udev->dev->kernel);
break;
case SUBST_KERNEL_NUMBER:
strlcat(string, udev->dev->kernel_number, maxsize);
- dbg("substitute kernel number '%s'", udev->dev->kernel_number);
+ dbg("substitute kernel number '%s'\n", udev->dev->kernel_number);
break;
case SUBST_ID:
if (udev->dev_parent != NULL) {
strlcat(string, udev->dev_parent->kernel, maxsize);
- dbg("substitute id '%s'", udev->dev_parent->kernel);
+ dbg("substitute id '%s'\n", udev->dev_parent->kernel);
}
break;
case SUBST_DRIVER:
if (udev->dev_parent != NULL) {
strlcat(string, udev->dev_parent->driver, maxsize);
- dbg("substitute driver '%s'", udev->dev_parent->driver);
+ dbg("substitute driver '%s'\n", udev->dev_parent->driver);
}
break;
case SUBST_MAJOR:
sprintf(temp2, "%d", major(udev->devt));
strlcat(string, temp2, maxsize);
- dbg("substitute major number '%s'", temp2);
+ dbg("substitute major number '%s'\n", temp2);
break;
case SUBST_MINOR:
sprintf(temp2, "%d", minor(udev->devt));
strlcat(string, temp2, maxsize);
- dbg("substitute minor number '%s'", temp2);
+ dbg("substitute minor number '%s'\n", temp2);
break;
case SUBST_RESULT:
if (udev->program_result[0] == '\0')
if (attr != NULL)
i = strtoul(attr, &rest, 10);
if (i > 0) {
- dbg("request part #%d of result string", i);
+ dbg("request part #%d of result string\n", i);
cpos = udev->program_result;
while (--i) {
while (cpos[0] != '\0' && !isspace(cpos[0]))
cpos++;
}
if (i > 0) {
- err("requested part of result string not found");
+ err("requested part of result string not found\n");
break;
}
strlcpy(temp2, cpos, sizeof(temp2));
cpos[0] = '\0';
}
strlcat(string, temp2, maxsize);
- dbg("substitute part of result string '%s'", temp2);
+ dbg("substitute part of result string '%s'\n", temp2);
} else {
strlcat(string, udev->program_result, maxsize);
- dbg("substitute result string '%s'", udev->program_result);
+ dbg("substitute result string '%s'\n", udev->program_result);
}
break;
case SUBST_ATTR:
if (attr == NULL)
- err("missing file parameter for attr");
+ err("missing file parameter for attr\n");
else {
char devpath[PATH_SIZE];
char *attrib;
struct sysfs_device *dev_parent = udev->dev;
do {
- dbg("looking at '%s'", dev_parent->devpath);
+ dbg("looking at '%s'\n", dev_parent->devpath);
value = sysfs_attr_get_value(dev_parent->devpath, attr);
if (value != NULL) {
strlcpy(temp2, value, sizeof(temp2));
temp2[--size] = '\0';
count = replace_chars(temp2, ALLOWED_CHARS_INPUT);
if (count > 0)
- info("%i character(s) replaced" , count);
+ info("%i character(s) replaced\n" , count);
strlcat(string, temp2, maxsize);
- dbg("substitute sysfs value '%s'", temp2);
+ dbg("substitute sysfs value '%s'\n", temp2);
}
break;
case SUBST_PARENT:
if (dev_parent != NULL) {
struct udevice *udev_parent;
- dbg("found parent '%s', get the node name", dev_parent->devpath);
+ dbg("found parent '%s', get the node name\n", dev_parent->devpath);
udev_parent = udev_device_init(NULL);
if (udev_parent != NULL) {
/* lookup the name in the udev_db with the DEVPATH of the parent */
if (udev_db_get_device(udev_parent, dev_parent->devpath) == 0) {
strlcat(string, udev_parent->name, maxsize);
- dbg("substitute parent node name'%s'", udev_parent->name);
+ dbg("substitute parent node name'%s'\n", udev_parent->name);
} else
- dbg("parent not found in database");
+ dbg("parent not found in database\n");
udev_device_cleanup(udev_parent);
}
}
break;
case SUBST_TEMP_NODE:
if (udev->tmp_node[0] == '\0' && major(udev->devt) > 0) {
- dbg("create temporary device node for callout");
+ dbg("create temporary device node for callout\n");
snprintf(udev->tmp_node, sizeof(udev->tmp_node), "%s/.tmp-%u-%u",
udev_root, major(udev->devt), minor(udev->devt));
udev->tmp_node[sizeof(udev->tmp_node)-1] = '\0';
udev_node_mknod(udev, udev->tmp_node, udev->devt, 0600, 0, 0);
}
strlcat(string, udev->tmp_node, maxsize);
- dbg("substitute temporary device node name '%s'", udev->tmp_node);
+ dbg("substitute temporary device node name '%s'\n", udev->tmp_node);
break;
case SUBST_NAME:
strlcat(string, udev->name, maxsize);
- dbg("substitute udev->name '%s'", udev->name);
+ dbg("substitute udev->name '%s'\n", udev->name);
break;
case SUBST_ROOT:
strlcat(string, udev_root, maxsize);
- dbg("substitute udev_root '%s'", udev_root);
+ dbg("substitute udev_root '%s'\n", udev_root);
break;
case SUBST_SYS:
strlcat(string, sysfs_path, maxsize);
- dbg("substitute sysfs_path '%s'", sysfs_path);
+ dbg("substitute sysfs_path '%s'\n", sysfs_path);
break;
case SUBST_ENV:
if (attr == NULL) {
- dbg("missing attribute");
+ dbg("missing attribute\n");
break;
}
pos = getenv(attr);
if (pos == NULL) {
- dbg("env '%s' not available", attr);
+ dbg("env '%s' not available\n", attr);
break;
}
- dbg("substitute env '%s=%s'", attr, pos);
+ dbg("substitute env '%s=%s'\n", attr, pos);
strlcat(string, pos, maxsize);
break;
default:
- err("unknown substitution type=%i", type);
+ err("unknown substitution type=%i\n", type);
break;
}
/* possibly truncate to format-char specified length */
if (len >= 0 && len < (int)strlen(head)) {
head[len] = '\0';
- dbg("truncate to %i chars, subtitution string becomes '%s'", len, head);
+ dbg("truncate to %i chars, subtitution string becomes '%s'\n", len, head);
}
strlcat(string, temp, maxsize);
}
/* look for a matching string, parts are separated by '|' */
strlcpy(value, rule->buf + key->val_off, sizeof(value));
key_value = value;
- dbg("key %s value='%s'", key_name, key_value);
+ dbg("key %s value='%s'\n", key_name, key_value);
while (key_value) {
pos = strchr(key_value, '|');
if (pos) {
pos++;
}
- dbg("match %s '%s' <-> '%s'", key_name, key_value, val);
+ dbg("match %s '%s' <-> '%s'\n", key_name, key_value, val);
match = (fnmatch(key_value, val, 0) == 0);
if (match)
break;
}
if (match && (key->operation == KEY_OP_MATCH)) {
- dbg("%s is true (matching value)", key_name);
+ dbg("%s is true (matching value)\n", key_name);
return 0;
}
if (!match && (key->operation == KEY_OP_NOMATCH)) {
- dbg("%s is true (non-matching value)", key_name);
+ dbg("%s is true (non-matching value)\n", key_name);
return 0;
}
return -1;
const char *value = getenv(key_name);
if (!value) {
- dbg("ENV{'%s'} is not set, treat as empty", key_name);
+ dbg("ENV{'%s'} is not set, treat as empty\n", key_name);
value = "";
}
if (match_key("ENV", rule, &pair->key, value))
attr_subst_subdir(filename, sizeof(filename));
match = (stat(filename, &statbuf) == 0);
- info("'%s' %s", filename, match ? "exists" : "does not exist");
+ info("'%s' %s", filename, match ? "exists" : "does not exist\n");
if (match && rule->test_mode_mask > 0) {
match = ((statbuf.st_mode & rule->test_mode_mask) > 0);
- info("'%s' has mode=%#o and %s %#o", filename, statbuf.st_mode,
+ info("'%s' has mode=%#o and %s %#o\n", filename, statbuf.st_mode,
match ? "matches" : "does not match",
rule->test_mode_mask);
}
goto nomatch;
if (!match && rule->test.operation == KEY_OP_MATCH)
goto nomatch;
- dbg("TEST key is true");
+ dbg("TEST key is true\n");
}
if (rule->wait_for_sysfs.operation != KEY_OP_UNSET) {
len = strlen(val);
while (len > 0 && isspace(val[len-1]))
val[--len] = '\0';
- dbg("removed %zi trailing whitespace chars from '%s'", strlen(val)-len, val);
+ dbg("removed %zi trailing whitespace chars from '%s'\n", strlen(val)-len, val);
}
if (match_key("ATTR", rule, &pair->key, val))
len = strlen(val);
while (len > 0 && isspace(val[len-1]))
val[--len] = '\0';
- dbg("removed %zi trailing whitespace chars from '%s'", strlen(val)-len, val);
+ dbg("removed %zi trailing whitespace chars from '%s'\n", strlen(val)-len, val);
}
if (match_key("ATTRS", rule, &pair->key, val))
break;
try_parent:
/* move to parent device */
- dbg("try parent sysfs device");
+ dbg("try parent sysfs device\n");
udev->dev_parent = sysfs_device_get_parent(udev->dev_parent);
if (udev->dev_parent == NULL)
goto nomatch;
- dbg("looking at dev_parent->devpath='%s'", udev->dev_parent->devpath);
- dbg("looking at dev_parent->kernel='%s'", udev->dev_parent->kernel);
+ dbg("looking at dev_parent->devpath='%s'\n", udev->dev_parent->devpath);
+ dbg("looking at dev_parent->kernel='%s'\n", udev->dev_parent->kernel);
}
/* execute external program */
strlcpy(program, key_val(rule, &rule->program), sizeof(program));
udev_rules_apply_format(udev, program, sizeof(program));
if (run_program(program, udev->dev->subsystem, result, sizeof(result), NULL) != 0) {
- dbg("PROGRAM is false");
+ dbg("PROGRAM is false\n");
udev->program_result[0] = '\0';
if (rule->program.operation != KEY_OP_NOMATCH)
goto nomatch;
} else {
int count;
- dbg("PROGRAM matches");
+ dbg("PROGRAM matches\n");
remove_trailing_chars(result, '\n');
if (rule->string_escape == ESCAPE_UNSET ||
rule->string_escape == ESCAPE_REPLACE) {
count = replace_chars(result, ALLOWED_CHARS_INPUT);
if (count > 0)
- info("%i character(s) replaced" , count);
+ info("%i character(s) replaced\n" , count);
}
- dbg("result is '%s'", result);
+ dbg("result is '%s'\n", result);
strlcpy(udev->program_result, result, sizeof(udev->program_result));
- dbg("PROGRAM returned successful");
+ dbg("PROGRAM returned successful\n");
if (rule->program.operation == KEY_OP_NOMATCH)
goto nomatch;
}
- dbg("PROGRAM key is true");
+ dbg("PROGRAM key is true\n");
}
/* check for matching result of external program */
strlcpy(import, key_val(rule, &rule->import), sizeof(import));
udev_rules_apply_format(udev, import, sizeof(import));
- dbg("check for IMPORT import='%s'", import);
+ dbg("check for IMPORT import='%s'\n", import);
if (rule->import_type == IMPORT_PROGRAM) {
rc = import_program_into_env(udev, import);
} else if (rule->import_type == IMPORT_FILE) {
- dbg("import file import='%s'", import);
+ dbg("import file import='%s'\n", import);
rc = import_file_into_env(udev, import);
} else if (rule->import_type == IMPORT_PARENT) {
- dbg("import parent import='%s'", import);
+ dbg("import parent import='%s'\n", import);
rc = import_parent_into_env(udev, import);
}
if (rc != 0) {
- dbg("IMPORT failed");
+ dbg("IMPORT failed\n");
if (rule->import.operation != KEY_OP_NOMATCH)
goto nomatch;
} else
- dbg("IMPORT '%s' imported", key_val(rule, &rule->import));
- dbg("IMPORT key is true");
+ dbg("IMPORT '%s' imported\n", key_val(rule, &rule->import));
+ dbg("IMPORT key is true\n");
}
/* rule matches, if we have ENV assignments export it */
if (temp_value[0] == '\0') {
name_list_key_remove(&udev->env_list, key_name);
unsetenv(key_name);
- info("unset ENV '%s'", key_name);
+ info("unset ENV '%s'\n", key_name);
} else {
struct name_entry *entry;
if (entry == NULL)
break;
putenv(entry->name);
- info("set ENV '%s'", entry->name);
+ info("set ENV '%s'\n", entry->name);
}
}
}
strlcpy(value, key_val(rule, &pair->key), sizeof(value));
udev_rules_apply_format(udev, value, sizeof(value));
- info("writing '%s' to sysfs file '%s'", value, attr);
+ info("writing '%s' to sysfs file '%s'\n", value, attr);
f = fopen(attr, "w");
if (f != NULL) {
if (!udev->test_run)
if (fprintf(f, "%s", value) <= 0)
- err("error writing ATTR{%s}: %s", attr, strerror(errno));
+ err("error writing ATTR{%s}: %s\n", attr, strerror(errno));
fclose(f);
} else
- err("error opening ATTR{%s} for writing: %s", attr, strerror(errno));
+ err("error opening ATTR{%s} for writing: %s\n", attr, strerror(errno));
}
}
return 0;
struct udev_rule *rule;
int name_set = 0;
- dbg("udev->dev->devpath='%s'", udev->dev->devpath);
- dbg("udev->dev->kernel='%s'", udev->dev->kernel);
+ dbg("udev->dev->devpath='%s'\n", udev->dev->devpath);
+ dbg("udev->dev->kernel='%s'\n", udev->dev->kernel);
/* look for a matching rule to apply */
udev_rules_iter_init(rules);
(rule->name.operation == KEY_OP_ASSIGN ||
rule->name.operation == KEY_OP_ASSIGN_FINAL ||
rule->name.operation == KEY_OP_ADD)) {
- dbg("node name already set, rule ignored");
+ dbg("node name already set, rule ignored\n");
continue;
}
- dbg("process rule");
+ dbg("process rule\n");
if (match_rule(udev, rule) == 0) {
/* apply options */
if (rule->ignore_device) {
- info("rule applied, '%s' is ignored", udev->dev->kernel);
+ info("rule applied, '%s' is ignored\n", udev->dev->kernel);
udev->ignore_device = 1;
return 0;
}
if (rule->ignore_remove) {
udev->ignore_remove = 1;
- dbg("remove event should be ignored");
+ dbg("remove event should be ignored\n");
}
if (rule->link_priority != 0) {
udev->link_priority = rule->link_priority;
- info("link_priority=%i", udev->link_priority);
+ info("link_priority=%i\n", udev->link_priority);
}
/* apply all_partitions option only at a main block device */
if (rule->partitions &&
strcmp(udev->dev->subsystem, "block") == 0 && udev->dev->kernel_number[0] == '\0') {
udev->partitions = rule->partitions;
- dbg("creation of partition nodes requested");
+ dbg("creation of partition nodes requested\n");
}
/* apply permissions */
if (rule->mode.operation == KEY_OP_ASSIGN_FINAL)
udev->mode_final = 1;
udev->mode = strtol(key_val(rule, &rule->mode), NULL, 8);
- dbg("applied mode=%#o to '%s'", udev->mode, udev->dev->kernel);
+ dbg("applied mode=%#o to '%s'\n", udev->mode, udev->dev->kernel);
}
if (!udev->owner_final && rule->owner.operation != KEY_OP_UNSET) {
if (rule->owner.operation == KEY_OP_ASSIGN_FINAL)
udev->owner_final = 1;
strlcpy(udev->owner, key_val(rule, &rule->owner), sizeof(udev->owner));
udev_rules_apply_format(udev, udev->owner, sizeof(udev->owner));
- dbg("applied owner='%s' to '%s'", udev->owner, udev->dev->kernel);
+ dbg("applied owner='%s' to '%s'\n", udev->owner, udev->dev->kernel);
}
if (!udev->group_final && rule->group.operation != KEY_OP_UNSET) {
if (rule->group.operation == KEY_OP_ASSIGN_FINAL)
udev->group_final = 1;
strlcpy(udev->group, key_val(rule, &rule->group), sizeof(udev->group));
udev_rules_apply_format(udev, udev->group, sizeof(udev->group));
- dbg("applied group='%s' to '%s'", udev->group, udev->dev->kernel);
+ dbg("applied group='%s' to '%s'\n", udev->group, udev->dev->kernel);
}
/* collect symlinks */
udev->symlink_final = 1;
if (rule->symlink.operation == KEY_OP_ASSIGN ||
rule->symlink.operation == KEY_OP_ASSIGN_FINAL) {
- info("reset symlink list");
+ info("reset symlink list\n");
name_list_cleanup(&udev->symlink_list);
}
/* allow multiple symlinks separated by spaces */
rule->string_escape == ESCAPE_REPLACE) {
count = replace_chars(temp, ALLOWED_CHARS_FILE " ");
if (count > 0)
- info("%i character(s) replaced" , count);
+ info("%i character(s) replaced\n" , count);
}
- dbg("rule applied, added symlink(s) '%s'", temp);
+ dbg("rule applied, added symlink(s) '%s'\n", temp);
pos = temp;
while (isspace(pos[0]))
pos++;
next = strchr(pos, ' ');
while (next) {
next[0] = '\0';
- info("add symlink '%s'", pos);
+ info("add symlink '%s'\n", pos);
name_list_add(&udev->symlink_list, pos, 0);
while (isspace(next[1]))
next++;
next = strchr(pos, ' ');
}
if (pos[0] != '\0') {
- info("add symlink '%s'", pos);
+ info("add symlink '%s'\n", pos);
name_list_add(&udev->symlink_list, pos, 0);
}
}
rule->string_escape == ESCAPE_REPLACE) {
count = replace_chars(udev->name, ALLOWED_CHARS_FILE);
if (count > 0)
- info("%i character(s) replaced", count);
+ info("%i character(s) replaced\n", count);
}
- info("rule applied, '%s' becomes '%s'", udev->dev->kernel, udev->name);
+ info("rule applied, '%s' becomes '%s'\n", udev->dev->kernel, udev->name);
if (strcmp(udev->dev->subsystem, "net") != 0)
- dbg("name, '%s' is going to have owner='%s', group='%s', mode=%#o partitions=%i",
+ dbg("name, '%s' is going to have owner='%s', group='%s', mode=%#o partitions=%i\n",
udev->name, udev->owner, udev->group, udev->mode, udev->partitions);
}
if (rule->run.operation == KEY_OP_ASSIGN_FINAL)
udev->run_final = 1;
if (rule->run.operation == KEY_OP_ASSIGN || rule->run.operation == KEY_OP_ASSIGN_FINAL) {
- info("reset run list");
+ info("reset run list\n");
name_list_cleanup(&udev->run_list);
}
- dbg("add run '%s'", key_val(rule, &rule->run));
+ dbg("add run '%s'\n", key_val(rule, &rule->run));
entry = name_list_add(&udev->run_list, key_val(rule, &rule->run), 0);
if (rule->run_ignore_error)
entry->ignore_error = 1;
}
if (rule->last_rule) {
- dbg("last rule to be applied");
+ dbg("last rule to be applied\n");
break;
}
if (rule->goto_label.operation != KEY_OP_UNSET) {
- dbg("moving forward to label '%s'", key_val(rule, &rule->goto_label));
+ dbg("moving forward to label '%s'\n", key_val(rule, &rule->goto_label));
udev_rules_iter_label(rules, key_val(rule, &rule->goto_label));
}
}
}
if (!name_set) {
- info("no node name set, will use kernel name '%s'", udev->dev->kernel);
+ info("no node name set, will use kernel name '%s'\n", udev->dev->kernel);
strlcpy(udev->name, udev->dev->kernel, sizeof(udev->name));
}
if (udev->tmp_node[0] != '\0') {
- dbg("removing temporary device node");
+ dbg("removing temporary device node\n");
unlink_secure(udev->tmp_node);
udev->tmp_node[0] = '\0';
}
{
struct udev_rule *rule;
- dbg("udev->kernel='%s'", udev->dev->kernel);
+ dbg("udev->kernel='%s'\n", udev->dev->kernel);
/* look for a matching rule to apply */
udev_rules_iter_init(rules);
if (rule == NULL)
break;
- dbg("process rule");
+ dbg("process rule\n");
if (rule->name.operation == KEY_OP_ASSIGN ||
rule->name.operation == KEY_OP_ASSIGN_FINAL ||
rule->name.operation == KEY_OP_ADD ||
rule->symlink.operation == KEY_OP_ADD ||
rule->mode.operation != KEY_OP_UNSET ||
rule->owner.operation != KEY_OP_UNSET || rule->group.operation != KEY_OP_UNSET) {
- dbg("skip rule that names a device");
+ dbg("skip rule that names a device\n");
continue;
}
if (match_rule(udev, rule) == 0) {
if (rule->ignore_device) {
- info("rule applied, '%s' is ignored", udev->dev->kernel);
+ info("rule applied, '%s' is ignored\n", udev->dev->kernel);
udev->ignore_device = 1;
return 0;
}
if (rule->ignore_remove) {
udev->ignore_remove = 1;
- dbg("remove event should be ignored");
+ dbg("remove event should be ignored\n");
}
if (!udev->run_final && rule->run.operation != KEY_OP_UNSET) {
if (rule->run.operation == KEY_OP_ASSIGN ||
rule->run.operation == KEY_OP_ASSIGN_FINAL) {
- info("reset run list");
+ info("reset run list\n");
name_list_cleanup(&udev->run_list);
}
- dbg("add run '%s'", key_val(rule, &rule->run));
+ dbg("add run '%s'\n", key_val(rule, &rule->run));
entry = name_list_add(&udev->run_list, key_val(rule, &rule->run), 0);
if (rule->run_ignore_error)
entry->ignore_error = 1;
}
if (rule->last_rule) {
- dbg("last rule to be applied");
+ dbg("last rule to be applied\n");
break;
}
if (rule->goto_label.operation != KEY_OP_UNSET) {
- dbg("moving forward to label '%s'", key_val(rule, &rule->goto_label));
+ dbg("moving forward to label '%s'\n", key_val(rule, &rule->goto_label));
udev_rules_iter_label(rules, key_val(rule, &rule->goto_label));
}
}
void udev_rules_iter_init(struct udev_rules *rules)
{
- dbg("bufsize=%zi", rules->bufsize);
+ dbg("bufsize=%zi\n", rules->bufsize);
rules->current = 0;
}
if (!rules)
return NULL;
- dbg("current=%zi", rules->current);
+ dbg("current=%zi\n", rules->current);
if (rules->current >= rules->bufsize) {
- dbg("no more rules");
+ dbg("no more rules\n");
return NULL;
}
static struct udev_rule *rule;
next:
- dbg("current=%zi", rules->current);
+ dbg("current=%zi\n", rules->current);
if (rules->current >= rules->bufsize) {
- dbg("no more rules");
+ dbg("no more rules\n");
return NULL;
}
rule = (struct udev_rule *) (rules->buf + rules->current);
if (strcmp(&rule->buf[rule->label.val_off], label) != 0) {
- dbg("moving forward, looking for label '%s'", label);
+ dbg("moving forward, looking for label '%s'\n", label);
rules->current += sizeof(struct udev_rule) + rule->bufsize;
goto next;
}
- dbg("found label '%s'", label);
+ dbg("found label '%s'\n", label);
return rule;
}
if (linepos[0] == '=' && linepos[1] == '=') {
*operation = KEY_OP_MATCH;
linepos += 2;
- dbg("operator=match");
+ dbg("operator=match\n");
} else if (linepos[0] == '!' && linepos[1] == '=') {
*operation = KEY_OP_NOMATCH;
linepos += 2;
- dbg("operator=nomatch");
+ dbg("operator=nomatch\n");
} else if (linepos[0] == '+' && linepos[1] == '=') {
*operation = KEY_OP_ADD;
linepos += 2;
- dbg("operator=add");
+ dbg("operator=add\n");
} else if (linepos[0] == '=') {
*operation = KEY_OP_ASSIGN;
linepos++;
- dbg("operator=assign");
+ dbg("operator=assign\n");
} else if (linepos[0] == ':' && linepos[1] == '=') {
*operation = KEY_OP_ASSIGN_FINAL;
linepos += 2;
- dbg("operator=assign_final");
+ dbg("operator=assign_final\n");
} else
return -1;
/* terminate key */
temp[0] = '\0';
- dbg("key='%s'", *key);
+ dbg("key='%s'\n", *key);
/* skip whitespace after operator */
while (isspace(linepos[0]))
return -1;
temp[0] = '\0';
temp++;
- dbg("value='%s'", *value);
+ dbg("value='%s'\n", *value);
/* move line to next key */
*line = temp;
attr++;
pos = strchr(attr, '}');
if (pos == NULL) {
- err("missing closing brace for format");
+ err("missing closing brace for format\n");
return NULL;
}
pos[0] = '\0';
- dbg("attribute='%s'", attr);
+ dbg("attribute='%s'\n", attr);
return attr;
}
size_t key_len = strnlen(key, PATH_SIZE);
if (pairs->count >= PAIRS_MAX) {
- err("skip, too many keys of the same type in a single rule");
+ err("skip, too many keys of the same type in a single rule\n");
return -1;
}
if (strcasecmp(key, "ACTION") == 0) {
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
- err("invalid ACTION operation");
+ err("invalid ACTION operation\n");
goto invalid;
}
add_rule_key(rule, &rule->action, operation, value);
if (strcasecmp(key, "DEVPATH") == 0) {
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
- err("invalid DEVPATH operation");
+ err("invalid DEVPATH operation\n");
goto invalid;
}
add_rule_key(rule, &rule->devpath, operation, value);
if (strcasecmp(key, "KERNEL") == 0) {
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
- err("invalid KERNEL operation");
+ err("invalid KERNEL operation\n");
goto invalid;
}
add_rule_key(rule, &rule->kernel, operation, value);
if (strcasecmp(key, "SUBSYSTEM") == 0) {
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
- err("invalid SUBSYSTEM operation");
+ err("invalid SUBSYSTEM operation\n");
goto invalid;
}
/* bus, class, subsystem events should all be the same */
strcmp(value, "bus") == 0 ||
strcmp(value, "class") == 0) {
if (strcmp(value, "bus") == 0 || strcmp(value, "class") == 0)
- err("'%s' must be specified as 'subsystem' "
+ err("'%s' must be specified as 'subsystem' \n"
"please fix it in %s:%u", value, filename, lineno);
add_rule_key(rule, &rule->subsystem, operation, "subsystem|class|bus");
} else
if (strcasecmp(key, "DRIVER") == 0) {
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
- err("invalid DRIVER operation");
+ err("invalid DRIVER operation\n");
goto invalid;
}
add_rule_key(rule, &rule->driver, operation, value);
if (strncasecmp(key, "ATTR{", sizeof("ATTR{")-1) == 0) {
attr = get_key_attribute(key + sizeof("ATTR")-1);
if (attr == NULL) {
- err("error parsing ATTR attribute");
+ err("error parsing ATTR attribute\n");
goto invalid;
}
if (add_rule_key_pair(rule, &rule->attr, operation, attr, value) != 0)
strcasecmp(key, "ID") == 0) {
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
- err("invalid KERNELS operation");
+ err("invalid KERNELS operation\n");
goto invalid;
}
add_rule_key(rule, &rule->kernels, operation, value);
strcasecmp(key, "BUS") == 0) {
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
- err("invalid SUBSYSTEMS operation");
+ err("invalid SUBSYSTEMS operation\n");
goto invalid;
}
add_rule_key(rule, &rule->subsystems, operation, value);
if (strcasecmp(key, "DRIVERS") == 0) {
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
- err("invalid DRIVERS operation");
+ err("invalid DRIVERS operation\n");
goto invalid;
}
add_rule_key(rule, &rule->drivers, operation, value);
strncasecmp(key, "SYSFS{", sizeof("SYSFS{")-1) == 0) {
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
- err("invalid ATTRS operation");
+ err("invalid ATTRS operation\n");
goto invalid;
}
attr = get_key_attribute(key + sizeof("ATTRS")-1);
if (attr == NULL) {
- err("error parsing ATTRS attribute");
+ err("error parsing ATTRS attribute\n");
goto invalid;
}
if (strncmp(attr, "device/", 7) == 0)
- err("the 'device' link is deprecated and will be removed from a future kernel, "
+ err("the 'device' link is deprecated and will be removed from a future kernel, \n"
"please fix it in %s:%u", filename, lineno);
else if (strstr(attr, "../") != NULL)
- err("do not reference parent sysfs directories directly, that may break with a future kernel, "
+ err("do not reference parent sysfs directories directly, that may break with a future kernel, \n"
"please fix it in %s:%u", filename, lineno);
if (add_rule_key_pair(rule, &rule->attrs, operation, attr, value) != 0)
goto invalid;
if (strncasecmp(key, "ENV{", sizeof("ENV{")-1) == 0) {
attr = get_key_attribute(key + sizeof("ENV")-1);
if (attr == NULL) {
- err("error parsing ENV attribute");
+ err("error parsing ENV attribute\n");
goto invalid;
}
if (strncmp(attr, "PHYSDEV", 7) == 0)
if (strcasecmp(key, "RESULT") == 0) {
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
- err("invalid RESULT operation");
+ err("invalid RESULT operation\n");
goto invalid;
}
add_rule_key(rule, &rule->result, operation, value);
if (strncasecmp(key, "IMPORT", sizeof("IMPORT")-1) == 0) {
attr = get_key_attribute(key + sizeof("IMPORT")-1);
if (attr != NULL && strstr(attr, "program")) {
- dbg("IMPORT will be executed");
+ dbg("IMPORT will be executed\n");
rule->import_type = IMPORT_PROGRAM;
} else if (attr != NULL && strstr(attr, "file")) {
- dbg("IMPORT will be included as file");
+ dbg("IMPORT will be included as file\n");
rule->import_type = IMPORT_FILE;
} else if (attr != NULL && strstr(attr, "parent")) {
- dbg("IMPORT will include the parent values");
+ dbg("IMPORT will include the parent values\n");
rule->import_type = IMPORT_PARENT;
} else {
/* figure it out if it is executable */
pos[0] = '\0';
}
- dbg("IMPORT auto mode for '%s'", file);
+ dbg("IMPORT auto mode for '%s'\n", file);
if (!lstat(file, &statbuf) && (statbuf.st_mode & S_IXUSR)) {
- dbg("IMPORT is executable, will be executed (autotype)");
+ dbg("IMPORT is executable, will be executed (autotype)\n");
rule->import_type = IMPORT_PROGRAM;
} else {
- dbg("IMPORT is not executable, will be included as file (autotype)");
+ dbg("IMPORT is not executable, will be included as file (autotype)\n");
rule->import_type = IMPORT_FILE;
}
}
if (strncasecmp(key, "TEST", sizeof("TEST")-1) == 0) {
if (operation != KEY_OP_MATCH &&
operation != KEY_OP_NOMATCH) {
- err("invalid TEST operation");
+ err("invalid TEST operation\n");
goto invalid;
}
attr = get_key_attribute(key + sizeof("TEST")-1);
attr = get_key_attribute(key + sizeof("NAME")-1);
if (attr != NULL) {
if (strstr(attr, "all_partitions") != NULL) {
- dbg("creation of partition nodes requested");
+ dbg("creation of partition nodes requested\n");
rule->partitions = DEFAULT_PARTITIONS_COUNT;
}
if (strstr(attr, "ignore_remove") != NULL) {
- dbg("remove event should be ignored");
+ dbg("remove event should be ignored\n");
rule->ignore_remove = 1;
}
}
if (value[0] == '\0')
- dbg("name empty, node creation supressed");
+ dbg("name empty, node creation supressed\n");
add_rule_key(rule, &rule->name, operation, value);
continue;
}
if (endptr[0] != '\0') {
char owner[32];
uid_t uid = lookup_user(value);
- dbg("replacing username='%s' by id=%i", value, uid);
+ dbg("replacing username='%s' by id=%i\n", value, uid);
sprintf(owner, "%u", (unsigned int) uid);
add_rule_key(rule, &rule->owner, operation, owner);
continue;
if (endptr[0] != '\0') {
char group[32];
gid_t gid = lookup_group(value);
- dbg("replacing groupname='%s' by id=%i", value, gid);
+ dbg("replacing groupname='%s' by id=%i\n", value, gid);
sprintf(group, "%u", (unsigned int) gid);
add_rule_key(rule, &rule->group, operation, group);
continue;
const char *pos;
if (strstr(value, "last_rule") != NULL) {
- dbg("last rule to be applied");
+ dbg("last rule to be applied\n");
rule->last_rule = 1;
}
if (strstr(value, "ignore_device") != NULL) {
- dbg("device should be ignored");
+ dbg("device should be ignored\n");
rule->ignore_device = 1;
}
if (strstr(value, "ignore_remove") != NULL) {
- dbg("remove event should be ignored");
+ dbg("remove event should be ignored\n");
rule->ignore_remove = 1;
}
pos = strstr(value, "link_priority=");
if (pos != NULL) {
rule->link_priority = atoi(&pos[strlen("link_priority=")]);
- dbg("link priority=%i", rule->link_priority);
+ dbg("link priority=%i\n", rule->link_priority);
}
pos = strstr(value, "string_escape=");
if (pos != NULL) {
rule->string_escape = ESCAPE_REPLACE;
}
if (strstr(value, "all_partitions") != NULL) {
- dbg("creation of partition nodes requested");
+ dbg("creation of partition nodes requested\n");
rule->partitions = DEFAULT_PARTITIONS_COUNT;
}
valid = 1;
continue;
}
- err("unknown key '%s' in %s:%u", key, filename, lineno);
+ err("unknown key '%s' in %s:%u\n", key, filename, lineno);
}
if (physdev && rule->wait_for_sysfs.operation == KEY_OP_UNSET)
- err("PHYSDEV* values are deprecated and will be removed from a future kernel, "
+ err("PHYSDEV* values are deprecated and will be removed from a future kernel, \n"
"please fix it in %s:%u", filename, lineno);
/* skip line if not any valid key was found */
/* grow buffer and add rule */
rule_size = sizeof(struct udev_rule) + rule->bufsize;
padding = (sizeof(size_t) - rule_size % sizeof(size_t)) % sizeof(size_t);
- dbg("add %zi padding bytes", padding);
+ dbg("add %zi padding bytes\n", padding);
rule_size += padding;
rule->bufsize += padding;
rules->buf = realloc(rules->buf, rules->bufsize + rule_size);
if (!rules->buf) {
- err("realloc failed");
+ err("realloc failed\n");
goto exit;
}
- dbg("adding rule to offset %zi", rules->bufsize);
+ dbg("adding rule to offset %zi\n", rules->bufsize);
memcpy(rules->buf + rules->bufsize, rule, rule_size);
rules->bufsize += rule_size;
exit:
return 0;
invalid:
- err("invalid rule '%s:%u'", filename, lineno);
+ err("invalid rule '%s:%u'\n", filename, lineno);
return -1;
}
int retval = 0;
if (file_map(filename, &buf, &bufsize) != 0) {
- err("can't open '%s' as rules file: %s", filename, strerror(errno));
+ err("can't open '%s' as rules file: %s\n", filename, strerror(errno));
return -1;
}
- info("reading '%s' as rules file", filename);
+ info("reading '%s' as rules file\n", filename);
/* loop through the whole file */
cur = 0;
continue;
if (count >= sizeof(line)) {
- err("line too long, rule skipped '%s:%u'", filename, lineno);
+ err("line too long, rule skipped '%s:%u'\n", filename, lineno);
continue;
}
}
line[j] = '\0';
- dbg("read '%s'", line);
+ dbg("read '%s'\n", line);
add_to_rules(rules, line, filename, lineno);
}
if (stat(udev_rules_dir, &statbuf) != 0)
return -1;
if ((statbuf.st_mode & S_IFMT) != S_IFDIR) {
- dbg("parse single rules file '%s'", udev_rules_dir);
+ dbg("parse single rules file '%s'\n", udev_rules_dir);
name_list_add(&name_list, udev_rules_dir, 1);
} else {
- dbg("parse rules directory '%s'", udev_rules_dir);
+ dbg("parse rules directory '%s'\n", udev_rules_dir);
retval = add_matching_files(&name_list, udev_rules_dir, RULESFILE_SUFFIX);
}
if (statbuf.st_size)
parse_file(rules, name_loop->name);
else
- dbg("empty rules file '%s'", name_loop->name);
+ dbg("empty rules file '%s'\n", name_loop->name);
} else
- err("could not read '%s': %s", name_loop->name, strerror(errno));
+ err("could not read '%s': %s\n", name_loop->name, strerror(errno));
list_del(&name_loop->node);
free(name_loop);
}
if (selinux_enabled == -1)
selinux_enabled = (is_selinux_enabled() > 0);
- dbg("selinux=%i", selinux_enabled);
+ dbg("selinux=%i\n", selinux_enabled);
return selinux_enabled;
}
}
media = strdup(mediabuf);
- info("selinux_get_media(%s)='%s'", devname, media);
+ info("selinux_get_media(%s)='%s'\n", devname, media);
close_out:
fclose(fp);
if (ret < 0)
if (matchpathcon(file, mode, &scontext) < 0) {
- err("matchpathcon(%s) failed", file);
+ err("matchpathcon(%s) failed\n", file);
return;
}
if (lsetfilecon(file, scontext) < 0)
- err("setfilecon %s failed: %s", file, strerror(errno));
+ err("setfilecon %s failed: %s\n", file, strerror(errno));
freecon(scontext);
}
if (ret < 0)
if (matchpathcon(file, mode, &scontext) < 0) {
- err("matchpathcon(%s) failed", file);
+ err("matchpathcon(%s) failed\n", file);
return;
}
if (setfscreatecon(scontext) < 0)
- err("setfscreatecon %s failed: %s", file, strerror(errno));
+ err("setfscreatecon %s failed: %s\n", file, strerror(errno));
freecon(scontext);
}
{
if (is_selinux_running()) {
if (setfscreatecon(prev_scontext) < 0)
- err("setfscreatecon failed: %s", strerror(errno));
+ err("setfscreatecon failed: %s\n", strerror(errno));
}
}
*/
if (is_selinux_running()) {
if (!udev_root[0])
- err("selinux_init: udev_root not set");
+ err("selinux_init: udev_root not set\n");
matchpathcon_init_prefix(NULL, udev_root);
if (getfscreatecon(&prev_scontext) < 0) {
- err("getfscreatecon failed");
+ err("getfscreatecon failed\n");
prev_scontext = NULL;
}
}
remove_trailing_chars(sysfs_path, '/');
} else
strlcpy(sysfs_path, "/sys", sizeof(sysfs_path));
- dbg("sysfs_path='%s'", sysfs_path);
+ dbg("sysfs_path='%s'\n", sysfs_path);
INIT_LIST_HEAD(&dev_list);
INIT_LIST_HEAD(&attr_list);
if (pos == NULL)
return;
strlcpy(dev->kernel, &pos[1], sizeof(dev->kernel));
- dbg("kernel='%s'", dev->kernel);
+ dbg("kernel='%s'\n", dev->kernel);
/* some devices have '!' in their name, change that to '/' */
pos = dev->kernel;
while (isdigit(pos[-1]))
pos--;
strlcpy(dev->kernel_number, pos, sizeof(dev->kernel_number));
- dbg("kernel_number='%s'", dev->kernel_number);
+ dbg("kernel_number='%s'\n", dev->kernel_number);
}
int sysfs_resolve_link(char *devpath, size_t size)
if (len <= 0)
return -1;
link_target[len] = '\0';
- dbg("path link '%s' points to '%s'", devpath, link_target);
+ dbg("path link '%s' points to '%s'\n", devpath, link_target);
for (back = 0; strncmp(&link_target[back * 3], "../", 3) == 0; back++)
;
- dbg("base '%s', tail '%s', back %i", devpath, &link_target[back * 3], back);
+ dbg("base '%s', tail '%s', back %i\n", devpath, &link_target[back * 3], back);
for (i = 0; i <= back; i++) {
char *pos = strrchr(devpath, '/');
return -1;
pos[0] = '\0';
}
- dbg("after moving back '%s'", devpath);
+ dbg("after moving back '%s'\n", devpath);
strlcat(devpath, "/", size);
strlcat(devpath, &link_target[back * 3], size);
return 0;
strncmp(devpath, "/block/", 7) != 0)
return NULL;
- dbg("open '%s'", devpath);
+ dbg("open '%s'\n", devpath);
strlcpy(devpath_real, devpath, sizeof(devpath_real));
remove_trailing_chars(devpath_real, '/');
if (devpath[0] == '\0' )
/* look for device already in cache (we never put an untranslated path in the cache) */
list_for_each_entry(dev_loop, &dev_list, node) {
if (strcmp(dev_loop->devpath, devpath_real) == 0) {
- dbg("found in cache '%s'", dev_loop->devpath);
+ dbg("found in cache '%s'\n", dev_loop->devpath);
return dev_loop;
}
}
strlcpy(path, sysfs_path, sizeof(path));
strlcat(path, devpath_real, sizeof(path));
if (lstat(path, &statbuf) != 0) {
- dbg("stat '%s' failed: %s", path, strerror(errno));
+ dbg("stat '%s' failed: %s\n", path, strerror(errno));
return NULL;
}
if (S_ISLNK(statbuf.st_mode)) {
/* now look for device in cache after path translation */
list_for_each_entry(dev_loop, &dev_list, node) {
if (strcmp(dev_loop->devpath, devpath_real) == 0) {
- dbg("found in cache '%s'", dev_loop->devpath);
+ dbg("found in cache '%s'\n", dev_loop->devpath);
return dev_loop;
}
}
}
/* it is a new device */
- dbg("new uncached device '%s'", devpath_real);
+ dbg("new uncached device '%s'\n", devpath_real);
dev = malloc(sizeof(struct sysfs_device));
if (dev == NULL)
return NULL;
if (len > 0) {
/* get subsystem from "subsystem" link */
link_target[len] = '\0';
- dbg("subsystem link '%s' points to '%s'", link_path, link_target);
+ dbg("subsystem link '%s' points to '%s'\n", link_path, link_target);
pos = strrchr(link_target, '/');
if (pos != NULL)
strlcpy(dev->subsystem, &pos[1], sizeof(dev->subsystem));
len = readlink(link_path, link_target, sizeof(link_target));
if (len > 0) {
link_target[len] = '\0';
- dbg("driver link '%s' points to '%s'", link_path, link_target);
+ dbg("driver link '%s' points to '%s'\n", link_path, link_target);
pos = strrchr(link_target, '/');
if (pos != NULL)
strlcpy(dev->driver, &pos[1], sizeof(dev->driver));
}
- dbg("add to cache 'devpath=%s', subsystem='%s', driver='%s'", dev->devpath, dev->subsystem, dev->driver);
+ dbg("add to cache 'devpath=%s', subsystem='%s', driver='%s'\n", dev->devpath, dev->subsystem, dev->driver);
list_add(&dev->node, &dev_list);
return dev;
char parent_devpath[PATH_SIZE];
char *pos;
- dbg("open '%s'", dev->devpath);
+ dbg("open '%s'\n", dev->devpath);
/* look if we already know the parent */
if (dev->parent != NULL)
return dev->parent;
strlcpy(parent_devpath, dev->devpath, sizeof(parent_devpath));
- dbg("'%s'", parent_devpath);
+ dbg("'%s'\n", parent_devpath);
/* strip last element */
pos = strrchr(parent_devpath, '/');
if (strncmp(parent_devpath, "/class", 6) == 0) {
pos = strrchr(parent_devpath, '/');
if (pos == &parent_devpath[6] || pos == parent_devpath) {
- dbg("/class top level, look for device link");
+ dbg("/class top level, look for device link\n");
goto device_link;
}
}
if (strcmp(parent_devpath, "/block") == 0) {
- dbg("/block top level, look for device link");
+ dbg("/block top level, look for device link\n");
goto device_link;
}
ssize_t size;
size_t sysfs_len;
- dbg("open '%s'/'%s'", devpath, attr_name);
+ dbg("open '%s'/'%s'\n", devpath, attr_name);
sysfs_len = strlcpy(path_full, sysfs_path, sizeof(path_full));
if(sysfs_len >= sizeof(path_full))
sysfs_len = sizeof(path_full) - 1;
/* look for attribute in cache */
list_for_each_entry(attr_loop, &attr_list, node) {
if (strcmp(attr_loop->path, path) == 0) {
- dbg("found in cache '%s'", attr_loop->path);
+ dbg("found in cache '%s'\n", attr_loop->path);
return attr_loop->value;
}
}
/* store attribute in cache (also negatives are kept in cache) */
- dbg("new uncached attribute '%s'", path_full);
+ dbg("new uncached attribute '%s'\n", path_full);
attr = malloc(sizeof(struct sysfs_attr));
if (attr == NULL)
return NULL;
memset(attr, 0x00, sizeof(struct sysfs_attr));
strlcpy(attr->path, path, sizeof(attr->path));
- dbg("add to cache '%s'", path_full);
+ dbg("add to cache '%s'\n", path_full);
list_add(&attr->node, &attr_list);
if (lstat(path_full, &statbuf) != 0) {
- dbg("stat '%s' failed: %s", path_full, strerror(errno));
+ dbg("stat '%s' failed: %s\n", path_full, strerror(errno));
goto out;
}
link_target[len] = '\0';
pos = strrchr(link_target, '/');
if (pos != NULL) {
- dbg("cache '%s' with link value '%s'", path_full, value);
+ dbg("cache '%s' with link value '%s'\n", path_full, value);
strlcpy(attr->value_local, &pos[1], sizeof(attr->value_local));
attr->value = attr->value_local;
}
/* read attribute value */
fd = open(path_full, O_RDONLY);
if (fd < 0) {
- dbg("attribute '%s' can not be opened", path_full);
+ dbg("attribute '%s' can not be opened\n", path_full);
goto out;
}
size = read(fd, value, sizeof(value));
/* got a valid value, store and return it */
value[size] = '\0';
remove_trailing_chars(value, '\n');
- dbg("cache '%s' with attribute value '%s'", path_full, value);
+ dbg("cache '%s' with attribute value '%s'\n", path_full, value);
strlcpy(attr->value_local, value, sizeof(attr->value_local));
attr->value = attr->value_local;
/* avoid duplicate entries */
list_for_each_entry(name_loop, name_list, node) {
if (strcmp(name_loop->name, name) == 0) {
- dbg("'%s' is already in the list", name);
+ dbg("'%s' is already in the list\n", name);
return name_loop;
}
}
return NULL;
strlcpy(name_new->name, name, sizeof(name_new->name));
- dbg("adding '%s'", name_new->name);
+ dbg("adding '%s'\n", name_new->name);
list_add_tail(&name_new->node, &name_loop->node);
return name_new;
list_for_each_entry(name_loop, name_list, node) {
if (strncmp(name_loop->name, key, strlen(key)) == 0) {
- dbg("key already present '%s', replace it", name_loop->name);
+ dbg("key already present '%s', replace it\n", name_loop->name);
snprintf(name_loop->name, sizeof(name_loop->name), "%s=%s", key, value);
name_loop->name[sizeof(name_loop->name)-1] = '\0';
return name_loop;
snprintf(name_new->name, sizeof(name_new->name), "%s=%s", key, value);
name_new->name[sizeof(name_new->name)-1] = '\0';
- dbg("adding '%s'", name_new->name);
+ dbg("adding '%s'\n", name_new->name);
list_add_tail(&name_new->node, &name_loop->node);
return name_new;
DIR *dir;
char filename[PATH_SIZE];
- dbg("open directory '%s'", dirname);
+ dbg("open directory '%s'\n", dirname);
dir = opendir(dirname);
if (dir == NULL) {
- err("unable to open '%s': %s", dirname, strerror(errno));
+ err("unable to open '%s': %s\n", dirname, strerror(errno));
return -1;
}
if (strcmp(ext, suffix) != 0)
continue;
}
- dbg("put file '%s/%s' into list", dirname, ent->d_name);
+ dbg("put file '%s/%s' into list\n", dirname, ent->d_name);
snprintf(filename, sizeof(filename), "%s/%s", dirname, ent->d_name);
filename[sizeof(filename)-1] = '\0';
pw = getpwnam(user);
if (pw == NULL) {
if (errno == 0 || errno == ENOENT || errno == ESRCH)
- err("specified user '%s' unknown", user);
+ err("specified user '%s' unknown\n", user);
else
- err("error resolving user '%s': %s", user, strerror(errno));
+ err("error resolving user '%s': %s\n", user, strerror(errno));
} else
uid = pw->pw_uid;
gr = getgrnam(group);
if (gr == NULL) {
if (errno == 0 || errno == ENOENT || errno == ESRCH)
- err("specified group '%s' unknown", group);
+ err("specified group '%s' unknown\n", group);
else
- err("error resolving group '%s': %s", group, strerror(errno));
+ err("error resolving group '%s': %s\n", group, strerror(errno));
} else
gid = gr->gr_gid;
pos--;
pos[0] = '\0';
- dbg("stat '%s'", p);
+ dbg("stat '%s'\n", p);
if (stat(p, &stats) == 0 && (stats.st_mode & S_IFMT) == S_IFDIR)
return 0;
if (create_path(p) != 0)
return -1;
- dbg("mkdir '%s'", p);
+ dbg("mkdir '%s'\n", p);
selinux_setfscreatecon(p, NULL, S_IFDIR|0755);
ret = mkdir(p, 0755);
selinux_resetfscreatecon();
if (retval) {
if (errno == ENOTEMPTY)
return 0;
- err("rmdir(%s) failed: %s", p, strerror(errno));
+ err("rmdir(%s) failed: %s\n", p, strerror(errno));
break;
}
- dbg("removed '%s'", p);
+ dbg("removed '%s'\n", p);
}
return 0;
}
retval = chown(filename, 0, 0);
if (retval)
- err("chown(%s, 0, 0) failed: %s", filename, strerror(errno));
+ err("chown(%s, 0, 0) failed: %s\n", filename, strerror(errno));
retval = chmod(filename, 0000);
if (retval)
- err("chmod(%s, 0000) failed: %s", filename, strerror(errno));
+ err("chmod(%s, 0000) failed: %s\n", filename, strerror(errno));
retval = unlink(filename);
if (errno == ENOENT)
retval = 0;
if (retval)
- err("unlink(%s) failed: %s", filename, strerror(errno));
+ err("unlink(%s) failed: %s\n", filename, strerror(errno));
return retval;
}
#include "udev.h"
-static int verbose;
+static int debug;
#ifdef USE_LOG
void log_message(int priority, const char *format, ...)
return;
va_start(args, format);
- if (verbose) {
+ if (debug) {
vprintf(format, args);
- printf("\n");
} else
vsyslog(priority, format, args);
va_end(args);
const char *name;
int (*cmd)(int argc, char *argv[], char *envp[]);
const char *help;
- int verbose;
+ int debug;
};
static const struct command cmds[];
.name = "test",
.cmd = udevtest,
.help = "simulation run",
- .verbose = 1,
+ .debug = 1,
},
{
.name = "version",
/* find and execute command */
for (cmd = cmds; cmd->name != NULL; cmd++) {
if (strcmp(cmd->name, command) == 0) {
- verbose = cmd->verbose;
+ debug = cmd->debug;
rc = cmd->cmd(argc, argv, envp);
goto out;
}
udev_log = log_priority(env);
logging_init("udevcontrol");
- dbg("version %s", UDEV_VERSION);
+ dbg("version %s\n", UDEV_VERSION);
if (argc < 2) {
fprintf(stderr, "missing command\n\n");
val = &arg[strlen("log_priority=")];
ctrl_msg.type = UDEVD_CTRL_SET_LOG_LEVEL;
*intval = log_priority(val);
- info("send log_priority=%i", *intval);
+ info("send log_priority=%i\n", *intval);
} else if (!strncmp(arg, "max_childs=", strlen("max_childs="))) {
char *endp;
int count;
goto exit;
}
*intval = count;
- info("send max_childs=%i", *intval);
+ info("send max_childs=%i\n", *intval);
} else if (!strncmp(arg, "max_childs_running=", strlen("max_childs_running="))) {
char *endp;
int count;
goto exit;
}
*intval = count;
- info("send max_childs_running=%i", *intval);
+ info("send max_childs_running=%i\n", *intval);
} else if (!strncmp(arg, "env", strlen("env"))) {
val = argv[2];
if (val == NULL) {
}
ctrl_msg.type = UDEVD_CTRL_ENV;
strlcpy(ctrl_msg.buf, val, sizeof(ctrl_msg.buf));
- info("send env '%s'", val);
+ info("send env '%s'\n", val);
} else if (strcmp(arg, "help") == 0 || strcmp(arg, "-h") == 0) {
printf("Usage: udevadm control COMMAND\n"
" --log_priority=<level> set the udev log level for the daemon\n"
sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
if (sock == -1) {
- err("error getting socket: %s", strerror(errno));
+ err("error getting socket: %s\n", strerror(errno));
goto exit;
}
retval = sendto(sock, &ctrl_msg, sizeof(ctrl_msg), 0, (struct sockaddr *)&saddr, addrlen);
if (retval == -1) {
- err("error sending message: %s", strerror(errno));
+ err("error sending message: %s\n", strerror(errno));
retval = 1;
} else {
- dbg("sent message type=0x%02x, %u bytes sent", ctrl_msg.type, retval);
+ dbg("sent message type=0x%02x, %u bytes sent\n", ctrl_msg.type, retval);
retval = 0;
}
udevd - event managing daemon
.SH "SYNOPSIS"
.HP 6
-\fBudevd\fR [\fB\-\-daemon\fR] [\fB\-\-debug\-trace\fR] [\fB\-\-verbose\fR] [\fB\-\-version\fR] [\fB\-\-help\fR]
+\fBudevd\fR [\fB\-\-daemon\fR] [\fB\-\-debug\-trace\fR] [\fB\-\-debug\fR] [\fB\-\-version\fR] [\fB\-\-help\fR]
.SH "DESCRIPTION"
.PP
udevd listens to kernel uevents and passes the incoming events to udev\. It ensures the correct event order and takes care, that events for child devices are delayed until the parent event has finished the device handling\. The behavior of the running daemon can be changed with
Run all events completely serialized\. This may be useful if udev triggers actions or loads kernel modules which cause problems and a slow but continuous operation is needed, where no events are processed in parallel\.
.RE
.PP
-\fB\-\-verbose\fR
+\fB\-\-debug\fR
.RS 4
Print log messages to stdout\.
.RE
#include "udev_selinux.h"
static int debug_trace;
-static int verbose;
+static int debug;
static struct udev_rules rules;
static int udevd_sock = -1;
return;
va_start(args, format);
- if (verbose) {
+ if (debug) {
printf("[%d] ", (int) getpid());
vprintf(format, args);
- printf("\n");
} else
vsyslog(priority, format, args);
va_end(args);
path_encode(&filename_failed_old[start], sizeof(filename) - start);
if (rename(filename_failed_old, filename_failed) == 0)
- info("renamed devpath, moved failed state of '%s' to %s'",
+ info("renamed devpath, moved failed state of '%s' to %s'\n",
msg->devpath_old, msg->devpath);
} else {
unlink(filename_failed);
setpriority(PRIO_PROCESS, 0, UDEV_PRIORITY);
retval = udev_event_process(msg);
- info("seq %llu finished with %i", msg->seqnum, retval);
+ info("seq %llu finished with %i\n", msg->seqnum, retval);
logging_close();
if (retval)
exit(1);
exit(0);
case -1:
- err("fork of child failed: %s", strerror(errno));
+ err("fork of child failed: %s\n", strerror(errno));
msg_queue_delete(msg);
break;
default:
/* get SIGCHLD in main loop */
- info("seq %llu forked, pid [%d], '%s' '%s', %ld seconds old",
+ info("seq %llu forked, pid [%d], '%s' '%s', %ld seconds old\n",
msg->seqnum, pid, msg->action, msg->subsystem, time(NULL) - msg->queue_time);
msg->pid = pid;
}
}
export_event_state(msg, EVENT_QUEUED);
- info("seq %llu queued, '%s' '%s'", msg->seqnum, msg->action, msg->subsystem);
+ info("seq %llu queued, '%s' '%s'\n", msg->seqnum, msg->action, msg->subsystem);
/* run one event after the other in debug mode */
if (debug_trace) {
/* check identical, parent, or child device event */
if (compare_devpath(loop_msg->devpath, msg->devpath) != 0) {
- dbg("%llu, device event still pending %llu (%s)",
+ dbg("%llu, device event still pending %llu (%s)\n",
msg->seqnum, loop_msg->seqnum, loop_msg->devpath);
return 3;
}
/* check for our major:minor number */
if (msg->devt && loop_msg->devt == msg->devt &&
strcmp(msg->subsystem, loop_msg->subsystem) == 0) {
- dbg("%llu, device event still pending %llu (%d:%d)", msg->seqnum,
+ dbg("%llu, device event still pending %llu (%d:%d)\n", msg->seqnum,
loop_msg->seqnum, major(loop_msg->devt), minor(loop_msg->devt));
return 4;
}
/* check physical device event (special case of parent) */
if (msg->physdevpath && msg->action && strcmp(msg->action, "add") == 0)
if (compare_devpath(loop_msg->devpath, msg->physdevpath) != 0) {
- dbg("%llu, physical device event still pending %llu (%s)",
+ dbg("%llu, physical device event still pending %llu (%s)\n",
msg->seqnum, loop_msg->seqnum, loop_msg->devpath);
return 5;
}
/* check run queue for still running events */
list_for_each_entry(loop_msg, &running_list, node) {
if (limit && childs_count++ > limit) {
- dbg("%llu, maximum number (%i) of childs reached", msg->seqnum, childs_count);
+ dbg("%llu, maximum number (%i) of childs reached\n", msg->seqnum, childs_count);
return 1;
}
/* check identical, parent, or child device event */
if (compare_devpath(loop_msg->devpath, msg->devpath) != 0) {
- dbg("%llu, device event still running %llu (%s)",
+ dbg("%llu, device event still running %llu (%s)\n",
msg->seqnum, loop_msg->seqnum, loop_msg->devpath);
return 3;
}
/* check for our major:minor number */
if (msg->devt && loop_msg->devt == msg->devt &&
strcmp(msg->subsystem, loop_msg->subsystem) == 0) {
- dbg("%llu, device event still running %llu (%d:%d)", msg->seqnum,
+ dbg("%llu, device event still running %llu (%d:%d)\n", msg->seqnum,
loop_msg->seqnum, major(loop_msg->devt), minor(loop_msg->devt));
return 4;
}
/* check physical device event (special case of parent) */
if (msg->physdevpath && msg->action && strcmp(msg->action, "add") == 0)
if (compare_devpath(loop_msg->devpath, msg->physdevpath) != 0) {
- dbg("%llu, physical device event still running %llu (%s)",
+ dbg("%llu, physical device event still running %llu (%s)\n",
msg->seqnum, loop_msg->seqnum, loop_msg->devpath);
return 5;
}
return;
running = running_processes();
- dbg("%d processes runnning on system", running);
+ dbg("%d processes runnning on system\n", running);
if (running < 0)
running = max_childs_running;
/* check running processes in our session and possibly throttle */
if (running >= max_childs_running) {
running = running_processes_in_session(sid, max_childs_running+10);
- dbg("at least %d processes running in session", running);
+ dbg("at least %d processes running in session\n", running);
if (running >= max_childs_running) {
- dbg("delay seq %llu, too many processes already running", loop_msg->seqnum);
+ dbg("delay seq %llu, too many processes already running\n", loop_msg->seqnum);
return;
}
}
/* serialize and wait for parent or child events */
if (devpath_busy(loop_msg, max_childs) != 0) {
- dbg("delay seq %llu (%s)", loop_msg->seqnum, loop_msg->devpath);
+ dbg("delay seq %llu (%s)\n", loop_msg->seqnum, loop_msg->devpath);
continue;
}
list_move_tail(&loop_msg->node, &running_list);
udev_event_run(loop_msg);
running++;
- dbg("moved seq %llu to running list", loop_msg->seqnum);
+ dbg("moved seq %llu to running list\n", loop_msg->seqnum);
}
}
keylen = strlen(key);
msg->envp[i] = key;
bufpos += keylen + 1;
- dbg("add '%s' to msg.envp[%i]", msg->envp[i], i);
+ dbg("add '%s' to msg.envp[%i]\n", msg->envp[i], i);
/* remember some keys for further processing */
if (strncmp(key, "ACTION=", 7) == 0)
msg->envp[i] = NULL;
if (msg->devpath == NULL || msg->action == NULL) {
- info("DEVPATH or ACTION missing, ignore message");
+ info("DEVPATH or ACTION missing, ignore message\n");
free(msg);
return NULL;
}
size = recvmsg(udevd_sock, &smsg, 0);
if (size < 0) {
if (errno != EINTR)
- err("unable to receive user udevd message: %s", strerror(errno));
+ err("unable to receive user udevd message: %s\n", strerror(errno));
return;
}
cmsg = CMSG_FIRSTHDR(&smsg);
cred = (struct ucred *) CMSG_DATA(cmsg);
if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) {
- err("no sender credentials received, message ignored");
+ err("no sender credentials received, message ignored\n");
return;
}
if (cred->uid != 0) {
- err("sender uid=%i, message ignored", cred->uid);
+ err("sender uid=%i, message ignored\n", cred->uid);
return;
}
if (strncmp(ctrl_msg.magic, UDEVD_CTRL_MAGIC, sizeof(UDEVD_CTRL_MAGIC)) != 0 ) {
- err("message magic '%s' doesn't match, ignore it", ctrl_msg.magic);
+ err("message magic '%s' doesn't match, ignore it\n", ctrl_msg.magic);
return;
}
case UDEVD_CTRL_ENV:
pos = strchr(ctrl_msg.buf, '=');
if (pos == NULL) {
- err("wrong key format '%s'", ctrl_msg.buf);
+ err("wrong key format '%s'\n", ctrl_msg.buf);
break;
}
pos[0] = '\0';
if (pos[1] == '\0') {
- info("udevd message (ENV) received, unset '%s'", ctrl_msg.buf);
+ info("udevd message (ENV) received, unset '%s'\n", ctrl_msg.buf);
unsetenv(ctrl_msg.buf);
} else {
- info("udevd message (ENV) received, set '%s=%s'", ctrl_msg.buf, &pos[1]);
+ info("udevd message (ENV) received, set '%s=%s'\n", ctrl_msg.buf, &pos[1]);
setenv(ctrl_msg.buf, &pos[1], 1);
}
break;
case UDEVD_CTRL_STOP_EXEC_QUEUE:
- info("udevd message (STOP_EXEC_QUEUE) received");
+ info("udevd message (STOP_EXEC_QUEUE) received\n");
stop_exec_q = 1;
break;
case UDEVD_CTRL_START_EXEC_QUEUE:
- info("udevd message (START_EXEC_QUEUE) received");
+ info("udevd message (START_EXEC_QUEUE) received\n");
stop_exec_q = 0;
msg_queue_manager();
break;
case UDEVD_CTRL_SET_LOG_LEVEL:
intval = (int *) ctrl_msg.buf;
- info("udevd message (SET_LOG_PRIORITY) received, udev_log_priority=%i", *intval);
+ info("udevd message (SET_LOG_PRIORITY) received, udev_log_priority=%i\n", *intval);
udev_log_priority = *intval;
sprintf(udev_log, "UDEV_LOG=%i", udev_log_priority);
putenv(udev_log);
break;
case UDEVD_CTRL_SET_MAX_CHILDS:
intval = (int *) ctrl_msg.buf;
- info("udevd message (UDEVD_SET_MAX_CHILDS) received, max_childs=%i", *intval);
+ info("udevd message (UDEVD_SET_MAX_CHILDS) received, max_childs=%i\n", *intval);
max_childs = *intval;
break;
case UDEVD_CTRL_SET_MAX_CHILDS_RUNNING:
intval = (int *) ctrl_msg.buf;
- info("udevd message (UDEVD_SET_MAX_CHILDS_RUNNING) received, max_childs=%i", *intval);
+ info("udevd message (UDEVD_SET_MAX_CHILDS_RUNNING) received, max_childs=%i\n", *intval);
max_childs_running = *intval;
break;
case UDEVD_CTRL_RELOAD_RULES:
- info("udevd message (RELOAD_RULES) received");
+ info("udevd message (RELOAD_RULES) received\n");
reload_config = 1;
break;
default:
- err("unknown control message type");
+ err("unknown control message type\n");
}
}
size = recv(uevent_netlink_sock, &buffer, sizeof(buffer), 0);
if (size < 0) {
if (errno != EINTR)
- err("unable to receive kernel netlink message: %s", strerror(errno));
+ err("unable to receive kernel netlink message: %s\n", strerror(errno));
return NULL;
}
if ((size_t)size > sizeof(buffer)-1)
size = sizeof(buffer)-1;
buffer[size] = '\0';
- dbg("uevent_size=%zi", size);
+ dbg("uevent_size=%zi\n", size);
/* start of event payload */
bufpos = strlen(buffer)+1;
/* validate message */
pos = strchr(buffer, '@');
if (pos == NULL) {
- err("invalid uevent '%s'", buffer);
+ err("invalid uevent '%s'\n", buffer);
free(msg);
return NULL;
}
pos[0] = '\0';
if (msg->action == NULL) {
- info("no ACTION in payload found, skip event '%s'", buffer);
+ info("no ACTION in payload found, skip event '%s'\n", buffer);
free(msg);
return NULL;
}
if (strcmp(msg->action, buffer) != 0) {
- err("ACTION in payload does not match uevent, skip event '%s'", buffer);
+ err("ACTION in payload does not match uevent, skip event '%s'\n", buffer);
free(msg);
return NULL;
}
list_for_each_entry(msg, &running_list, node) {
if (msg->pid == pid) {
- info("seq %llu, pid [%d] exit with %i, %ld seconds old", msg->seqnum, msg->pid,
+ info("seq %llu, pid [%d] exit with %i, %ld seconds old\n", msg->seqnum, msg->pid,
exitstatus, time(NULL) - msg->queue_time);
msg->exitstatus = exitstatus;
msg_queue_delete(msg);
udevd_sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
if (udevd_sock == -1) {
- err("error getting socket: %s", strerror(errno));
+ err("error getting socket: %s\n", strerror(errno));
return -1;
}
/* the bind takes care of ensuring only one copy running */
retval = bind(udevd_sock, (struct sockaddr *) &saddr, addrlen);
if (retval < 0) {
- err("bind failed: %s", strerror(errno));
+ err("bind failed: %s\n", strerror(errno));
close(udevd_sock);
udevd_sock = -1;
return -1;
uevent_netlink_sock = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
if (uevent_netlink_sock == -1) {
- err("error getting socket: %s", strerror(errno));
+ err("error getting socket: %s\n", strerror(errno));
return -1;
}
retval = bind(uevent_netlink_sock, (struct sockaddr *) &snl, sizeof(struct sockaddr_nl));
if (retval < 0) {
- err("bind failed: %s", strerror(errno));
+ err("bind failed: %s\n", strerror(errno));
close(uevent_netlink_sock);
uevent_netlink_sock = -1;
return -1;
static const struct option options[] = {
{ "daemon", 0, NULL, 'd' },
{ "debug-trace", 0, NULL, 't' },
- { "verbose", 0, NULL, 'v' },
+ { "debug", 0, NULL, 'D' },
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'V' },
{}
logging_init("udevd");
udev_config_init();
selinux_init();
- dbg("version %s", UDEV_VERSION);
+ dbg("version %s\n", UDEV_VERSION);
while (1) {
- option = getopt_long(argc, argv, "dtvhV", options, NULL);
+ option = getopt_long(argc, argv, "dDthV", options, NULL);
if (option == -1)
break;
case 't':
debug_trace = 1;
break;
- case 'v':
- verbose = 1;
+ case 'D':
+ debug = 1;
if (udev_log_priority < LOG_INFO)
udev_log_priority = LOG_INFO;
break;
case 'h':
- printf("Usage: udevd [--help] [--daemon] [--debug-trace] [--verbose] [--version]\n");
+ printf("Usage: udevd [--help] [--daemon] [--debug-trace] [--debug] [--version]\n");
goto exit;
case 'V':
printf("%s\n", UDEV_VERSION);
if (getuid() != 0) {
fprintf(stderr, "root privileges required\n");
- err("root privileges required");
+ err("root privileges required\n");
goto exit;
}
fd = open("/dev/null", O_RDWR);
if (fd < 0) {
fprintf(stderr, "cannot open /dev/null\n");
- err("cannot open /dev/null");
+ err("cannot open /dev/null\n");
}
if (fd > STDIN_FILENO)
dup2(fd, STDIN_FILENO);
if (init_udevd_socket() < 0) {
if (errno == EADDRINUSE) {
fprintf(stderr, "another udev daemon already running\n");
- err("another udev daemon already running");
+ err("another udev daemon already running\n");
rc = 1;
} else {
fprintf(stderr, "error initializing udevd socket\n");
- err("error initializing udevd socket");
+ err("error initializing udevd socket\n");
rc = 2;
}
goto exit;
if (init_uevent_netlink_sock() < 0) {
fprintf(stderr, "error initializing netlink socket\n");
- err("error initializing netlink socket");
+ err("error initializing netlink socket\n");
rc = 3;
goto exit;
}
/* setup signal handler pipe */
retval = pipe(signal_pipe);
if (retval < 0) {
- err("error getting pipes: %s", strerror(errno));
+ err("error getting pipes: %s\n", strerror(errno));
goto exit;
}
retval = fcntl(signal_pipe[READ_END], F_GETFL, 0);
if (retval < 0) {
- err("error fcntl on read pipe: %s", strerror(errno));
+ err("error fcntl on read pipe: %s\n", strerror(errno));
goto exit;
}
retval = fcntl(signal_pipe[READ_END], F_SETFL, retval | O_NONBLOCK);
if (retval < 0) {
- err("error fcntl on read pipe: %s", strerror(errno));
+ err("error fcntl on read pipe: %s\n", strerror(errno));
goto exit;
}
retval = fcntl(signal_pipe[WRITE_END], F_GETFL, 0);
if (retval < 0) {
- err("error fcntl on write pipe: %s", strerror(errno));
+ err("error fcntl on write pipe: %s\n", strerror(errno));
goto exit;
}
retval = fcntl(signal_pipe[WRITE_END], F_SETFL, retval | O_NONBLOCK);
if (retval < 0) {
- err("error fcntl on write pipe: %s", strerror(errno));
+ err("error fcntl on write pipe: %s\n", strerror(errno));
goto exit;
}
pid = fork();
switch (pid) {
case 0:
- dbg("daemonized fork running");
+ dbg("daemonized fork running\n");
break;
case -1:
- err("fork of daemon failed: %s", strerror(errno));
+ err("fork of daemon failed: %s\n", strerror(errno));
rc = 4;
goto exit;
default:
- dbg("child [%u] running, parent exits", pid);
+ dbg("child [%u] running, parent exits\n", pid);
rc = 0;
goto exit;
}
}
/* redirect std{out,err} fd's */
- if (!verbose)
+ if (!debug)
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
if (fd > STDERR_FILENO)
/* become session leader */
sid = setsid();
- dbg("our session is %d", sid);
+ dbg("our session is %d\n", sid);
/* OOM_DISABLE == -17 */
fd = open("/proc/self/oom_adj", O_RDWR);
if (fd < 0)
- err("error disabling OOM: %s", strerror(errno));
+ err("error disabling OOM: %s\n", strerror(errno));
else {
write(fd, "-17", 3);
close(fd);
strlcat(filename, "/"RULES_DYN_DIR, sizeof(filename));
inotify_add_watch(inotify_fd, filename, IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
} else if (errno == ENOSYS)
- err("the kernel does not support inotify, udevd can't monitor rules file changes");
+ err("the kernel does not support inotify, udevd can't monitor rules file changes\n");
else
- err("inotify_init failed: %s", strerror(errno));
+ err("inotify_init failed: %s\n", strerror(errno));
/* maximum limit of forked childs */
value = getenv("UDEVD_MAX_CHILDS");
else
max_childs = UDEVD_MAX_CHILDS;
}
- info("initialize max_childs to %u", max_childs);
+ info("initialize max_childs to %u\n", max_childs);
/* start to throttle forking if maximum number of _running_ childs is reached */
value = getenv("UDEVD_MAX_CHILDS_RUNNING");
else
max_childs_running = UDEVD_MAX_CHILDS_RUNNING;
}
- info("initialize max_childs_running to %u", max_childs_running);
+ info("initialize max_childs_running to %u\n", max_childs_running);
/* clear environment for forked event processes */
clearenv();
fdcount = select(maxfd+1, &readfds, NULL, NULL, NULL);
if (fdcount < 0) {
if (errno != EINTR)
- err("error in select: %s", strerror(errno));
+ err("error in select: %s\n", strerror(errno));
continue;
}
reload_config = 1;
buf = malloc(nbytes);
if (buf == NULL) {
- err("error getting buffer for inotify, disable watching");
+ err("error getting buffer for inotify, disable watching\n");
close(inotify_fd);
inotify_fd = -1;
}
<command>udevd</command>
<arg><option>--daemon</option></arg>
<arg><option>--debug-trace</option></arg>
- <arg><option>--verbose</option></arg>
+ <arg><option>--debug</option></arg>
<arg><option>--version</option></arg>
<arg><option>--help</option></arg>
</cmdsynopsis>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--verbose</option></term>
+ <term><option>--debug</option></term>
<listitem>
<para>Print log messages to stdout.</para>
</listitem>
len = strlcpy(value, attr_value, sizeof(value));
if(len >= sizeof(value))
len = sizeof(value) - 1;
- dbg("attr '%s'='%s'(%zi)", dent->d_name, value, len);
+ dbg("attr '%s'='%s'(%zi)\n", dent->d_name, value, len);
/* remove trailing newlines */
while (len && value[len-1] == '\n')
while (len && isprint(value[len-1]))
len--;
if (len) {
- dbg("attribute value of '%s' non-printable, skip", dent->d_name);
+ dbg("attribute value of '%s' non-printable, skip\n", dent->d_name);
continue;
}
if (count <= 0)
goto out;
- info("found %i devices for '%s'", count, name);
+ info("found %i devices for '%s'\n", count, name);
/* select the device that seems to match */
list_for_each_entry(device, &name_list, node) {
udev_device_init(udev);
if (udev_db_get_device(udev, device->name) != 0)
continue;
- info("found db entry '%s'", device->name);
+ info("found db entry '%s'\n", device->name);
/* make sure, we don't get a link of a differnt device */
strlcpy(filename, udev_root, sizeof(filename));
if (stat(filename, &statbuf) != 0)
continue;
if (major(udev->devt) > 0 && udev->devt != statbuf.st_rdev) {
- info("skip '%s', dev_t doesn't match", udev->name);
+ info("skip '%s', dev_t doesn't match\n", udev->name);
continue;
}
rc = 0;
if (option == -1)
break;
- dbg("option '%c'", option);
+ dbg("option '%c'\n", option);
switch (option) {
case 'n':
/* remove /dev if given */
else
strlcpy(name, optarg, sizeof(name));
remove_trailing_chars(name, '/');
- dbg("name: %s", name);
+ dbg("name: %s\n", name);
break;
case 'p':
/* remove /sys if given */
}
}
}
- dbg("path: %s", path);
+ dbg("path: %s\n", path);
break;
case 'q':
action = ACTION_QUERY;
logging_init("udevsettle");
udev_config_init();
- dbg("version %s", UDEV_VERSION);
+ dbg("version %s\n", UDEV_VERSION);
sysfs_init();
while (1) {
timeout = seconds;
else
fprintf(stderr, "invalid timeout value\n");
- dbg("timeout=%i", timeout);
+ dbg("timeout=%i\n", timeout);
break;
case 'h':
printf("Usage: udevadm settle [--help] [--timeout=<seconds>]\n\n");
struct stat statbuf;
if (stat(queuename, &statbuf) < 0) {
- info("queue is empty");
+ info("queue is empty\n");
break;
}
usleep(1000 * 1000 / LOOP_PER_SECOND);
}
if (loop <= 0) {
- info("timeout waiting for queue");
+ info("timeout waiting for queue\n");
goto exit;
}
goto exit;
seqnum[len] = '\0';
seq_udev = strtoull(seqnum, NULL, 10);
- info("udev seqnum = %llu", seq_udev);
+ info("udev seqnum = %llu\n", seq_udev);
/* read current kernel seqnum */
strlcpy(filename, sysfs_path, sizeof(filename));
goto exit;
seqnum[len] = '\0';
seq_kernel = strtoull(seqnum, NULL, 10);
- info("kernel seqnum = %llu", seq_kernel);
+ info("kernel seqnum = %llu\n", seq_kernel);
/* make sure all kernel events have arrived in the queue */
if (seq_udev >= seq_kernel) {
- info("queue is empty and no pending events left");
+ info("queue is empty and no pending events left\n");
rc = 0;
goto exit;
}
usleep(1000 * 1000 / LOOP_PER_SECOND);
- info("queue is empty, but events still pending");
+ info("queue is empty, but events still pending\n");
}
exit:
if (next == NULL)
goto out;
next[0] = '\0';
- info("import into environment: '%s'", key);
+ info("import into environment: '%s'\n", key);
putenv(key);
key = &next[1];
}
{}
};
- info("version %s", UDEV_VERSION);
+ info("version %s\n", UDEV_VERSION);
udev_config_init();
if (udev_log_priority < LOG_INFO) {
char priority[32];
if (option == -1)
break;
- dbg("option '%c'", option);
+ dbg("option '%c'\n", option);
switch (option) {
case 'a':
action = optarg;
setenv("ACTION", udev->action, 1);
import_uevent_var(udev->dev->devpath);
- info("looking at device '%s' from subsystem '%s'", udev->dev->devpath, udev->dev->subsystem);
+ info("looking at device '%s' from subsystem '%s'\n", udev->dev->devpath, udev->dev->subsystem);
retval = udev_device_event(&rules, udev);
if (retval == 0 && !udev->ignore_device && udev_run) {
struct name_entry *name_loop;
strlcpy(program, name_loop->name, sizeof(program));
udev_rules_apply_format(udev, program, sizeof(program));
- info("run: '%s'", program);
+ info("run: '%s'\n", program);
}
}
udev_device_cleanup(udev);
char devpath[PATH_SIZE];
struct stat statbuf;
- dbg("add '%s'" , path);
+ dbg("add '%s'\n" , path);
/* we only have a device, if we have an uevent file */
strlcpy(filename, path, sizeof(filename));
fd = open(filename, O_WRONLY);
if (fd < 0) {
- dbg("error on opening %s: %s", filename, strerror(errno));
+ dbg("error on opening %s: %s\n", filename, strerror(errno));
return;
}
if (write(fd, action, strlen(action)) < 0)
- info("error writing '%s' to '%s': %s", action, filename, strerror(errno));
+ info("error writing '%s' to '%s': %s\n", action, filename, strerror(errno));
close(fd);
}
logging_init("udevtrigger");
udev_config_init();
- dbg("version %s", UDEV_VERSION);
+ dbg("version %s\n", UDEV_VERSION);
sysfs_init();
while (1) {