All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-lvm] Reduced dependecies for /root on lvm
@ 2000-01-31 12:37 Klaus Strebel
  2000-01-31 14:32 ` Andi Kleen
  0 siblings, 1 reply; 3+ messages in thread
From: Klaus Strebel @ 2000-01-31 12:37 UTC (permalink / raw)
  To: linux-lvm

[-- Attachment #1: Type: text/plain, Size: 885 bytes --]

Hi all,

i found, that the vgscan and vgchange commands, needed for activation of
volumes, depend on shared libc and ld-loader in the initrd. Even if
these two are linked static, there remains a dependecie, due to a
system() call of the 'rm -rf' command. I added a little routine to do
this task to liblvm, removed the system(rm...) calls and changed the
tools/Makefile to link vgscan.static and vgchange.static.
I did'n change lvmcreate_initrd 'cause i still do this by hand (sorry
;-)).
It works for me, my initrd is much smaller now (stripped the executables
;-)), there are less pof's (point-of-failure) when trying to install
with root on a lv.
Comments and bugreports are welcome.

Ciao
Klaus
-- 
Klaus Strebel
stb@ep-ag.com
EIGNER + PARTNER AG   - The Engineering Warehouse Company -
<http://www.ep-ag.com>
-----------------------------------------------------------------------

[-- Attachment #2: lvm_tools.0.8.ks.patch --]
[-- Type: application/octet-stream, Size: 8341 bytes --]

diff -urN 0.8-pre02.10.1999/tools/Makefile 0.8-pre.ks/tools/Makefile
--- 0.8-pre02.10.1999/tools/Makefile	Sat Oct  2 12:59:41 1999
+++ 0.8-pre.ks/tools/Makefile	Mon Jan 31 12:47:55 2000
@@ -29,14 +29,14 @@
 #
 # uncomment next line and comment out XLINKER
 # if you like binding with static LVM library
-## LIBS = $(TOP)/tools/lib/liblvm.a
+STATLIBS = $(TOP)/tools/lib/liblvm.a
 XLINKER = -Xlinker -rpath $(TOP)/tools/lib -Xlinker -rpath /lib -Xlinker -rpath /usr/lib -llvm
 
 include ../make.tmpl
 include tools_and_lib.make.tmpl
 
 LDFLAGS = $(LIBS) -L$(TOP)/tools/lib $(XLINKER)
-ALL = $(ALL_SOURCES:.c=)
+ALL = $(ALL_SOURCES:.c=) vgscan.static vgchange.static
 ALL_RM = $(ALL) $(ALL_OBJECTS)
 ALL_SCRIPTS = lvmcreate_initrd
 
@@ -44,34 +44,40 @@
 
 $(ALL_OBJECTS):	Makefile lib/liblvm.h lvm_user.h
 
+vgscan.static: vgscan.o $(STATLIBS)
+		$(CC) -static $(LDFLAGS) -o $@ vgscan.o $(STATLIBS)
+ 
+vgchange.static: vgchange.o $(STATLIBS)
+		$(CC) -static $(LDFLAGS) -o $@ vgchange.o $(STATLIBS)
+ 
 all_this:	$(ALL_OBJECTS) $(ALL) $(ALL_SOURCES) $(ALL_HEADERS) $(OTHER_DEP) $(LIBS)
 		@echo ""
 		@echo "Done Tools parts"
 		@echo ""
 
 
-strip:		$(ALL_TARGETS)
+strip:		$(ALL_TARGETS) vgscan.static vgchange.static 
 	@echo
 	@echo "Stripping all executables..."
 	@echo
-	@strip $(ALL_TARGETS) >/dev/null 2>&1
+	@strip $(ALL_TARGETS) vgscan.static vgchange.static >/dev/null 2>&1
 
 list:		$(ALL_TARGETS)
 	@ls -l $(ALL_TARGETS)
 
 l:	list
 
-install-bin:	$(ALL_TARGETS) $(ALL_SCRIPTS)
-	@echo "*** Installing $(ALL_TARGETS) $(ALL_SCRIPTS) in $(BINDIR) ***"
-	@for f in $(ALL_TARGETS) $(ALL_SCRIPTS); \
+install-bin:	$(ALL_TARGETS) $(ALL_SCRIPTS) vgscan.static vgchange.static 
+	@echo "*** Installing $(ALL_TARGETS) $(ALL_SCRIPTS) vgscan.static vgchange.static in $(BINDIR) ***"
+	@for f in $(ALL_TARGETS) $(ALL_SCRIPTS) vgscan.static vgchange.static; \
 	do \
   	   rm -f $(BINDIR)/$$f; \
 	   install -o root -g root -m 555 -s $$f $(BINDIR)/$$f; \
 	done
 
-remove-bin:	$(ALL_TARGETS) $(ALL_SCRIPTS)
-	@echo "*** Removing $(ALL_TARGETS) $(ALL_SCRIPTS) from $(BINDIR) ***"
-	@for f in $(ALL_TARGETS) $(ALL_SCRIPTS); \
+remove-bin:	$(ALL_TARGETS) $(ALL_SCRIPTS) vgscan.static vgchange.static
+	@echo "*** Removing $(ALL_TARGETS) $(ALL_SCRIPTS) vgscan.static vgchange.static from $(BINDIR) ***"
+	@for f in $(ALL_TARGETS) $(ALL_SCRIPTS) vgscan.static vgchange.static; \
 	do \
 	   rm -f $(BINDIR)/$$f; \
 	done
diff -urN 0.8-pre02.10.1999/tools/lib/liblvm.h 0.8-pre.ks/tools/lib/liblvm.h
--- 0.8-pre02.10.1999/tools/lib/liblvm.h	Sat Oct  2 12:59:41 1999
+++ 0.8-pre.ks/tools/lib/liblvm.h	Mon Jan 31 13:07:46 2000
@@ -421,7 +421,7 @@
 int  lvm_tab_vg_check_exist ( char *, vg_t **);
 int  lvm_tab_get_free_blk_dev ( kdev_t **);
 char **lvm_tab_vg_check_exist_all_vg ( void);
-
+int  lvm_rm_rf (char *);
 
 /* return codes */
 #define LVM_VG_CFGBACKUP_NO_DIFF                                           100
diff -urN 0.8-pre02.10.1999/tools/lib/lvm_rm_rf.c 0.8-pre.ks/tools/lib/lvm_rm_rf.c
--- 0.8-pre02.10.1999/tools/lib/lvm_rm_rf.c	Thu Jan  1 01:00:00 1970
+++ 0.8-pre.ks/tools/lib/lvm_rm_rf.c	Mon Jan 31 13:07:29 2000
@@ -0,0 +1,59 @@
+/*
+ * tools/lib/lvm_rm_rf.c
+ *
+ * Copyright (C)  1998  Heinz Mauelshagen, Germany
+ *
+ * August 1998
+ *
+ *
+ * This LVM library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This LVM library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this LVM library; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA
+ *
+ */
+
+#include <liblvm.h>
+
+#include <dirent.h>
+
+int lvm_rm_rf (char *dirname)
+{
+	DIR *dir_pointer;
+	struct dirent *dp;
+	int my_err;
+
+	if (dirname != NULL && strlen(dirname) > 0)
+	{	
+		my_err=unlink(dirname);
+		if (my_err == 0) return 0;
+		if (unlink(dirname) != EISDIR) return my_err;
+
+		dir_pointer = opendir(dirname);
+		for (dp = readdir(dir_pointer); dp != NULL; 
+		     dp = readdir(dir_pointer)) {
+       			if (dp->d_type = DT_DIR)
+				my_err=lvm_rm_rf (dp->d_name);
+			else
+				my_err=unlink (dp->d_name);
+
+			if (my_err != NULL)
+				continue;
+		}	
+		closedir(dir_pointer);
+                if (my_err != NULL) return my_err;
+		return rmdir(dirname);
+	}	
+        return 0;
+}	
+
diff -urN 0.8-pre02.10.1999/tools/lib/lvm_tab_vg_check_exist_all_vg.c 0.8-pre.ks/tools/lib/lvm_tab_vg_check_exist_all_vg.c
--- 0.8-pre02.10.1999/tools/lib/lvm_tab_vg_check_exist_all_vg.c	Sat Oct  2 12:59:42 1999
+++ 0.8-pre.ks/tools/lib/lvm_tab_vg_check_exist_all_vg.c	Wed Jan 12 19:39:38 2000
@@ -91,10 +91,13 @@
 #ifdef DEBUG
    debug ( "lvm_tab_vg_check_exist_all_vg -- LEAVING with ret: %d\n", ret);
 #endif
-   if ( ret < 0 || size < 2) {
-      free ( data);
-      if ( vg_name_ptr     != NULL) free ( vg_name_ptr);
-      if ( vg_name_ptr_sav != NULL) free ( vg_name_ptr_sav);
+if ( ret < 0 || size < 2) {
+      if ( data != NULL) {
+         free ( data);
+         data = NULL;
+      }
+      if ( vg_name_ptr     != NULL)      free ( vg_name_ptr);
+      else if ( vg_name_ptr_sav != NULL) free ( vg_name_ptr_sav);
    }
 
    return vg_name_ptr;
diff -urN 0.8-pre02.10.1999/tools/lib/lvm_tab_vg_remove.c 0.8-pre.ks/tools/lib/lvm_tab_vg_remove.c
--- 0.8-pre02.10.1999/tools/lib/lvm_tab_vg_remove.c	Sat Oct  2 12:59:42 1999
+++ 0.8-pre.ks/tools/lib/lvm_tab_vg_remove.c	Mon Jan 31 13:16:19 2000
@@ -83,8 +83,8 @@
          }
 
          if ( ( ret = lvm_tab_write ( data, size)) == 0) {
-            sprintf ( command, "rm -f %s/%s%c", LVMTAB_DIR, vg_name, 0);
-            ret = system ( command);
+            sprintf ( command, "%s/%s%c", LVMTAB_DIR, vg_name, 0);
+            ret = lvm_rm_rf ( command);
          }
       }
    }
diff -urN 0.8-pre02.10.1999/tools/lib/vg_create_dir_and_group.c 0.8-pre.ks/tools/lib/vg_create_dir_and_group.c
--- 0.8-pre02.10.1999/tools/lib/vg_create_dir_and_group.c	Sat Oct  2 12:59:42 1999
+++ 0.8-pre.ks/tools/lib/vg_create_dir_and_group.c	Thu Jan 20 17:07:58 2000
@@ -48,8 +48,8 @@
 
    if ( vg == NULL || vg_check_name ( vg->vg_name) < 0) return -LVM_EPARAM;
 
-   sprintf ( name, "rm -fr " LVM_DIR_PREFIX "%s%c", vg->vg_name, 0);
-   system ( name);
+   sprintf ( name, "%s%s%c", LVM_DIR_PREFIX, vg->vg_name, 0);
+   lvm_rm_rf ( name);
    mkdir ( LVM_DIR_PREFIX, 0555);
    sprintf ( name, LVM_DIR_PREFIX "%s%c", vg->vg_name, 0);
    if ( mkdir ( name, 0555) == -1) ret = -LVM_EVG_CREATE_DIR_AND_GROUP_MKDIR;
diff -urN 0.8-pre02.10.1999/tools/lib/vg_remove_dir_and_group_and_nodes.c 0.8-pre.ks/tools/lib/vg_remove_dir_and_group_and_nodes.c
--- 0.8-pre02.10.1999/tools/lib/vg_remove_dir_and_group_and_nodes.c	Sat Oct  2 12:59:42 1999
+++ 0.8-pre.ks/tools/lib/vg_remove_dir_and_group_and_nodes.c	Mon Jan 31 13:18:15 2000
@@ -36,12 +36,12 @@
    if ( vg_name == NULL || vg_check_name ( vg_name) < 0) return -LVM_EPARAM;
 
    /* remove the volume group directory */
-   sprintf ( system_buffer, "rm -fr " LVM_DIR_PREFIX "%s%c", vg_name, 0);
+   sprintf ( system_buffer, "%s%s%c", LVM_DIR_PREFIX, vg_name, 0);
 
 #ifdef DEBUG
    debug ( "vg_remove_dir_and_group_and_nodes -- LEAVING\n");
 #endif
 
-   return system ( system_buffer);
+   return (lvm_rm_rf (system_buffer));
 }
    
diff -urN 0.8-pre02.10.1999/tools/vgscan.c 0.8-pre.ks/tools/vgscan.c
--- 0.8-pre02.10.1999/tools/vgscan.c	Sat Oct  2 12:59:42 1999
+++ 0.8-pre.ks/tools/vgscan.c	Mon Jan 31 13:02:21 2000
@@ -185,8 +185,10 @@
 
    if ( opt_v > 0) printf ( "%s -- removing \"%s\" and \"%s\"\n",
                             cmd, LVMTAB, LVMTAB_DIR);
-   sprintf ( command, "rm -fr %s %s%c", LVMTAB, LVMTAB_DIR, 0);
-   system ( command);
+   sprintf ( command, "%s%c", LVMTAB, 0);
+   lvm_rm_rf ( command);
+   sprintf ( command, "%s%c", LVMTAB_DIR, 0);
+   lvm_rm_rf ( command);
 
    printf ( "%s -- reading all physical volumes (this may take a while...)\n",
             cmd);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-02-01 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-01-31 12:37 [linux-lvm] Reduced dependecies for /root on lvm Klaus Strebel
2000-01-31 14:32 ` Andi Kleen
2000-02-01 16:07   ` Klaus Strebel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.