3
0

mdev.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * mdev - Mini udev for busybox
  4. *
  5. * Copyright 2005 Rob Landley <rob@landley.net>
  6. * Copyright 2005 Frank Sorenson <frank@tuxrocks.com>
  7. *
  8. * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  9. */
  10. #include "libbb.h"
  11. #include "xregex.h"
  12. /* "mdev -s" scans /sys/class/xxx, looking for directories which have dev
  13. * file (it is of the form "M:m\n"). Example: /sys/class/tty/tty0/dev
  14. * contains "4:0\n". Directory name is taken as device name, path component
  15. * directly after /sys/class/ as subsystem. In this example, "tty0" and "tty".
  16. * Then mdev creates the /dev/device_name node.
  17. * If /sys/class/.../dev file does not exist, mdev still may act
  18. * on this device: see "@|$|*command args..." parameter in config file.
  19. *
  20. * mdev w/o parameters is called as hotplug helper. It takes device
  21. * and subsystem names from $DEVPATH and $SUBSYSTEM, extracts
  22. * maj,min from "/sys/$DEVPATH/dev" and also examines
  23. * $ACTION ("add"/"delete") and $FIRMWARE.
  24. *
  25. * If action is "add", mdev creates /dev/device_name similarly to mdev -s.
  26. * (todo: explain "delete" and $FIRMWARE)
  27. *
  28. * If /etc/mdev.conf exists, it may modify /dev/device_name's properties.
  29. * /etc/mdev.conf file format:
  30. *
  31. * [-][subsystem/]device user:grp mode [>|=path] [@|$|*command args...]
  32. * [-]@maj,min[-min2] user:grp mode [>|=path] [@|$|*command args...]
  33. * [-]$envvar=val user:grp mode [>|=path] [@|$|*command args...]
  34. *
  35. * Leading minus in 1st field means "don't stop on this line", otherwise
  36. * search is stopped after the matching line is encountered.
  37. *
  38. * The device name or "subsystem/device" combo is matched against 1st field
  39. * (which is a regex), or maj,min is matched against 1st field,
  40. * or specified environment variable (as regex) is matched against 1st field.
  41. *
  42. * $envvar=val format is useful for loading modules for hot-plugged devices
  43. * which do not have driver loaded yet. In this case /sys/class/.../dev
  44. * does not exist, but $MODALIAS is set to needed module's name
  45. * (actually, an alias to it) by kernel. This rule instructs mdev
  46. * to load the module and exit:
  47. * $MODALIAS=.* 0:0 660 @modprobe "$MODALIAS"
  48. * The kernel will generate another hotplug event when /sys/class/.../dev
  49. * file appears.
  50. *
  51. * When line matches, the device node is created, chmod'ed and chown'ed,
  52. * moved to path, and if >path, a symlink to moved node is created,
  53. * all this if /sys/class/.../dev exists.
  54. * Examples:
  55. * =loop/ - moves to /dev/loop
  56. * >disk/sda%1 - moves to /dev/disk/sdaN, makes /dev/sdaN a symlink
  57. *
  58. * Then "command args..." is executed (via sh -c 'command args...').
  59. * @:execute on creation, $:on deletion, *:on both.
  60. * This happens regardless of /sys/class/.../dev existence.
  61. */
  62. struct globals {
  63. int root_major, root_minor;
  64. char *subsystem;
  65. } FIX_ALIASING;
  66. #define G (*(struct globals*)&bb_common_bufsiz1)
  67. /* Prevent infinite loops in /sys symlinks */
  68. #define MAX_SYSFS_DEPTH 3
  69. /* We use additional 64+ bytes in make_device() */
  70. #define SCRATCH_SIZE 80
  71. /* Builds an alias path.
  72. * This function potentionally reallocates the alias parameter.
  73. * Only used for ENABLE_FEATURE_MDEV_RENAME
  74. */
  75. static char *build_alias(char *alias, const char *device_name)
  76. {
  77. char *dest;
  78. /* ">bar/": rename to bar/device_name */
  79. /* ">bar[/]baz": rename to bar[/]baz */
  80. dest = strrchr(alias, '/');
  81. if (dest) { /* ">bar/[baz]" ? */
  82. *dest = '\0'; /* mkdir bar */
  83. bb_make_directory(alias, 0755, FILEUTILS_RECUR);
  84. *dest = '/';
  85. if (dest[1] == '\0') { /* ">bar/" => ">bar/device_name" */
  86. dest = alias;
  87. alias = concat_path_file(alias, device_name);
  88. free(dest);
  89. }
  90. }
  91. return alias;
  92. }
  93. /* mknod in /dev based on a path like "/sys/block/hda/hda1"
  94. * NB1: path parameter needs to have SCRATCH_SIZE scratch bytes
  95. * after NUL, but we promise to not mangle (IOW: to restore if needed)
  96. * path string.
  97. * NB2: "mdev -s" may call us many times, do not leak memory/fds!
  98. */
  99. static void make_device(char *path, int delete)
  100. {
  101. char *device_name, *subsystem_slash_devname;
  102. int major, minor, type, len;
  103. mode_t mode;
  104. parser_t *parser;
  105. /* Try to read major/minor string. Note that the kernel puts \n after
  106. * the data, so we don't need to worry about null terminating the string
  107. * because sscanf() will stop at the first nondigit, which \n is.
  108. * We also depend on path having writeable space after it.
  109. */
  110. major = -1;
  111. if (!delete) {
  112. char *dev_maj_min = path + strlen(path);
  113. strcpy(dev_maj_min, "/dev");
  114. len = open_read_close(path, dev_maj_min + 1, 64);
  115. *dev_maj_min = '\0';
  116. if (len < 1) {
  117. if (!ENABLE_FEATURE_MDEV_EXEC)
  118. return;
  119. /* no "dev" file, but we can still run scripts
  120. * based on device name */
  121. } else if (sscanf(++dev_maj_min, "%u:%u", &major, &minor) != 2) {
  122. major = -1;
  123. }
  124. }
  125. /* Determine device name, type, major and minor */
  126. device_name = (char*) bb_basename(path);
  127. /* http://kernel.org/doc/pending/hotplug.txt says that only
  128. * "/sys/block/..." is for block devices. "/sys/bus" etc is not.
  129. * But since 2.6.25 block devices are also in /sys/class/block.
  130. * We use strstr("/block/") to forestall future surprises. */
  131. type = S_IFCHR;
  132. if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0))
  133. type = S_IFBLK;
  134. /* Make path point to "subsystem/device_name" */
  135. subsystem_slash_devname = NULL;
  136. /* Check for coldplug invocations first */
  137. if (strncmp(path, "/sys/block/", 11) == 0) /* legacy case */
  138. path += sizeof("/sys/") - 1;
  139. else if (strncmp(path, "/sys/class/", 11) == 0)
  140. path += sizeof("/sys/class/") - 1;
  141. else {
  142. /* Example of a hotplug invocation:
  143. * SUBSYSTEM="block"
  144. * DEVPATH="/sys" + "/devices/virtual/mtd/mtd3/mtdblock3"
  145. * ("/sys" is added by mdev_main)
  146. * - path does not contain subsystem
  147. */
  148. subsystem_slash_devname = concat_path_file(G.subsystem, device_name);
  149. path = subsystem_slash_devname;
  150. }
  151. /* If we have config file, look up user settings */
  152. if (ENABLE_FEATURE_MDEV_CONF)
  153. parser = config_open2("/etc/mdev.conf", fopen_for_read);
  154. do {
  155. int keep_matching;
  156. struct bb_uidgid_t ugid;
  157. char *tokens[4];
  158. char *command = NULL;
  159. char *alias = NULL;
  160. char aliaslink = aliaslink; /* for compiler */
  161. /* Defaults in case we won't match any line */
  162. ugid.uid = ugid.gid = 0;
  163. keep_matching = 0;
  164. mode = 0660;
  165. if (ENABLE_FEATURE_MDEV_CONF
  166. && config_read(parser, tokens, 4, 3, "# \t", PARSE_NORMAL)
  167. ) {
  168. char *val;
  169. char *str_to_match;
  170. regmatch_t off[1 + 9 * ENABLE_FEATURE_MDEV_RENAME_REGEXP];
  171. val = tokens[0];
  172. keep_matching = ('-' == val[0]);
  173. val += keep_matching; /* swallow leading dash */
  174. /* Match against either "subsystem/device_name"
  175. * or "device_name" alone */
  176. str_to_match = strchr(val, '/') ? path : device_name;
  177. /* Fields: regex uid:gid mode [alias] [cmd] */
  178. if (val[0] == '@') {
  179. /* @major,minor[-minor2] */
  180. /* (useful when name is ambiguous:
  181. * "/sys/class/usb/lp0" and
  182. * "/sys/class/printer/lp0") */
  183. int cmaj, cmin0, cmin1, sc;
  184. if (major < 0)
  185. continue; /* no dev, no match */
  186. sc = sscanf(val, "@%u,%u-%u", &cmaj, &cmin0, &cmin1);
  187. if (sc < 1
  188. || major != cmaj
  189. || (sc == 2 && minor != cmin0)
  190. || (sc == 3 && (minor < cmin0 || minor > cmin1))
  191. ) {
  192. continue; /* this line doesn't match */
  193. }
  194. goto line_matches;
  195. }
  196. if (val[0] == '$') {
  197. /* regex to match an environment variable */
  198. char *eq = strchr(++val, '=');
  199. if (!eq)
  200. continue;
  201. *eq = '\0';
  202. str_to_match = getenv(val);
  203. if (!str_to_match)
  204. continue;
  205. str_to_match -= strlen(val) + 1;
  206. *eq = '=';
  207. }
  208. /* else: regex to match [subsystem/]device_name */
  209. {
  210. regex_t match;
  211. int result;
  212. xregcomp(&match, val, REG_EXTENDED);
  213. result = regexec(&match, str_to_match, ARRAY_SIZE(off), off, 0);
  214. regfree(&match);
  215. //bb_error_msg("matches:");
  216. //for (int i = 0; i < ARRAY_SIZE(off); i++) {
  217. // if (off[i].rm_so < 0) continue;
  218. // bb_error_msg("match %d: '%.*s'\n", i,
  219. // (int)(off[i].rm_eo - off[i].rm_so),
  220. // device_name + off[i].rm_so);
  221. //}
  222. /* If no match, skip rest of line */
  223. /* (regexec returns whole pattern as "range" 0) */
  224. if (result
  225. || off[0].rm_so
  226. || ((int)off[0].rm_eo != (int)strlen(str_to_match))
  227. ) {
  228. continue; /* this line doesn't match */
  229. }
  230. }
  231. line_matches:
  232. /* This line matches. Stop parsing after parsing
  233. * the rest the line unless keep_matching == 1 */
  234. /* 2nd field: uid:gid - device ownership */
  235. if (get_uidgid(&ugid, tokens[1], 1) == 0)
  236. bb_error_msg("unknown user/group %s on line %d", tokens[1], parser->lineno);
  237. /* 3rd field: mode - device permissions */
  238. bb_parse_mode(tokens[2], &mode);
  239. val = tokens[3];
  240. /* 4th field (opt): ">|=alias" or "!" to not create the node */
  241. if (ENABLE_FEATURE_MDEV_RENAME && val) {
  242. char *a, *s, *st;
  243. a = val;
  244. s = strchrnul(val, ' ');
  245. st = strchrnul(val, '\t');
  246. if (st < s)
  247. s = st;
  248. st = (s[0] && s[1]) ? s+1 : NULL;
  249. aliaslink = a[0];
  250. if (aliaslink == '!' && s == a+1) {
  251. val = st;
  252. /* "!": suppress node creation/deletion */
  253. major = -1;
  254. }
  255. else if (aliaslink == '>' || aliaslink == '=') {
  256. val = st;
  257. s[0] = '\0';
  258. if (ENABLE_FEATURE_MDEV_RENAME_REGEXP) {
  259. char *p;
  260. unsigned i, n;
  261. /* substitute %1..9 with off[1..9], if any */
  262. n = 0;
  263. s = a;
  264. while (*s)
  265. if (*s++ == '%')
  266. n++;
  267. p = alias = xzalloc(strlen(a) + n * strlen(str_to_match));
  268. s = a + 1;
  269. while (*s) {
  270. *p = *s;
  271. if ('%' == *s) {
  272. i = (s[1] - '0');
  273. if (i <= 9 && off[i].rm_so >= 0) {
  274. n = off[i].rm_eo - off[i].rm_so;
  275. strncpy(p, str_to_match + off[i].rm_so, n);
  276. p += n - 1;
  277. s++;
  278. }
  279. }
  280. p++;
  281. s++;
  282. }
  283. } else {
  284. alias = xstrdup(a + 1);
  285. }
  286. }
  287. }
  288. if (ENABLE_FEATURE_MDEV_EXEC && val) {
  289. const char *s = "$@*";
  290. const char *s2 = strchr(s, val[0]);
  291. if (!s2) {
  292. bb_error_msg("bad line %u", parser->lineno);
  293. if (ENABLE_FEATURE_MDEV_RENAME)
  294. free(alias);
  295. continue;
  296. }
  297. /* Are we running this command now?
  298. * Run $cmd on delete, @cmd on create, *cmd on both
  299. */
  300. if (s2 - s != delete) {
  301. /* We are here if: '*',
  302. * or: '@' and delete = 0,
  303. * or: '$' and delete = 1
  304. */
  305. command = xstrdup(val + 1);
  306. }
  307. }
  308. }
  309. /* End of field parsing */
  310. /* "Execute" the line we found */
  311. {
  312. const char *node_name;
  313. node_name = device_name;
  314. if (ENABLE_FEATURE_MDEV_RENAME && alias)
  315. node_name = alias = build_alias(alias, device_name);
  316. if (!delete && major >= 0) {
  317. if (mknod(node_name, mode | type, makedev(major, minor)) && errno != EEXIST)
  318. bb_perror_msg("can't create '%s'", node_name);
  319. if (major == G.root_major && minor == G.root_minor)
  320. symlink(node_name, "root");
  321. if (ENABLE_FEATURE_MDEV_CONF) {
  322. chmod(node_name, mode);
  323. chown(node_name, ugid.uid, ugid.gid);
  324. }
  325. if (ENABLE_FEATURE_MDEV_RENAME && alias) {
  326. if (aliaslink == '>')
  327. symlink(node_name, device_name);
  328. }
  329. }
  330. if (ENABLE_FEATURE_MDEV_EXEC && command) {
  331. /* setenv will leak memory, use putenv/unsetenv/free */
  332. char *s = xasprintf("%s=%s", "MDEV", node_name);
  333. char *s1 = xasprintf("%s=%s", "SUBSYSTEM", G.subsystem);
  334. putenv(s);
  335. putenv(s1);
  336. if (system(command) == -1)
  337. bb_perror_msg("can't run '%s'", command);
  338. unsetenv("SUBSYSTEM");
  339. free(s1);
  340. unsetenv("MDEV");
  341. free(s);
  342. free(command);
  343. }
  344. if (delete && major >= 0) {
  345. if (ENABLE_FEATURE_MDEV_RENAME && alias) {
  346. if (aliaslink == '>')
  347. unlink(device_name);
  348. }
  349. unlink(node_name);
  350. }
  351. if (ENABLE_FEATURE_MDEV_RENAME)
  352. free(alias);
  353. }
  354. /* We found matching line.
  355. * Stop unless it was prefixed with '-' */
  356. if (ENABLE_FEATURE_MDEV_CONF && !keep_matching)
  357. break;
  358. /* end of "while line is read from /etc/mdev.conf" */
  359. } while (ENABLE_FEATURE_MDEV_CONF);
  360. if (ENABLE_FEATURE_MDEV_CONF)
  361. config_close(parser);
  362. free(subsystem_slash_devname);
  363. }
  364. /* File callback for /sys/ traversal */
  365. static int FAST_FUNC fileAction(const char *fileName,
  366. struct stat *statbuf UNUSED_PARAM,
  367. void *userData,
  368. int depth UNUSED_PARAM)
  369. {
  370. size_t len = strlen(fileName) - 4; /* can't underflow */
  371. char *scratch = userData;
  372. /* len check is for paranoid reasons */
  373. if (strcmp(fileName + len, "/dev") != 0 || len >= PATH_MAX)
  374. return FALSE;
  375. strcpy(scratch, fileName);
  376. scratch[len] = '\0';
  377. make_device(scratch, /*delete:*/ 0);
  378. return TRUE;
  379. }
  380. /* Directory callback for /sys/ traversal */
  381. static int FAST_FUNC dirAction(const char *fileName UNUSED_PARAM,
  382. struct stat *statbuf UNUSED_PARAM,
  383. void *userData UNUSED_PARAM,
  384. int depth)
  385. {
  386. /* Extract device subsystem -- the name of the directory
  387. * under /sys/class/ */
  388. if (1 == depth) {
  389. free(G.subsystem);
  390. G.subsystem = strrchr(fileName, '/');
  391. if (G.subsystem)
  392. G.subsystem = xstrdup(G.subsystem + 1);
  393. }
  394. return (depth >= MAX_SYSFS_DEPTH ? SKIP : TRUE);
  395. }
  396. /* For the full gory details, see linux/Documentation/firmware_class/README
  397. *
  398. * Firmware loading works like this:
  399. * - kernel sets FIRMWARE env var
  400. * - userspace checks /lib/firmware/$FIRMWARE
  401. * - userspace waits for /sys/$DEVPATH/loading to appear
  402. * - userspace writes "1" to /sys/$DEVPATH/loading
  403. * - userspace copies /lib/firmware/$FIRMWARE into /sys/$DEVPATH/data
  404. * - userspace writes "0" (worked) or "-1" (failed) to /sys/$DEVPATH/loading
  405. * - kernel loads firmware into device
  406. */
  407. static void load_firmware(const char *firmware, const char *sysfs_path)
  408. {
  409. int cnt;
  410. int firmware_fd, loading_fd, data_fd;
  411. /* check for /lib/firmware/$FIRMWARE */
  412. xchdir("/lib/firmware");
  413. firmware_fd = xopen(firmware, O_RDONLY);
  414. /* in case we goto out ... */
  415. data_fd = -1;
  416. /* check for /sys/$DEVPATH/loading ... give 30 seconds to appear */
  417. xchdir(sysfs_path);
  418. for (cnt = 0; cnt < 30; ++cnt) {
  419. loading_fd = open("loading", O_WRONLY);
  420. if (loading_fd != -1)
  421. goto loading;
  422. sleep(1);
  423. }
  424. goto out;
  425. loading:
  426. /* tell kernel we're loading by "echo 1 > /sys/$DEVPATH/loading" */
  427. if (full_write(loading_fd, "1", 1) != 1)
  428. goto out;
  429. /* load firmware into /sys/$DEVPATH/data */
  430. data_fd = open("data", O_WRONLY);
  431. if (data_fd == -1)
  432. goto out;
  433. cnt = bb_copyfd_eof(firmware_fd, data_fd);
  434. /* tell kernel result by "echo [0|-1] > /sys/$DEVPATH/loading" */
  435. if (cnt > 0)
  436. full_write(loading_fd, "0", 1);
  437. else
  438. full_write(loading_fd, "-1", 2);
  439. out:
  440. if (ENABLE_FEATURE_CLEAN_UP) {
  441. close(firmware_fd);
  442. close(loading_fd);
  443. close(data_fd);
  444. }
  445. }
  446. int mdev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  447. int mdev_main(int argc UNUSED_PARAM, char **argv)
  448. {
  449. RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE);
  450. /* We can be called as hotplug helper */
  451. /* Kernel cannot provide suitable stdio fds for us, do it ourself */
  452. bb_sanitize_stdio();
  453. /* Force the configuration file settings exactly */
  454. umask(0);
  455. xchdir("/dev");
  456. if (argv[1] && strcmp(argv[1], "-s") == 0) {
  457. /* Scan:
  458. * mdev -s
  459. */
  460. struct stat st;
  461. xstat("/", &st);
  462. G.root_major = major(st.st_dev);
  463. G.root_minor = minor(st.st_dev);
  464. /* ACTION_FOLLOWLINKS is needed since in newer kernels
  465. * /sys/block/loop* (for example) are symlinks to dirs,
  466. * not real directories.
  467. * (kernel's CONFIG_SYSFS_DEPRECATED makes them real dirs,
  468. * but we can't enforce that on users)
  469. */
  470. if (access("/sys/class/block", F_OK) != 0) {
  471. /* Scan obsolete /sys/block only if /sys/class/block
  472. * doesn't exist. Otherwise we'll have dupes.
  473. * Also, do not complain if it doesn't exist.
  474. * Some people configure kernel to have no blockdevs.
  475. */
  476. recursive_action("/sys/block",
  477. ACTION_RECURSE | ACTION_FOLLOWLINKS | ACTION_QUIET,
  478. fileAction, dirAction, temp, 0);
  479. }
  480. recursive_action("/sys/class",
  481. ACTION_RECURSE | ACTION_FOLLOWLINKS,
  482. fileAction, dirAction, temp, 0);
  483. } else {
  484. char *fw;
  485. char *seq;
  486. char *action;
  487. char *env_path;
  488. static const char keywords[] ALIGN1 = "remove\0add\0";
  489. enum { OP_remove = 0, OP_add };
  490. smalluint op;
  491. /* Hotplug:
  492. * env ACTION=... DEVPATH=... SUBSYSTEM=... [SEQNUM=...] mdev
  493. * ACTION can be "add" or "remove"
  494. * DEVPATH is like "/block/sda" or "/class/input/mice"
  495. */
  496. action = getenv("ACTION");
  497. env_path = getenv("DEVPATH");
  498. G.subsystem = getenv("SUBSYSTEM");
  499. if (!action || !env_path /*|| !G.subsystem*/)
  500. bb_show_usage();
  501. fw = getenv("FIRMWARE");
  502. op = index_in_strings(keywords, action);
  503. /* If it exists, does /dev/mdev.seq match $SEQNUM?
  504. * If it does not match, earlier mdev is running
  505. * in parallel, and we need to wait */
  506. seq = getenv("SEQNUM");
  507. if (seq) {
  508. int timeout = 2000 / 32; /* 2000 msec */
  509. do {
  510. int seqlen;
  511. char seqbuf[sizeof(int)*3 + 2];
  512. seqlen = open_read_close("mdev.seq", seqbuf, sizeof(seqbuf-1));
  513. if (seqlen < 0) {
  514. seq = NULL;
  515. break;
  516. }
  517. seqbuf[seqlen] = '\0';
  518. if (seqbuf[0] == '\n' /* seed file? */
  519. || strcmp(seq, seqbuf) == 0 /* correct idx? */
  520. ) {
  521. break;
  522. }
  523. usleep(32*1000);
  524. } while (--timeout);
  525. }
  526. snprintf(temp, PATH_MAX, "/sys%s", env_path);
  527. if (op == OP_remove) {
  528. /* Ignoring "remove firmware". It was reported
  529. * to happen and to cause erroneous deletion
  530. * of device nodes. */
  531. if (!fw)
  532. make_device(temp, /*delete:*/ 1);
  533. }
  534. else if (op == OP_add) {
  535. make_device(temp, /*delete:*/ 0);
  536. if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) {
  537. if (fw)
  538. load_firmware(fw, temp);
  539. }
  540. }
  541. if (seq) {
  542. xopen_xwrite_close("mdev.seq", utoa(xatou(seq) + 1));
  543. }
  544. }
  545. if (ENABLE_FEATURE_CLEAN_UP)
  546. RELEASE_CONFIG_BUFFER(temp);
  547. return EXIT_SUCCESS;
  548. }