diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-04-19 03:25:04 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-04-19 03:25:04 +0200 |
commit | 540f46698dd5a3bed767fa1c761ead1c9e41ed2e (patch) | |
tree | 24d3b7893b3d87aed9fa222fa68427421365ad36 /udev/udev-node.c | |
parent | ccc87b0e992063df81d07fc2581d7ca2d9c87c0a (diff) |
udevd: at startup create /dev/null, /dev/console, /dev/kmsg
Diffstat (limited to 'udev/udev-node.c')
-rw-r--r-- | udev/udev-node.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/udev/udev-node.c b/udev/udev-node.c index 74ec00b1eb..965017240c 100644 --- a/udev/udev-node.c +++ b/udev/udev-node.c @@ -68,7 +68,7 @@ static int name_index(struct udev *udev, const char *devpath, const char *name, int udev_node_mknod(struct udev_device *dev, const char *file, dev_t devnum, mode_t mode, uid_t uid, gid_t gid) { struct udev *udev = udev_device_get_udev(dev); - char file_tmp[UTIL_PATH_SIZE + sizeof(TMP_FILE_EXT)]; + char filename[UTIL_PATH_SIZE]; struct stat stats; int preserve = 0; int err = 0; @@ -81,8 +81,14 @@ int udev_node_mknod(struct udev_device *dev, const char *file, dev_t devnum, mod else mode |= S_IFCHR; - if (file == NULL) + if (file == NULL) { file = udev_device_get_devnode(dev); + } else if (file[0] != '/') { + util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); + util_strlcat(filename, "/", sizeof(filename)); + util_strlcat(filename, file, sizeof(filename)); + file = filename; + } if (lstat(file, &stats) == 0) { if (((stats.st_mode & S_IFMT) == (mode & S_IFMT)) && (stats.st_rdev == devnum)) { @@ -90,6 +96,8 @@ int udev_node_mknod(struct udev_device *dev, const char *file, dev_t devnum, mod preserve = 1; udev_selinux_lsetfilecon(udev, file, mode); } else { + char file_tmp[UTIL_PATH_SIZE + sizeof(TMP_FILE_EXT)]; + info(udev, "atomically replace existing file '%s'\n", file); util_strlcpy(file_tmp, file, sizeof(file_tmp)); util_strlcat(file_tmp, TMP_FILE_EXT, sizeof(file_tmp)); |