1
0
mirror of https://github.com/systemd/systemd.git synced 2025-08-24 09:49:49 +03:00

[PATCH] fix debug in volume id / fix clashing global var name

Here we get the logging for udev_volume_id working if it is compiled
with DEBUG=true. Also fixed is a name clash with a global variable.
This commit is contained in:
kay.sievers@vrfy.org
2004-10-18 22:57:41 -07:00
committed by Greg KH
parent 3b2382de51
commit ff694eca17
3 changed files with 13 additions and 10 deletions

View File

@ -28,9 +28,8 @@ INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644 INSTALL_DATA = ${INSTALL} -m 644
INSTALL_SCRIPT = ${INSTALL_PROGRAM} INSTALL_SCRIPT = ${INSTALL_PROGRAM}
override CFLAGS+=-Wall -fno-builtin -Wchar-subscripts -Wmissing-declarations \ override CFLAGS+=-Wall -fno-builtin -Wchar-subscripts \
-Wnested-externs -Wpointer-arith -Wcast-align \ -Wpointer-arith -Wcast-align -Wsign-compare
-Wsign-compare
override CFLAGS+=-D_FILE_OFFSET_BITS=64 override CFLAGS+=-D_FILE_OFFSET_BITS=64

View File

@ -104,7 +104,7 @@ int main(int argc, char *argv[])
" -d disk label from main device\n" " -d disk label from main device\n"
"\n"; "\n";
static const char short_options[] = "htlud"; static const char short_options[] = "htlud";
char sysfs_path[SYSFS_PATH_MAX]; char sysfs_mnt_path[SYSFS_PATH_MAX];
char dev_path[SYSFS_PATH_MAX]; char dev_path[SYSFS_PATH_MAX];
struct sysfs_class_device *class_dev = NULL; struct sysfs_class_device *class_dev = NULL;
struct sysfs_class_device *class_dev_parent = NULL; struct sysfs_class_device *class_dev_parent = NULL;
@ -118,6 +118,8 @@ int main(int argc, char *argv[])
unsigned long long size; unsigned long long size;
int rc = 1; int rc = 1;
logging_init("udev_volume_id");
while (1) { while (1) {
int option; int option;
@ -152,12 +154,12 @@ int main(int argc, char *argv[])
goto exit; goto exit;
} }
if (sysfs_get_mnt_path(sysfs_path, SYSFS_PATH_MAX) != 0) { if (sysfs_get_mnt_path(sysfs_mnt_path, SYSFS_PATH_MAX) != 0) {
printf("error getting sysfs mount path\n"); printf("error getting sysfs mount path\n");
goto exit; goto exit;
} }
strfieldcpy(dev_path, sysfs_path); strfieldcpy(dev_path, sysfs_mnt_path);
strfieldcat(dev_path, devpath); strfieldcat(dev_path, devpath);
class_dev = sysfs_open_class_device_path(dev_path); class_dev = sysfs_open_class_device_path(dev_path);
@ -261,5 +263,7 @@ exit:
if (vid != NULL) if (vid != NULL)
volume_id_close(vid); volume_id_close(vid);
logging_close();
exit(rc); exit(rc);
} }

View File

@ -387,7 +387,7 @@ int main(int argc, char *argv[], char *envp[])
const char *devpath = ""; const char *devpath = "";
const char *action; const char *action;
const char *subsystem; const char *subsystem;
char sysfs_path[SYSFS_PATH_MAX]; char sysfs_mnt_path[SYSFS_PATH_MAX];
char filename[SYSFS_PATH_MAX]; char filename[SYSFS_PATH_MAX];
struct sysfs_class_device *class_dev; struct sysfs_class_device *class_dev;
struct sysfs_device *devices_dev; struct sysfs_device *devices_dev;
@ -422,14 +422,14 @@ int main(int argc, char *argv[], char *envp[])
goto exit; goto exit;
} }
if (sysfs_get_mnt_path(sysfs_path, SYSFS_PATH_MAX) != 0) { if (sysfs_get_mnt_path(sysfs_mnt_path, SYSFS_PATH_MAX) != 0) {
dbg("error: no sysfs path"); dbg("error: no sysfs path");
rc = 2; rc = 2;
goto exit; goto exit;
} }
if ((strncmp(devpath, "/block/", 7) == 0) || (strncmp(devpath, "/class/", 7) == 0)) { if ((strncmp(devpath, "/block/", 7) == 0) || (strncmp(devpath, "/class/", 7) == 0)) {
snprintf(filename, SYSFS_PATH_MAX-1, "%s%s", sysfs_path, devpath); snprintf(filename, SYSFS_PATH_MAX-1, "%s%s", sysfs_mnt_path, devpath);
filename[SYSFS_PATH_MAX-1] = '\0'; filename[SYSFS_PATH_MAX-1] = '\0';
/* open the class device we are called for */ /* open the class device we are called for */
@ -446,7 +446,7 @@ int main(int argc, char *argv[], char *envp[])
sysfs_close_class_device(class_dev); sysfs_close_class_device(class_dev);
} else if ((strncmp(devpath, "/devices/", 9) == 0)) { } else if ((strncmp(devpath, "/devices/", 9) == 0)) {
snprintf(filename, SYSFS_PATH_MAX-1, "%s%s", sysfs_path, devpath); snprintf(filename, SYSFS_PATH_MAX-1, "%s%s", sysfs_mnt_path, devpath);
filename[SYSFS_PATH_MAX-1] = '\0'; filename[SYSFS_PATH_MAX-1] = '\0';
/* open the path we are called for */ /* open the path we are called for */