hal/tools fstab-sync.c,1.18,1.19

David Zeuthen david at freedesktop.org
Tue Aug 31 16:40:24 PDT 2004


Update of /cvs/hal/hal/tools
In directory gabe:/tmp/cvs-serv3421/tools

Modified Files:
	fstab-sync.c 
Log Message:
2004-09-01  David Zeuthen  <david at fubar.dk>

	* tools/fstab-sync.c (fs_table_line_is_mounted): New function
	(fs_table_remove_generated_entries): Don't remove generated entries
	that are in use (e.g device mounted at path). Fixes problem with
	restarting the hal daemon with devices mounted (e.g. on package
	upgrade etc.)

	* hald/callout.c (process_callouts): Print full path of callout



Index: fstab-sync.c
===================================================================
RCS file: /cvs/hal/hal/tools/fstab-sync.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- fstab-sync.c	31 Aug 2004 01:34:27 -0000	1.18
+++ fstab-sync.c	31 Aug 2004 23:40:22 -0000	1.19
@@ -1668,6 +1668,32 @@
   return FALSE;
 }
 
+static boolean fs_table_line_is_mounted (FSTableLine *line)
+{
+  FILE *f;
+  boolean is_mounted = FALSE;
+  struct mntent *m;
+
+  f = fopen (_PATH_MOUNTED, "r");
+  if (f == NULL)
+    goto out;
+
+  while ((m = getmntent (f)) != NULL) {
+
+    if (strcmp (m->mnt_fsname, line->block_device) == 0 && 
+	strcmp (m->mnt_dir, line->mount_point) == 0) {
+      is_mounted = TRUE;
+      goto out;
+    }
+  }
+
+out:
+  if (f != NULL)
+    fclose (f);
+
+  return is_mounted;
+}
+
 static void
 fs_table_remove_generated_entries (FSTable *table)
 {
@@ -1677,8 +1703,10 @@
   line = table->lines;
   while (line != NULL)
     {
-      if (fs_table_line_is_generated (line))
+      /* don't remove generated line if device is mounted there */
+      if (fs_table_line_is_generated (line) && !fs_table_line_is_mounted (line))
         {
+
 	  if (rmdir (line->mount_point) < 0)
 	    {
 	      fstab_update_debug (_("%d: Failed to remove mount point '%s': %s\n"),




More information about the hal-commit mailing list