diff options
author | H. Peter Anvin <hpa@zytor.com> | 2006-08-24 22:18:34 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2006-08-24 22:18:34 -0700 |
commit | 6582bed72ada9ff9154c463c6cd6393d3548b282 (patch) | |
tree | 28aa93eae8159cd8fb52ed4db818e7c9ed3e55cf /extlinux | |
parent | a7179414798e28720e25d4a1346a765a521c4fbe (diff) | |
download | syslinux.git-6582bed72ada9ff9154c463c6cd6393d3548b282.tar.gz syslinux.git-6582bed72ada9ff9154c463c6cd6393d3548b282.tar.xz syslinux.git-6582bed72ada9ff9154c463c6cd6393d3548b282.zip |
extlinux: when compiling against klibc, use atexit() to clean up the devnode
Diffstat (limited to 'extlinux')
-rw-r--r-- | extlinux/extlinux.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/extlinux/extlinux.c b/extlinux/extlinux.c index 1ec8b7bc..75de5b9f 100644 --- a/extlinux/extlinux.c +++ b/extlinux/extlinux.c @@ -645,6 +645,17 @@ already_installed(int devfd) return !memcmp(buffer, "EXTLINUX", 8); } + +#ifdef __KLIBC__ +static char devname_buf[64]; + +static void device_cleanup(void) +{ + unlink(devname_buf); +} +#endif + + int install_loader(const char *path, int update_only) { @@ -668,21 +679,17 @@ install_loader(const char *path, int update_only) /* klibc doesn't have getmntent and friends; instead, just create a new device with the appropriate device type */ - - { - static char devname_buf[64]; - - snprintf(devname_buf, sizeof devname_buf, "/tmp/dev-%u:%u", - major(st.st_dev), minor(st.st_dev)); + snprintf(devname_buf, sizeof devname_buf, "/tmp/dev-%u:%u", + major(st.st_dev), minor(st.st_dev)); - if (mknod(devname_buf, S_IFBLK|0600, st.st_dev)) { - fprintf(stderr, "%s: cannot create device %s\n", program, devname); - return 1; - } - - devname = devname_buf; + if (mknod(devname_buf, S_IFBLK|0600, st.st_dev)) { + fprintf(stderr, "%s: cannot create device %s\n", program, devname); + return 1; } + atexit(device_cleanup); /* unlink the device node on exit */ + devname = devname_buf; + #else if ( (mtab = setmntent("/proc/mounts", "r")) ) { @@ -739,15 +746,7 @@ install_loader(const char *path, int update_only) close(devfd); sync(); -#ifdef __KLIBC__ - unlink(devname); -#else - endmntent(mtab); -#endif - - if ( rv ) return rv; - - return 0; + return rv; } int |