mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
udev: remove database conversion code
This commit is contained in:
parent
3f60bcb5e6
commit
1d600df55b
@ -896,90 +896,6 @@ static int mem_size_mb(void)
|
||||
return memsize;
|
||||
}
|
||||
|
||||
static int convert_db(struct udev *udev)
|
||||
{
|
||||
char filename[UTIL_PATH_SIZE];
|
||||
struct udev_enumerate *udev_enumerate;
|
||||
struct udev_list_entry *list_entry;
|
||||
|
||||
/* current database */
|
||||
if (access("/run/udev/data", F_OK) >= 0)
|
||||
return 0;
|
||||
|
||||
/* make sure we do not get here again */
|
||||
mkdir_p("/run/udev/data", 0755);
|
||||
|
||||
/* old database */
|
||||
strscpyl(filename, sizeof(filename), "/dev/.udev/db", NULL);
|
||||
if (access(filename, F_OK) < 0)
|
||||
return 0;
|
||||
|
||||
print_kmsg("converting old udev database\n");
|
||||
|
||||
udev_enumerate = udev_enumerate_new(udev);
|
||||
if (udev_enumerate == NULL)
|
||||
return -1;
|
||||
udev_enumerate_scan_devices(udev_enumerate);
|
||||
udev_list_entry_foreach(list_entry, udev_enumerate_get_list_entry(udev_enumerate)) {
|
||||
struct udev_device *device;
|
||||
|
||||
device = udev_device_new_from_syspath(udev, udev_list_entry_get_name(list_entry));
|
||||
if (device == NULL)
|
||||
continue;
|
||||
|
||||
/* try to find the old database for devices without a current one */
|
||||
if (udev_device_read_db(device, NULL) < 0) {
|
||||
bool have_db;
|
||||
const char *id;
|
||||
struct stat stats;
|
||||
char devpath[UTIL_PATH_SIZE];
|
||||
char from[UTIL_PATH_SIZE];
|
||||
|
||||
have_db = false;
|
||||
|
||||
/* find database in old location */
|
||||
id = udev_device_get_id_filename(device);
|
||||
strscpyl(from, sizeof(from), "/dev/.udev/db/", id, NULL);
|
||||
if (lstat(from, &stats) == 0) {
|
||||
if (!have_db) {
|
||||
udev_device_read_db(device, from);
|
||||
have_db = true;
|
||||
}
|
||||
unlink(from);
|
||||
}
|
||||
|
||||
/* find old database with $subsys:$sysname name */
|
||||
strscpyl(from, sizeof(from), "/dev/.udev/db/",
|
||||
udev_device_get_subsystem(device), ":", udev_device_get_sysname(device), NULL);
|
||||
if (lstat(from, &stats) == 0) {
|
||||
if (!have_db) {
|
||||
udev_device_read_db(device, from);
|
||||
have_db = true;
|
||||
}
|
||||
unlink(from);
|
||||
}
|
||||
|
||||
/* find old database with the encoded devpath name */
|
||||
util_path_encode(udev_device_get_devpath(device), devpath, sizeof(devpath));
|
||||
strscpyl(from, sizeof(from), "/dev/.udev/db/", devpath, NULL);
|
||||
if (lstat(from, &stats) == 0) {
|
||||
if (!have_db) {
|
||||
udev_device_read_db(device, from);
|
||||
have_db = true;
|
||||
}
|
||||
unlink(from);
|
||||
}
|
||||
|
||||
/* write out new database */
|
||||
if (have_db)
|
||||
udev_device_update_db(device);
|
||||
}
|
||||
udev_device_unref(device);
|
||||
}
|
||||
udev_enumerate_unref(udev_enumerate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink)
|
||||
{
|
||||
int ctrl = -1, netlink = -1;
|
||||
@ -1355,9 +1271,6 @@ int main(int argc, char *argv[])
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* if needed, convert old database from earlier udev version */
|
||||
convert_db(udev);
|
||||
|
||||
if (children_max <= 0) {
|
||||
int memsize = mem_size_mb();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user