#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <string.h>
#include <ctype.h>
-#include <linux/fs.h>
#include <sys/ioctl.h>
#include "../../libsysfs/sysfs/libsysfs.h"
-#include "../../udev_lib.h"
+#include "../../udev_utils.h"
#include "../../logging.h"
#include "volume_id.h"
#include "dasdlabel.h"
+#define BLKGETSIZE64 _IOR(0x12,114,size_t)
+
#ifdef LOG
-unsigned char logname[LOGNAME_SIZE];
void log_message(int level, const char *format, ...)
{
va_list args;
return vid;
}
-static unsigned long long get_size(struct volume_id *vid)
-{
- unsigned long long size;
-
- if (ioctl(vid->fd, BLKGETSIZE64, &size) != 0)
- size = 0;
-
- return size;
-}
-
static char *usage_id_name(enum volume_id_usage usage)
{
switch(usage) {
" -d disk label from main device\n"
"\n";
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];
struct sysfs_class_device *class_dev = NULL;
struct sysfs_class_device *class_dev_parent = NULL;
unsigned long long size;
int rc = 1;
+ logging_init("udev_volume_id");
+
while (1) {
int option;
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");
goto exit;
}
- strfieldcpy(dev_path, sysfs_path);
+ strfieldcpy(dev_path, sysfs_mnt_path);
strfieldcat(dev_path, devpath);
class_dev = sysfs_open_class_device_path(dev_path);
if (vid == NULL)
goto exit;
- size = get_size(vid);
+ if (ioctl(vid->fd, BLKGETSIZE64, &size) != 0)
+ size = 0;
if (volume_id_probe(vid, VOLUME_ID_ALL, 0, size) == 0)
goto print;
if (vid != NULL)
volume_id_close(vid);
+ logging_close();
+
exit(rc);
}