mdev.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  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. bb_unsetenv_and_free(s1);
  339. bb_unsetenv_and_free(s);
  340. free(command);
  341. }
  342. if (delete && major >= 0) {
  343. if (ENABLE_FEATURE_MDEV_RENAME && alias) {
  344. if (aliaslink == '>')
  345. unlink(device_name);
  346. }
  347. unlink(node_name);
  348. }
  349. if (ENABLE_FEATURE_MDEV_RENAME)
  350. free(alias);
  351. }
  352. /* We found matching line.
  353. * Stop unless it was prefixed with '-' */
  354. if (ENABLE_FEATURE_MDEV_CONF && !keep_matching)
  355. break;
  356. /* end of "while line is read from /etc/mdev.conf" */
  357. } while (ENABLE_FEATURE_MDEV_CONF);
  358. if (ENABLE_FEATURE_MDEV_CONF)
  359. config_close(parser);
  360. free(subsystem_slash_devname);
  361. }
  362. /* File callback for /sys/ traversal */
  363. static int FAST_FUNC fileAction(const char *fileName,
  364. struct stat *statbuf UNUSED_PARAM,
  365. void *userData,
  366. int depth UNUSED_PARAM)
  367. {
  368. size_t len = strlen(fileName) - 4; /* can't underflow */
  369. char *scratch = userData;
  370. /* len check is for paranoid reasons */
  371. if (strcmp(fileName + len, "/dev") != 0 || len >= PATH_MAX)
  372. return FALSE;
  373. strcpy(scratch, fileName);
  374. scratch[len] = '\0';
  375. make_device(scratch, /*delete:*/ 0);
  376. return TRUE;
  377. }
  378. /* Directory callback for /sys/ traversal */
  379. static int FAST_FUNC dirAction(const char *fileName UNUSED_PARAM,
  380. struct stat *statbuf UNUSED_PARAM,
  381. void *userData UNUSED_PARAM,
  382. int depth)
  383. {
  384. /* Extract device subsystem -- the name of the directory
  385. * under /sys/class/ */
  386. if (1 == depth) {
  387. free(G.subsystem);
  388. G.subsystem = strrchr(fileName, '/');
  389. if (G.subsystem)
  390. G.subsystem = xstrdup(G.subsystem + 1);
  391. }
  392. return (depth >= MAX_SYSFS_DEPTH ? SKIP : TRUE);
  393. }
  394. /* For the full gory details, see linux/Documentation/firmware_class/README
  395. *
  396. * Firmware loading works like this:
  397. * - kernel sets FIRMWARE env var
  398. * - userspace checks /lib/firmware/$FIRMWARE
  399. * - userspace waits for /sys/$DEVPATH/loading to appear
  400. * - userspace writes "1" to /sys/$DEVPATH/loading
  401. * - userspace copies /lib/firmware/$FIRMWARE into /sys/$DEVPATH/data
  402. * - userspace writes "0" (worked) or "-1" (failed) to /sys/$DEVPATH/loading
  403. * - kernel loads firmware into device
  404. */
  405. static void load_firmware(const char *firmware, const char *sysfs_path)
  406. {
  407. int cnt;
  408. int firmware_fd, loading_fd, data_fd;
  409. /* check for /lib/firmware/$FIRMWARE */
  410. xchdir("/lib/firmware");
  411. firmware_fd = xopen(firmware, O_RDONLY);
  412. /* in case we goto out ... */
  413. data_fd = -1;
  414. /* check for /sys/$DEVPATH/loading ... give 30 seconds to appear */
  415. xchdir(sysfs_path);
  416. for (cnt = 0; cnt < 30; ++cnt) {
  417. loading_fd = open("loading", O_WRONLY);
  418. if (loading_fd != -1)
  419. goto loading;
  420. sleep(1);
  421. }
  422. goto out;
  423. loading:
  424. /* tell kernel we're loading by "echo 1 > /sys/$DEVPATH/loading" */
  425. if (full_write(loading_fd, "1", 1) != 1)
  426. goto out;
  427. /* load firmware into /sys/$DEVPATH/data */
  428. data_fd = open("data", O_WRONLY);
  429. if (data_fd == -1)
  430. goto out;
  431. cnt = bb_copyfd_eof(firmware_fd, data_fd);
  432. /* tell kernel result by "echo [0|-1] > /sys/$DEVPATH/loading" */
  433. if (cnt > 0)
  434. full_write(loading_fd, "0", 1);
  435. else
  436. full_write(loading_fd, "-1", 2);
  437. out:
  438. if (ENABLE_FEATURE_CLEAN_UP) {
  439. close(firmware_fd);
  440. close(loading_fd);
  441. close(data_fd);
  442. }
  443. }
  444. int mdev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  445. int mdev_main(int argc UNUSED_PARAM, char **argv)
  446. {
  447. RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE);
  448. /* We can be called as hotplug helper */
  449. /* Kernel cannot provide suitable stdio fds for us, do it ourself */
  450. bb_sanitize_stdio();
  451. /* Force the configuration file settings exactly */
  452. umask(0);
  453. xchdir("/dev");
  454. if (argv[1] && strcmp(argv[1], "-s") == 0) {
  455. /* Scan:
  456. * mdev -s
  457. */
  458. struct stat st;
  459. xstat("/", &st);
  460. G.root_major = major(st.st_dev);
  461. G.root_minor = minor(st.st_dev);
  462. /* ACTION_FOLLOWLINKS is needed since in newer kernels
  463. * /sys/block/loop* (for example) are symlinks to dirs,
  464. * not real directories.
  465. * (kernel's CONFIG_SYSFS_DEPRECATED makes them real dirs,
  466. * but we can't enforce that on users)
  467. */
  468. if (access("/sys/class/block", F_OK) != 0) {
  469. /* Scan obsolete /sys/block only if /sys/class/block
  470. * doesn't exist. Otherwise we'll have dupes.
  471. * Also, do not complain if it doesn't exist.
  472. * Some people configure kernel to have no blockdevs.
  473. */
  474. recursive_action("/sys/block",
  475. ACTION_RECURSE | ACTION_FOLLOWLINKS | ACTION_QUIET,
  476. fileAction, dirAction, temp, 0);
  477. }
  478. recursive_action("/sys/class",
  479. ACTION_RECURSE | ACTION_FOLLOWLINKS,
  480. fileAction, dirAction, temp, 0);
  481. } else {
  482. char *fw;
  483. char *seq;
  484. char *action;
  485. char *env_path;
  486. static const char keywords[] ALIGN1 = "remove\0add\0";
  487. enum { OP_remove = 0, OP_add };
  488. smalluint op;
  489. /* Hotplug:
  490. * env ACTION=... DEVPATH=... SUBSYSTEM=... [SEQNUM=...] mdev
  491. * ACTION can be "add" or "remove"
  492. * DEVPATH is like "/block/sda" or "/class/input/mice"
  493. */
  494. action = getenv("ACTION");
  495. env_path = getenv("DEVPATH");
  496. G.subsystem = getenv("SUBSYSTEM");
  497. if (!action || !env_path /*|| !G.subsystem*/)
  498. bb_show_usage();
  499. fw = getenv("FIRMWARE");
  500. op = index_in_strings(keywords, action);
  501. /* If it exists, does /dev/mdev.seq match $SEQNUM?
  502. * If it does not match, earlier mdev is running
  503. * in parallel, and we need to wait */
  504. seq = getenv("SEQNUM");
  505. if (seq) {
  506. int timeout = 2000 / 32; /* 2000 msec */
  507. do {
  508. int seqlen;
  509. char seqbuf[sizeof(int)*3 + 2];
  510. seqlen = open_read_close("mdev.seq", seqbuf, sizeof(seqbuf-1));
  511. if (seqlen < 0) {
  512. seq = NULL;
  513. break;
  514. }
  515. seqbuf[seqlen] = '\0';
  516. if (seqbuf[0] == '\n' /* seed file? */
  517. || strcmp(seq, seqbuf) == 0 /* correct idx? */
  518. ) {
  519. break;
  520. }
  521. usleep(32*1000);
  522. } while (--timeout);
  523. }
  524. snprintf(temp, PATH_MAX, "/sys%s", env_path);
  525. if (op == OP_remove) {
  526. /* Ignoring "remove firmware". It was reported
  527. * to happen and to cause erroneous deletion
  528. * of device nodes. */
  529. if (!fw)
  530. make_device(temp, /*delete:*/ 1);
  531. }
  532. else if (op == OP_add) {
  533. make_device(temp, /*delete:*/ 0);
  534. if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) {
  535. if (fw)
  536. load_firmware(fw, temp);
  537. }
  538. }
  539. if (seq) {
  540. xopen_xwrite_close("mdev.seq", utoa(xatou(seq) + 1));
  541. }
  542. }
  543. if (ENABLE_FEATURE_CLEAN_UP)
  544. RELEASE_CONFIG_BUFFER(temp);
  545. return EXIT_SUCCESS;
  546. }