diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-29 15:11:07 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-29 15:11:07 +0000 |
commit | cae11b51aac9f52d35f2446a26acafbe7be8e9bd (patch) | |
tree | 6284f6c5979f6a001f7086fcfdbfe656a14382e9 /util-linux/mdev.c | |
parent | 4461564c77260351fe3d82386eebf81085347b34 (diff) | |
download | busybox-w32-cae11b51aac9f52d35f2446a26acafbe7be8e9bd.tar.gz busybox-w32-cae11b51aac9f52d35f2446a26acafbe7be8e9bd.tar.bz2 busybox-w32-cae11b51aac9f52d35f2446a26acafbe7be8e9bd.zip |
mdev: fix "foo 0:0 444 >bar/baz" rule handling. make_device() +23 bytes
Diffstat (limited to 'util-linux/mdev.c')
-rw-r--r-- | util-linux/mdev.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index a2866054c..c4c4350a4 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
@@ -203,21 +203,26 @@ static void make_device(char *path, int delete) | |||
203 | if (ENABLE_FEATURE_MDEV_RENAME && alias) { | 203 | if (ENABLE_FEATURE_MDEV_RENAME && alias) { |
204 | char *dest; | 204 | char *dest; |
205 | 205 | ||
206 | /* ">bar/": rename to bar/device_name */ | ||
207 | /* ">bar[/]baz": rename to bar[/]baz */ | ||
206 | dest = strrchr(alias, '/'); | 208 | dest = strrchr(alias, '/'); |
207 | if (dest) { | 209 | if (dest) { /* ">bar/[baz]" ? */ |
208 | if (dest[1] != '\0') | 210 | *dest = '\0'; /* mkdir bar */ |
209 | /* given a file name, so rename it */ | ||
210 | *dest = '\0'; | ||
211 | bb_make_directory(alias, 0755, FILEUTILS_RECUR); | 211 | bb_make_directory(alias, 0755, FILEUTILS_RECUR); |
212 | dest = concat_path_file(alias, device_name); | 212 | *dest = '/'; |
213 | free(alias); | 213 | if (dest[1] == '\0') { /* ">bar/" => ">bar/device_name" */ |
214 | } else | 214 | dest = alias; |
215 | dest = alias; | 215 | alias = concat_path_file(alias, device_name); |
216 | free(dest); | ||
217 | } | ||
218 | } | ||
216 | 219 | ||
217 | rename(device_name, dest); | 220 | /* recreate device_name as a symlink to moved device node */ |
218 | symlink(dest, device_name); | 221 | if (rename(device_name, alias) == 0) { |
222 | symlink(alias, device_name); | ||
223 | } | ||
219 | 224 | ||
220 | free(dest); | 225 | free(alias); |
221 | } | 226 | } |
222 | } | 227 | } |
223 | } | 228 | } |