[patch] merge mtab_file.c into messages.c and provide fstab_file

Bernhard Fischer rep.nop at aon.at
Thu Mar 30 12:06:42 UTC 2006


Hi,

Attached patch merges libbb/mtab_file.c into libbb/messages.c
It also adds a bb_path_fstab_file and peruses it where apporpriate.

If you apply this, please don't forget to svn rm libbb/mtab_file.c

Objections or comments?

-------------- next part --------------
Index: e2fsprogs/fsck.c
===================================================================
--- e2fsprogs/fsck.c	(revision 14700)
+++ e2fsprogs/fsck.c	(working copy)
@@ -49,7 +49,7 @@
 #include "busybox.h"
 
 #ifndef _PATH_MNTTAB
-#define _PATH_MNTTAB    "/etc/fstab"
+#define _PATH_MNTTAB    bb_path_fstab_file
 #endif
 
 /*
Index: libbb/Makefile.in
===================================================================
--- libbb/Makefile.in	(revision 14700)
+++ libbb/Makefile.in	(working copy)
@@ -20,7 +20,7 @@
 	herror_msg.c herror_msg_and_die.c \
 	human_readable.c inet_common.c inode_hash.c isdirectory.c \
 	kernel_version.c last_char_is.c login.c \
-	make_directory.c md5.c mode_string.c mtab_file.c \
+	make_directory.c md5.c mode_string.c \
 	obscure.c parse_mode.c parse_number.c perror_msg.c \
 	perror_msg_and_die.c print_file.c get_console.c \
 	process_escape_sequence.c procps.c qmodule.c \
@@ -36,7 +36,7 @@
 	warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
 	bb_echo.c bb_do_delay.c
 
-# conditionally compiled objects:
+# conditionally compiled single-file objects:
 LIBBB-$(CONFIG_FEATURE_SHADOWPASSWDS)+=pwd2spwd.c
 LIBBB-$(CONFIG_FEATURE_MOUNT_LOOP)+= loop.c
 LIBBB-$(CONFIG_LOSETUP)+= loop.c
@@ -53,7 +53,7 @@
 
 # 1:N objects
 LIBBB_MSRC0:=$(srcdir)/messages.c
-LIBBB_MOBJ0:=full_version.o \
+LIBBB_MOBJ0-y:=full_version.o \
 	memory_exhausted.o invalid_date.o io_error.o \
 	read_error.o write_error.o name_longer_than_foo.o unknown.o \
 	can_not_create_raw_socket.o perm_denied_are_you_root.o \
@@ -61,53 +61,60 @@
 	securetty_file.o motd_file.o \
 	msg_standard_input.o msg_standard_output.o shell_file.o \
 	bb_dev_null.o bb_common_bufsiz1.o
-LIBBB_MOBJ0:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ0))
-$(LIBBB_MOBJ0):$(LIBBB_MSRC0)
+LIBBB_MOBJ0-$(CONFIG_FSCK)	+= fstab_file.o
+LIBBB_MOBJ0-$(CONFIG_MOUNT)	+= fstab_file.o
+LIBBB_MOBJ0-$(CONFIG_SWAPONOFF)	+= fstab_file.o
+LIBBB_MOBJ0-$(CONFIG_DF)	+= mtab_file.o
+LIBBB_MOBJ0-$(CONFIG_EJECT)	+= mtab_file.o
+LIBBB_MOBJ0-$(CONFIG_MOUNT)	+= mtab_file.o
+LIBBB_MOBJ0-$(CONFIG_UMOUNT)	+= mtab_file.o
+LIBBB_MOBJ0-y:=$(patsubst %,$(LIBBB_DIR)/%,$(sort $(LIBBB_MOBJ0-y)))
+$(LIBBB_MOBJ0-y):$(LIBBB_MSRC0)
 	$(compile.c) -DL_$(notdir $*)
 
 LIBBB_MSRC1:=$(srcdir)/xfuncs.c
-LIBBB_MOBJ1:=xmalloc.o xrealloc.o xcalloc.o xstrdup.o xstrndup.o \
+LIBBB_MOBJ1-y:=xmalloc.o xrealloc.o xcalloc.o xstrdup.o xstrndup.o \
 	xfopen.o xopen.o xread.o xread_all.o xread_char.o \
 	xferror.o xferror_stdout.o xfflush_stdout.o strlen.o
-LIBBB_MOBJ1:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ1))
-$(LIBBB_MOBJ1):$(LIBBB_MSRC1)
+LIBBB_MOBJ1-y:=$(patsubst %,$(LIBBB_DIR)/%,$(sort $(LIBBB_MOBJ1-y)))
+$(LIBBB_MOBJ1-y):$(LIBBB_MSRC1)
 	$(compile.c) -DL_$(notdir $*)
 
 LIBBB_MSRC2:=$(srcdir)/printf.c
-LIBBB_MOBJ2:=bb_vfprintf.o bb_vprintf.o bb_fprintf.o bb_printf.o
-LIBBB_MOBJ2:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ2))
-$(LIBBB_MOBJ2):$(LIBBB_MSRC2)
+LIBBB_MOBJ2-y:=bb_vfprintf.o bb_vprintf.o bb_fprintf.o bb_printf.o
+LIBBB_MOBJ2-y:=$(patsubst %,$(LIBBB_DIR)/%,$(sort $(LIBBB_MOBJ2-y)))
+$(LIBBB_MOBJ2-y):$(LIBBB_MSRC2)
 	$(compile.c) -DL_$(notdir $*)
 
 LIBBB_MSRC3:=$(srcdir)/xgetularg.c
-LIBBB_MOBJ3:=xgetularg_bnd_sfx.o xgetlarg_bnd_sfx.o getlarg10_sfx.o \
+LIBBB_MOBJ3-y:=xgetularg_bnd_sfx.o xgetlarg_bnd_sfx.o getlarg10_sfx.o \
 	xgetularg_bnd.o xgetularg10_bnd.o xgetularg10.o
-LIBBB_MOBJ3:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ3))
-$(LIBBB_MOBJ3):$(LIBBB_MSRC3)
+LIBBB_MOBJ3-y:=$(patsubst %,$(LIBBB_DIR)/%,$(sort $(LIBBB_MOBJ3-y)))
+$(LIBBB_MOBJ3-y):$(LIBBB_MSRC3)
 	$(compile.c) -DL_$(notdir $*)
 
 LIBBB_MSRC4:=$(srcdir)/safe_strtol.c
-LIBBB_MOBJ4:=safe_strtoi.o safe_strtod.o safe_strtol.o safe_strtoul.o
-LIBBB_MOBJ4:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ4))
-$(LIBBB_MOBJ4):$(LIBBB_MSRC4)
+LIBBB_MOBJ4-y:=safe_strtoi.o safe_strtod.o safe_strtol.o safe_strtoul.o
+LIBBB_MOBJ4-y:=$(patsubst %,$(LIBBB_DIR)/%,$(sort $(LIBBB_MOBJ4-y)))
+$(LIBBB_MOBJ4-y):$(LIBBB_MSRC4)
 	$(compile.c) -DL_$(notdir $*)
 
 LIBBB_MSRC5:=$(srcdir)/bb_pwd.c
-LIBBB_MOBJ5:=bb_xgetpwnam.o bb_xgetgrnam.o bb_getgrgid.o bb_getpwuid.o \
+LIBBB_MOBJ5-y:=bb_xgetpwnam.o bb_xgetgrnam.o bb_getgrgid.o bb_getpwuid.o \
 	bb_getug.o get_ug_id.o
-LIBBB_MOBJ5:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ5))
-$(LIBBB_MOBJ5):$(LIBBB_MSRC5)
+LIBBB_MOBJ5-y:=$(patsubst %,$(LIBBB_DIR)/%,$(sort $(LIBBB_MOBJ5-y)))
+$(LIBBB_MOBJ5-y):$(LIBBB_MSRC5)
 	$(compile.c) -DL_$(notdir $*)
 
 LIBBB_MSRC6:=$(srcdir)/llist.c
-LIBBB_MOBJ6:=llist_add_to.o llist_add_to_end.o llist_free_one.o llist_free.o
-LIBBB_MOBJ6:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ6))
-$(LIBBB_MOBJ6):$(LIBBB_MSRC6)
+LIBBB_MOBJ6-y:=llist_add_to.o llist_add_to_end.o llist_free_one.o llist_free.o
+LIBBB_MOBJ6-y:=$(patsubst %,$(LIBBB_DIR)/%,$(sort $(LIBBB_MOBJ6-y)))
+$(LIBBB_MOBJ6-y):$(LIBBB_MSRC6)
 	$(compile.c) -DL_$(notdir $*)
 
 
 # We need the names of the object files built from MSRC for the L_ defines
-LIBBB_ALL_MOBJ:=$(LIBBB_MOBJ0) $(LIBBB_MOBJ1) $(LIBBB_MOBJ2) $(LIBBB_MOBJ3) $(LIBBB_MOBJ4) $(LIBBB_MOBJ5) $(LIBBB_MOBJ6)
+LIBBB_ALL_MOBJ:=$(LIBBB_MOBJ0-y) $(LIBBB_MOBJ1-y) $(LIBBB_MOBJ2-y) $(LIBBB_MOBJ3-y) $(LIBBB_MOBJ4-y) $(LIBBB_MOBJ5-y) $(LIBBB_MOBJ6-y)
 
 LIBBB_ALL_MSRC:=$(LIBBB_MSRC0) $(LIBBB_MSRC1) $(LIBBB_MSRC2) $(LIBBB_MSRC3) \
 	$(LIBBB_MSRC4) $(LIBBB_MSRC5) $(LIBBB_MSRC6)
Index: libbb/mtab_file.c
===================================================================
--- libbb/mtab_file.c	(revision 14700)
+++ libbb/mtab_file.c	(working copy)
@@ -1,42 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Utility routines.
- *
- * Copyright (C) 1999-2004 by Erik Andersen <andersen at codepoet.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <stdio.h>
-#include "libbb.h"
-
-
-/* Busybox mount uses either /proc/mounts or /etc/mtab to
- * get the list of currently mounted filesystems */
-#if defined(CONFIG_FEATURE_MTAB_SUPPORT)
-const char bb_path_mtab_file[] = "/etc/mtab";
-#else
-const char bb_path_mtab_file[] = "/proc/mounts";
-#endif
-
-
-/* END CODE */
-/*
-Local Variables:
-c-file-style: "linux"
-c-basic-offset: 4
-tab-width: 4
-End:
-*/
Index: libbb/messages.c
===================================================================
--- libbb/messages.c	(revision 14700)
+++ libbb/messages.c	(working copy)
@@ -2,20 +2,7 @@
 /*
  * Copyright (C) 1999-2004 by Erik Andersen <andersen at codepoet.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
 #include "busybox.h"
@@ -106,6 +93,29 @@
 const char * const bb_dev_null = "/dev/null";
 #endif
 
+#ifdef L_fstab_file
+const char bb_path_fstab_file[] = "/etc/fstab";
+#endif
+
+#ifdef L_mtab_file
+/* Busybox mount uses either /proc/mounts or /etc/mtab to
+ * get the list of currently mounted filesystems */
+#if ENABLE_FEATURE_MTAB_SUPPORT
+const char bb_path_mtab_file[] = "/etc/mtab";
+#else
+const char bb_path_mtab_file[] = "/proc/mounts";
+#endif
+#endif
+
 #ifdef L_bb_common_bufsiz1
 char bb_common_bufsiz1[BUFSIZ+1];
 #endif
+
+/* END CODE */
+/*
+Local Variables:
+c-file-style: "linux"
+c-basic-offset: 4
+tab-width: 4
+End:
+*/
Index: include/libbb.h
===================================================================
--- include/libbb.h	(revision 14700)
+++ include/libbb.h	(working copy)
@@ -310,6 +310,10 @@
 extern const char * const bb_path_motd_file;
 extern const char * const bb_dev_null;
 
+extern const char bb_path_fstab_file[];
+extern const char bb_path_mtab_file[];
+
+
 #ifndef BUFSIZ
 #define BUFSIZ 4096
 #endif
@@ -329,9 +333,6 @@
 /* "sh" */
 #define DEFAULT_SHELL_SHORT_NAME     (bb_default_login_shell+6)
 
-
-extern const char bb_path_mtab_file[];
-
 extern int bb_default_error_retval;
 
 #ifdef CONFIG_FEATURE_DEVFS
Index: util-linux/swaponoff.c
===================================================================
--- util-linux/swaponoff.c	(revision 14700)
+++ util-linux/swaponoff.c	(working copy)
@@ -49,9 +49,9 @@
 	FILE *f;
 	int err;
 
-	f = setmntent("/etc/fstab", "r");
+	f = setmntent(bb_path_fstab_file, "r");
 	if (f == NULL)
-		bb_perror_msg_and_die("/etc/fstab");
+		bb_perror_msg_and_die(bb_path_fstab_file);
 
 	err = 0;
 	while ((m = getmntent(f)) != NULL)
Index: util-linux/mount.c
===================================================================
--- util-linux/mount.c	(revision 14700)
+++ util-linux/mount.c	(working copy)
@@ -462,7 +462,7 @@
 
 	if (parse_mount_options(cmdopts,0) & MS_REMOUNT)
 		fstabname = (char *)bb_path_mtab_file;  // Again with the evil const.
-	else fstabname="/etc/fstab";
+	else fstabname=bb_path_fstab_file;
 
 	if (!(fstab=setmntent(fstabname,"r")))
 		bb_perror_msg_and_die("Cannot read %s",fstabname);


More information about the busybox mailing list