aboutsummaryrefslogtreecommitdiff
path: root/util-linux/mdev.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-04-14 21:23:33 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-04-14 21:23:33 +0000
commit32a3d084d32dfc827ffa736959f4fe9834ef528c (patch)
treed47f675f7ac137fd8f54b68f3a0bb59b75adba7e /util-linux/mdev.c
parent7223424815b2ce563553ff35342e84b4a14d8d8b (diff)
downloadbusybox-w32-32a3d084d32dfc827ffa736959f4fe9834ef528c.tar.gz
busybox-w32-32a3d084d32dfc827ffa736959f4fe9834ef528c.tar.bz2
busybox-w32-32a3d084d32dfc827ffa736959f4fe9834ef528c.zip
mdev: safer handling of $SUBSYSTEM in mdev -s
Diffstat (limited to 'util-linux/mdev.c')
-rw-r--r--util-linux/mdev.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 0f7e082ba..2451cca05 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -1,6 +1,5 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 *
4 * mdev - Mini udev for busybox 3 * mdev - Mini udev for busybox
5 * 4 *
6 * Copyright 2005 Rob Landley <rob@landley.net> 5 * Copyright 2005 Rob Landley <rob@landley.net>
@@ -8,7 +7,6 @@
8 * 7 *
9 * Licensed under GPL version 2, see file LICENSE in this tarball for details. 8 * Licensed under GPL version 2, see file LICENSE in this tarball for details.
10 */ 9 */
11
12#include "libbb.h" 10#include "libbb.h"
13#include "xregex.h" 11#include "xregex.h"
14 12
@@ -353,11 +351,13 @@ static int FAST_FUNC dirAction(const char *fileName UNUSED_PARAM,
353 void *userData UNUSED_PARAM, 351 void *userData UNUSED_PARAM,
354 int depth) 352 int depth)
355{ 353{
356 /* Extract device subsystem -- the name of the directory under /sys/class/ */ 354 /* Extract device subsystem -- the name of the directory
355 * under /sys/class/ */
357 if (1 == depth) { 356 if (1 == depth) {
357 free(subsystem);
358 subsystem = strrchr(fileName, '/'); 358 subsystem = strrchr(fileName, '/');
359 if (subsystem) 359 if (subsystem)
360 subsystem++; 360 subsystem = xstrdup(subsystem + 1);
361 } 361 }
362 362
363 return (depth >= MAX_SYSFS_DEPTH ? SKIP : TRUE); 363 return (depth >= MAX_SYSFS_DEPTH ? SKIP : TRUE);
@@ -397,17 +397,17 @@ static void load_firmware(const char *const firmware, const char *const sysfs_pa
397 goto out; 397 goto out;
398 398
399 loading: 399 loading:
400 /* tell kernel we're loading by `echo 1 > /sys/$DEVPATH/loading` */ 400 /* tell kernel we're loading by "echo 1 > /sys/$DEVPATH/loading" */
401 if (full_write(loading_fd, "1", 1) != 1) 401 if (full_write(loading_fd, "1", 1) != 1)
402 goto out; 402 goto out;
403 403
404 /* load firmware by `cat /lib/firmware/$FIRMWARE > /sys/$DEVPATH/data */ 404 /* load firmware into /sys/$DEVPATH/data */
405 data_fd = open("data", O_WRONLY); 405 data_fd = open("data", O_WRONLY);
406 if (data_fd == -1) 406 if (data_fd == -1)
407 goto out; 407 goto out;
408 cnt = bb_copyfd_eof(firmware_fd, data_fd); 408 cnt = bb_copyfd_eof(firmware_fd, data_fd);
409 409
410 /* tell kernel result by `echo [0|-1] > /sys/$DEVPATH/loading` */ 410 /* tell kernel result by "echo [0|-1] > /sys/$DEVPATH/loading" */
411 if (cnt > 0) 411 if (cnt > 0)
412 full_write(loading_fd, "0", 1); 412 full_write(loading_fd, "0", 1);
413 else 413 else