Patch from Chris Steel to fix mdev deleting device nodes.
This commit is contained in:
parent
b988462d3e
commit
10b36f94bb
@ -37,18 +37,19 @@ static void make_device(char *path, int delete)
|
|||||||
* because sscanf() will stop at the first nondigit, which \n is. We
|
* because sscanf() will stop at the first nondigit, which \n is. We
|
||||||
* also depend on path having writeable space after it. */
|
* also depend on path having writeable space after it. */
|
||||||
|
|
||||||
strcat(path, "/dev");
|
if (!delete) {
|
||||||
fd = open(path, O_RDONLY);
|
strcat(path, "/dev");
|
||||||
len = read(fd, temp + 1, 64);
|
fd = open(path, O_RDONLY);
|
||||||
*temp++ = 0;
|
len = read(fd, temp + 1, 64);
|
||||||
close(fd);
|
*temp++ = 0;
|
||||||
if (len < 1) return;
|
close(fd);
|
||||||
|
if (len < 1) return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Determine device name, type, major and minor */
|
/* Determine device name, type, major and minor */
|
||||||
|
|
||||||
device_name = strrchr(path, '/') + 1;
|
device_name = strrchr(path, '/') + 1;
|
||||||
type = path[5]=='c' ? S_IFCHR : S_IFBLK;
|
type = path[5]=='c' ? S_IFCHR : S_IFBLK;
|
||||||
if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
|
|
||||||
|
|
||||||
/* If we have a config file, look up permissions for this device */
|
/* If we have a config file, look up permissions for this device */
|
||||||
|
|
||||||
@ -164,6 +165,7 @@ static void make_device(char *path, int delete)
|
|||||||
|
|
||||||
umask(0);
|
umask(0);
|
||||||
if (!delete) {
|
if (!delete) {
|
||||||
|
if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
|
||||||
if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST)
|
if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST)
|
||||||
bb_perror_msg_and_die("mknod %s failed", device_name);
|
bb_perror_msg_and_die("mknod %s failed", device_name);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user