X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_db.c;h=afbd50e50fc00fdfb9fa1948a209f0d8ec2893b4;hp=806fc71bce3b9f07f2a8d376c3cce5f2f5676249;hb=d27d3bb05288fb5e70bc3f3fc7da1dc8ee5413a8;hpb=63f61c5cf639953aa38e025485919b0aa1c49b59 diff --git a/udev_db.c b/udev_db.c index 806fc71bc..afbd50e50 100644 --- a/udev_db.c +++ b/udev_db.c @@ -74,7 +74,7 @@ int udev_db_add_device(struct udevice *udev) f = fopen(filename, "w"); if (f == NULL) { - dbg("unable to create db file '%s'", filename); + err("unable to create db file '%s'", filename); return -1; } dbg("storing data for device '%s' in '%s'", udev->devpath, filename); @@ -103,7 +103,7 @@ static int parse_db_file(struct udevice *udev, const char *filename) size_t count; if (file_map(filename, &buf, &bufsize) != 0) { - dbg("unable to read db file '%s'", filename); + err("unable to read db file '%s'", filename); return -1; } @@ -116,37 +116,37 @@ static int parse_db_file(struct udevice *udev, const char *filename) switch(bufline[0]) { case 'P': if (count > sizeof(udev->devpath)) - count = sizeof(udev->devpath)-1; - strlcpy(udev->devpath, &bufline[2], count-2); + count = sizeof(udev->devpath); + strlcpy(udev->devpath, &bufline[2], count-1); break; case 'N': if (count > sizeof(udev->name)) - count = sizeof(udev->name)-1; - strlcpy(udev->name, &bufline[2], count-2); + count = sizeof(udev->name); + strlcpy(udev->name, &bufline[2], count-1); break; case 'M': if (count > sizeof(line)) - count = sizeof(line)-1; - strlcpy(line, &bufline[2], count-2); + count = sizeof(line); + strlcpy(line, &bufline[2], count-1); sscanf(line, "%u:%u", &major, &minor); udev->devt = makedev(major, minor); break; case 'S': - if (count > sizeof(line)) - count = sizeof(line)-1; - strlcpy(line, &bufline[2], count-2); + if (count > sizeof(line)) + count = sizeof(line); + strlcpy(line, &bufline[2], count-1); name_list_add(&udev->symlink_list, line, 0); break; case 'A': - if (count > sizeof(line)) - count = sizeof(line)-1; - strlcpy(line, &bufline[2], count-2); + if (count > sizeof(line)) + count = sizeof(line); + strlcpy(line, &bufline[2], count-1); udev->partitions = atoi(line); break; case 'R': - if (count > sizeof(line)) - count = sizeof(line)-1; - strlcpy(line, &bufline[2], count-2); + if (count > sizeof(line)) + count = sizeof(line); + strlcpy(line, &bufline[2], count-1); udev->ignore_remove = atoi(line); break; } @@ -187,7 +187,7 @@ int udev_db_search_name(char *devpath, size_t len, const char *name) dir = opendir(udev_db_path); if (dir == NULL) { - dbg("unable to udev db '%s'", udev_db_path); + err("unable to open udev_db '%s'", udev_db_path); return -1; } @@ -214,7 +214,7 @@ int udev_db_search_name(char *devpath, size_t len, const char *name) dbg("looking at '%s'", filename); if (file_map(filename, &buf, &bufsize) != 0) { - dbg("unable to read db file '%s'", filename); + err("unable to read db file '%s'", filename); continue; } @@ -227,14 +227,14 @@ int udev_db_search_name(char *devpath, size_t len, const char *name) switch(bufline[0]) { case 'P': if (count > sizeof(path)) - count = sizeof(path)-1; - strlcpy(path, &bufline[2], count-2); + count = sizeof(path); + strlcpy(path, &bufline[2], count-1); break; case 'N': case 'S': if (count > sizeof(nodename)) - count = sizeof(nodename)-1; - strlcpy(nodename, &bufline[2], count-2); + count = sizeof(nodename); + strlcpy(nodename, &bufline[2], count-1); dbg("compare '%s' '%s'", nodename, name); if (strcmp(nodename, name) == 0) { strlcpy(devpath, path, len); @@ -260,7 +260,7 @@ int udev_db_dump_names(int (*handler_function)(const char *path, const char *nam dir = opendir(udev_db_path); if (dir == NULL) { - dbg("unable to udev db '%s'", udev_db_path); + err("unable to open udev_db '%s'", udev_db_path); return -1; } @@ -287,7 +287,7 @@ int udev_db_dump_names(int (*handler_function)(const char *path, const char *nam dbg("looking at '%s'", filename); if (file_map(filename, &buf, &bufsize) != 0) { - dbg("unable to read db file '%s'", filename); + err("unable to read db file '%s'", filename); continue; } @@ -302,13 +302,13 @@ int udev_db_dump_names(int (*handler_function)(const char *path, const char *nam switch(bufline[0]) { case 'P': if (count > sizeof(path)) - count = sizeof(path)-1; - strlcpy(path, &bufline[2], count-2); + count = sizeof(path); + strlcpy(path, &bufline[2], count-1); break; case 'N': if (count > sizeof(nodename)) - count = sizeof(nodename)-1; - strlcpy(nodename, &bufline[2], count-2); + count = sizeof(nodename); + strlcpy(nodename, &bufline[2], count-1); break; default: continue;