3
0

mdev.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  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 GPLv2, see file LICENSE in this source tree.
  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. /* else: for delete, -1 still deletes the node, but < -1 suppresses that */
  126. /* Determine device name, type, major and minor */
  127. device_name = (char*) bb_basename(path);
  128. /* http://kernel.org/doc/pending/hotplug.txt says that only
  129. * "/sys/block/..." is for block devices. "/sys/bus" etc is not.
  130. * But since 2.6.25 block devices are also in /sys/class/block.
  131. * We use strstr("/block/") to forestall future surprises. */
  132. type = S_IFCHR;
  133. if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0))
  134. type = S_IFBLK;
  135. /* Make path point to "subsystem/device_name" */
  136. subsystem_slash_devname = NULL;
  137. /* Check for coldplug invocations first */
  138. if (strncmp(path, "/sys/block/", 11) == 0) /* legacy case */
  139. path += sizeof("/sys/") - 1;
  140. else if (strncmp(path, "/sys/class/", 11) == 0)
  141. path += sizeof("/sys/class/") - 1;
  142. else {
  143. /* Example of a hotplug invocation:
  144. * SUBSYSTEM="block"
  145. * DEVPATH="/sys" + "/devices/virtual/mtd/mtd3/mtdblock3"
  146. * ("/sys" is added by mdev_main)
  147. * - path does not contain subsystem
  148. */
  149. subsystem_slash_devname = concat_path_file(G.subsystem, device_name);
  150. path = subsystem_slash_devname;
  151. }
  152. /* If we have config file, look up user settings */
  153. if (ENABLE_FEATURE_MDEV_CONF)
  154. parser = config_open2("/etc/mdev.conf", fopen_for_read);
  155. do {
  156. int keep_matching;
  157. struct bb_uidgid_t ugid;
  158. char *tokens[4];
  159. char *command = NULL;
  160. char *alias = NULL;
  161. char aliaslink = aliaslink; /* for compiler */
  162. /* Defaults in case we won't match any line */
  163. ugid.uid = ugid.gid = 0;
  164. keep_matching = 0;
  165. mode = 0660;
  166. if (ENABLE_FEATURE_MDEV_CONF
  167. && config_read(parser, tokens, 4, 3, "# \t", PARSE_NORMAL)
  168. ) {
  169. char *val;
  170. char *str_to_match;
  171. regmatch_t off[1 + 9 * ENABLE_FEATURE_MDEV_RENAME_REGEXP];
  172. val = tokens[0];
  173. keep_matching = ('-' == val[0]);
  174. val += keep_matching; /* swallow leading dash */
  175. /* Match against either "subsystem/device_name"
  176. * or "device_name" alone */
  177. str_to_match = strchr(val, '/') ? path : device_name;
  178. /* Fields: regex uid:gid mode [alias] [cmd] */
  179. if (val[0] == '@') {
  180. /* @major,minor[-minor2] */
  181. /* (useful when name is ambiguous:
  182. * "/sys/class/usb/lp0" and
  183. * "/sys/class/printer/lp0") */
  184. int cmaj, cmin0, cmin1, sc;
  185. if (major < 0)
  186. continue; /* no dev, no match */
  187. sc = sscanf(val, "@%u,%u-%u", &cmaj, &cmin0, &cmin1);
  188. if (sc < 1
  189. || major != cmaj
  190. || (sc == 2 && minor != cmin0)
  191. || (sc == 3 && (minor < cmin0 || minor > cmin1))
  192. ) {
  193. continue; /* this line doesn't match */
  194. }
  195. goto line_matches;
  196. }
  197. if (val[0] == '$') {
  198. /* regex to match an environment variable */
  199. char *eq = strchr(++val, '=');
  200. if (!eq)
  201. continue;
  202. *eq = '\0';
  203. str_to_match = getenv(val);
  204. if (!str_to_match)
  205. continue;
  206. str_to_match -= strlen(val) + 1;
  207. *eq = '=';
  208. }
  209. /* else: regex to match [subsystem/]device_name */
  210. {
  211. regex_t match;
  212. int result;
  213. xregcomp(&match, val, REG_EXTENDED);
  214. result = regexec(&match, str_to_match, ARRAY_SIZE(off), off, 0);
  215. regfree(&match);
  216. //bb_error_msg("matches:");
  217. //for (int i = 0; i < ARRAY_SIZE(off); i++) {
  218. // if (off[i].rm_so < 0) continue;
  219. // bb_error_msg("match %d: '%.*s'\n", i,
  220. // (int)(off[i].rm_eo - off[i].rm_so),
  221. // device_name + off[i].rm_so);
  222. //}
  223. /* If no match, skip rest of line */
  224. /* (regexec returns whole pattern as "range" 0) */
  225. if (result
  226. || off[0].rm_so
  227. || ((int)off[0].rm_eo != (int)strlen(str_to_match))
  228. ) {
  229. continue; /* this line doesn't match */
  230. }
  231. }
  232. line_matches:
  233. /* This line matches. Stop parsing after parsing
  234. * the rest the line unless keep_matching == 1 */
  235. /* 2nd field: uid:gid - device ownership */
  236. if (get_uidgid(&ugid, tokens[1], 1) == 0)
  237. bb_error_msg("unknown user/group %s on line %d", tokens[1], parser->lineno);
  238. /* 3rd field: mode - device permissions */
  239. bb_parse_mode(tokens[2], &mode);
  240. val = tokens[3];
  241. /* 4th field (opt): ">|=alias" or "!" to not create the node */
  242. if (ENABLE_FEATURE_MDEV_RENAME && val) {
  243. char *a, *s, *st;
  244. a = val;
  245. s = strchrnul(val, ' ');
  246. st = strchrnul(val, '\t');
  247. if (st < s)
  248. s = st;
  249. st = (s[0] && s[1]) ? s+1 : NULL;
  250. aliaslink = a[0];
  251. if (aliaslink == '!' && s == a+1) {
  252. val = st;
  253. /* "!": suppress node creation/deletion */
  254. major = -2;
  255. }
  256. else if (aliaslink == '>' || aliaslink == '=') {
  257. val = st;
  258. s[0] = '\0';
  259. if (ENABLE_FEATURE_MDEV_RENAME_REGEXP) {
  260. char *p;
  261. unsigned i, n;
  262. /* substitute %1..9 with off[1..9], if any */
  263. n = 0;
  264. s = a;
  265. while (*s)
  266. if (*s++ == '%')
  267. n++;
  268. p = alias = xzalloc(strlen(a) + n * strlen(str_to_match));
  269. s = a + 1;
  270. while (*s) {
  271. *p = *s;
  272. if ('%' == *s) {
  273. i = (s[1] - '0');
  274. if (i <= 9 && off[i].rm_so >= 0) {
  275. n = off[i].rm_eo - off[i].rm_so;
  276. strncpy(p, str_to_match + off[i].rm_so, n);
  277. p += n - 1;
  278. s++;
  279. }
  280. }
  281. p++;
  282. s++;
  283. }
  284. } else {
  285. alias = xstrdup(a + 1);
  286. }
  287. }
  288. }
  289. if (ENABLE_FEATURE_MDEV_EXEC && val) {
  290. const char *s = "$@*";
  291. const char *s2 = strchr(s, val[0]);
  292. if (!s2) {
  293. bb_error_msg("bad line %u", parser->lineno);
  294. if (ENABLE_FEATURE_MDEV_RENAME)
  295. free(alias);
  296. continue;
  297. }
  298. /* Are we running this command now?
  299. * Run $cmd on delete, @cmd on create, *cmd on both
  300. */
  301. if (s2 - s != delete) {
  302. /* We are here if: '*',
  303. * or: '@' and delete = 0,
  304. * or: '$' and delete = 1
  305. */
  306. command = xstrdup(val + 1);
  307. }
  308. }
  309. }
  310. /* End of field parsing */
  311. /* "Execute" the line we found */
  312. {
  313. const char *node_name;
  314. node_name = device_name;
  315. if (ENABLE_FEATURE_MDEV_RENAME && alias)
  316. node_name = alias = build_alias(alias, device_name);
  317. if (!delete && major >= 0) {
  318. if (mknod(node_name, mode | type, makedev(major, minor)) && errno != EEXIST)
  319. bb_perror_msg("can't create '%s'", node_name);
  320. if (major == G.root_major && minor == G.root_minor)
  321. symlink(node_name, "root");
  322. if (ENABLE_FEATURE_MDEV_CONF) {
  323. chmod(node_name, mode);
  324. chown(node_name, ugid.uid, ugid.gid);
  325. }
  326. if (ENABLE_FEATURE_MDEV_RENAME && alias) {
  327. if (aliaslink == '>')
  328. symlink(node_name, device_name);
  329. }
  330. }
  331. if (ENABLE_FEATURE_MDEV_EXEC && command) {
  332. /* setenv will leak memory, use putenv/unsetenv/free */
  333. char *s = xasprintf("%s=%s", "MDEV", node_name);
  334. char *s1 = xasprintf("%s=%s", "SUBSYSTEM", G.subsystem);
  335. putenv(s);
  336. putenv(s1);
  337. if (system(command) == -1)
  338. bb_perror_msg("can't run '%s'", command);
  339. bb_unsetenv_and_free(s1);
  340. bb_unsetenv_and_free(s);
  341. free(command);
  342. }
  343. if (delete && major >= -1) {
  344. if (ENABLE_FEATURE_MDEV_RENAME && alias) {
  345. if (aliaslink == '>')
  346. unlink(device_name);
  347. }
  348. unlink(node_name);
  349. }
  350. if (ENABLE_FEATURE_MDEV_RENAME)
  351. free(alias);
  352. }
  353. /* We found matching line.
  354. * Stop unless it was prefixed with '-' */
  355. if (ENABLE_FEATURE_MDEV_CONF && !keep_matching)
  356. break;
  357. /* end of "while line is read from /etc/mdev.conf" */
  358. } while (ENABLE_FEATURE_MDEV_CONF);
  359. if (ENABLE_FEATURE_MDEV_CONF)
  360. config_close(parser);
  361. free(subsystem_slash_devname);
  362. }
  363. /* File callback for /sys/ traversal */
  364. static int FAST_FUNC fileAction(const char *fileName,
  365. struct stat *statbuf UNUSED_PARAM,
  366. void *userData,
  367. int depth UNUSED_PARAM)
  368. {
  369. size_t len = strlen(fileName) - 4; /* can't underflow */
  370. char *scratch = userData;
  371. /* len check is for paranoid reasons */
  372. if (strcmp(fileName + len, "/dev") != 0 || len >= PATH_MAX)
  373. return FALSE;
  374. strcpy(scratch, fileName);
  375. scratch[len] = '\0';
  376. make_device(scratch, /*delete:*/ 0);
  377. return TRUE;
  378. }
  379. /* Directory callback for /sys/ traversal */
  380. static int FAST_FUNC dirAction(const char *fileName UNUSED_PARAM,
  381. struct stat *statbuf UNUSED_PARAM,
  382. void *userData UNUSED_PARAM,
  383. int depth)
  384. {
  385. /* Extract device subsystem -- the name of the directory
  386. * under /sys/class/ */
  387. if (1 == depth) {
  388. free(G.subsystem);
  389. G.subsystem = strrchr(fileName, '/');
  390. if (G.subsystem)
  391. G.subsystem = xstrdup(G.subsystem + 1);
  392. }
  393. return (depth >= MAX_SYSFS_DEPTH ? SKIP : TRUE);
  394. }
  395. /* For the full gory details, see linux/Documentation/firmware_class/README
  396. *
  397. * Firmware loading works like this:
  398. * - kernel sets FIRMWARE env var
  399. * - userspace checks /lib/firmware/$FIRMWARE
  400. * - userspace waits for /sys/$DEVPATH/loading to appear
  401. * - userspace writes "1" to /sys/$DEVPATH/loading
  402. * - userspace copies /lib/firmware/$FIRMWARE into /sys/$DEVPATH/data
  403. * - userspace writes "0" (worked) or "-1" (failed) to /sys/$DEVPATH/loading
  404. * - kernel loads firmware into device
  405. */
  406. static void load_firmware(const char *firmware, const char *sysfs_path)
  407. {
  408. int cnt;
  409. int firmware_fd, loading_fd, data_fd;
  410. /* check for /lib/firmware/$FIRMWARE */
  411. xchdir("/lib/firmware");
  412. firmware_fd = xopen(firmware, O_RDONLY);
  413. /* in case we goto out ... */
  414. data_fd = -1;
  415. /* check for /sys/$DEVPATH/loading ... give 30 seconds to appear */
  416. xchdir(sysfs_path);
  417. for (cnt = 0; cnt < 30; ++cnt) {
  418. loading_fd = open("loading", O_WRONLY);
  419. if (loading_fd != -1)
  420. goto loading;
  421. sleep(1);
  422. }
  423. goto out;
  424. loading:
  425. /* tell kernel we're loading by "echo 1 > /sys/$DEVPATH/loading" */
  426. if (full_write(loading_fd, "1", 1) != 1)
  427. goto out;
  428. /* load firmware into /sys/$DEVPATH/data */
  429. data_fd = open("data", O_WRONLY);
  430. if (data_fd == -1)
  431. goto out;
  432. cnt = bb_copyfd_eof(firmware_fd, data_fd);
  433. /* tell kernel result by "echo [0|-1] > /sys/$DEVPATH/loading" */
  434. if (cnt > 0)
  435. full_write(loading_fd, "0", 1);
  436. else
  437. full_write(loading_fd, "-1", 2);
  438. out:
  439. if (ENABLE_FEATURE_CLEAN_UP) {
  440. close(firmware_fd);
  441. close(loading_fd);
  442. close(data_fd);
  443. }
  444. }
  445. int mdev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  446. int mdev_main(int argc UNUSED_PARAM, char **argv)
  447. {
  448. RESERVE_CONFIG_BUFFER(temp, PATH_MAX + SCRATCH_SIZE);
  449. /* We can be called as hotplug helper */
  450. /* Kernel cannot provide suitable stdio fds for us, do it ourself */
  451. bb_sanitize_stdio();
  452. /* Force the configuration file settings exactly */
  453. umask(0);
  454. xchdir("/dev");
  455. if (argv[1] && strcmp(argv[1], "-s") == 0) {
  456. /* Scan:
  457. * mdev -s
  458. */
  459. struct stat st;
  460. xstat("/", &st);
  461. G.root_major = major(st.st_dev);
  462. G.root_minor = minor(st.st_dev);
  463. /* ACTION_FOLLOWLINKS is needed since in newer kernels
  464. * /sys/block/loop* (for example) are symlinks to dirs,
  465. * not real directories.
  466. * (kernel's CONFIG_SYSFS_DEPRECATED makes them real dirs,
  467. * but we can't enforce that on users)
  468. */
  469. if (access("/sys/class/block", F_OK) != 0) {
  470. /* Scan obsolete /sys/block only if /sys/class/block
  471. * doesn't exist. Otherwise we'll have dupes.
  472. * Also, do not complain if it doesn't exist.
  473. * Some people configure kernel to have no blockdevs.
  474. */
  475. recursive_action("/sys/block",
  476. ACTION_RECURSE | ACTION_FOLLOWLINKS | ACTION_QUIET,
  477. fileAction, dirAction, temp, 0);
  478. }
  479. recursive_action("/sys/class",
  480. ACTION_RECURSE | ACTION_FOLLOWLINKS,
  481. fileAction, dirAction, temp, 0);
  482. } else {
  483. char *fw;
  484. char *seq;
  485. char *action;
  486. char *env_path;
  487. static const char keywords[] ALIGN1 = "remove\0add\0";
  488. enum { OP_remove = 0, OP_add };
  489. smalluint op;
  490. /* Hotplug:
  491. * env ACTION=... DEVPATH=... SUBSYSTEM=... [SEQNUM=...] mdev
  492. * ACTION can be "add" or "remove"
  493. * DEVPATH is like "/block/sda" or "/class/input/mice"
  494. */
  495. action = getenv("ACTION");
  496. env_path = getenv("DEVPATH");
  497. G.subsystem = getenv("SUBSYSTEM");
  498. if (!action || !env_path /*|| !G.subsystem*/)
  499. bb_show_usage();
  500. fw = getenv("FIRMWARE");
  501. op = index_in_strings(keywords, action);
  502. /* If it exists, does /dev/mdev.seq match $SEQNUM?
  503. * If it does not match, earlier mdev is running
  504. * in parallel, and we need to wait */
  505. seq = getenv("SEQNUM");
  506. if (seq) {
  507. int timeout = 2000 / 32; /* 2000 msec */
  508. do {
  509. int seqlen;
  510. char seqbuf[sizeof(int)*3 + 2];
  511. seqlen = open_read_close("mdev.seq", seqbuf, sizeof(seqbuf-1));
  512. if (seqlen < 0) {
  513. seq = NULL;
  514. break;
  515. }
  516. seqbuf[seqlen] = '\0';
  517. if (seqbuf[0] == '\n' /* seed file? */
  518. || strcmp(seq, seqbuf) == 0 /* correct idx? */
  519. ) {
  520. break;
  521. }
  522. usleep(32*1000);
  523. } while (--timeout);
  524. }
  525. snprintf(temp, PATH_MAX, "/sys%s", env_path);
  526. if (op == OP_remove) {
  527. /* Ignoring "remove firmware". It was reported
  528. * to happen and to cause erroneous deletion
  529. * of device nodes. */
  530. if (!fw)
  531. make_device(temp, /*delete:*/ 1);
  532. }
  533. else if (op == OP_add) {
  534. make_device(temp, /*delete:*/ 0);
  535. if (ENABLE_FEATURE_MDEV_LOAD_FIRMWARE) {
  536. if (fw)
  537. load_firmware(fw, temp);
  538. }
  539. }
  540. if (seq) {
  541. xopen_xwrite_close("mdev.seq", utoa(xatou(seq) + 1));
  542. }
  543. }
  544. if (ENABLE_FEATURE_CLEAN_UP)
  545. RELEASE_CONFIG_BUFFER(temp);
  546. return EXIT_SUCCESS;
  547. }