Applied patch from Larry Doolittle to fix '>\na\n' bug. Should close bug #1132
[oweals/busybox.git] / mtab.c
diff --git a/mtab.c b/mtab.c
index 27489cfd4ba8e46732c99d8e03df0bee461a6be9..0497657758089d28cd60a1a93e7b1360fef580b7 100644 (file)
--- a/mtab.c
+++ b/mtab.c
@@ -1,16 +1,14 @@
 /* vi: set sw=4 ts=4: */
-#include "internal.h"
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
 #include <mntent.h>
-#include <fstab.h>
-#include <sys/mount.h>
+#include "busybox.h"
 
 extern const char mtab_file[]; /* Defined in utility.c */
-
+static const int MS_RDONLY = 1;        /* Mount read-only.  */
 
 void erase_mtab(const char *name)
 {
@@ -21,13 +19,9 @@ void erase_mtab(const char *name)
 
        /* Check if reading the mtab file failed */
        if (mountTable == 0
-#if ! defined BB_FEATURE_USE_PROCFS
-               ) {
-#else
-               /* Bummer.  fall back on trying the /proc filesystem */
-               && (mountTable = setmntent("/proc/mounts", "r")) == 0) {
-#endif
-               perror(mtab_file);
+                       /* Bummer.  fall back on trying the /proc filesystem */
+                       && (mountTable = setmntent("/proc/mounts", "r")) == 0) {
+               perror_msg("%s", mtab_file);
                return;
        }
 
@@ -55,7 +49,7 @@ void erase_mtab(const char *name)
                }
                endmntent(mountTable);
        } else if (errno != EROFS)
-               perror(mtab_file);
+               perror_msg("%s", mtab_file);
 }
 
 void write_mtab(char *blockDevice, char *directory,
@@ -65,7 +59,7 @@ void write_mtab(char *blockDevice, char *directory,
        struct mntent m;
 
        if (mountTable == 0) {
-               perror(mtab_file);
+               perror_msg("%s", mtab_file);
                return;
        }
        if (mountTable) {
@@ -74,14 +68,12 @@ void write_mtab(char *blockDevice, char *directory,
                if (length > 1 && directory[length - 1] == '/')
                        directory[length - 1] = '\0';
 
-#ifdef BB_FEATURE_USE_PROCFS
                if (filesystemType == 0) {
-                       struct mntent *p = findMountPoint(blockDevice, "/proc/mounts");
+                       struct mntent *p = find_mount_point(blockDevice, "/proc/mounts");
 
                        if (p && p->mnt_type)
                                filesystemType = p->mnt_type;
                }
-#endif
                m.mnt_fsname = blockDevice;
                m.mnt_dir = directory;
                m.mnt_type = filesystemType ? filesystemType : "default";