aboutsummaryrefslogtreecommitdiffstats
path: root/extlinux
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-08-24 22:18:34 -0700
committerH. Peter Anvin <hpa@zytor.com>2006-08-24 22:18:34 -0700
commit6582bed72ada9ff9154c463c6cd6393d3548b282 (patch)
tree28aa93eae8159cd8fb52ed4db818e7c9ed3e55cf /extlinux
parenta7179414798e28720e25d4a1346a765a521c4fbe (diff)
downloadsyslinux.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.c41
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