]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
change ply_create_scratch directory to be a two step,
authorRay Strode <rstrode@redhat.com>
Wed, 13 Jun 2007 22:15:27 +0000 (18:15 -0400)
committerRay Strode <rstrode@redhat.com>
Wed, 13 Jun 2007 22:15:27 +0000 (18:15 -0400)
ply_create_detachable_directory/ply_detach_directory process,
because the former semantics couldn't actually work

src/libply/ply-utils.c
src/libply/ply-utils.h

index f98f21a690e5458ae9b380c3e3e9853366a44779..0467b78e5a43173370c951e4eb3f073dd4e44aca 100644 (file)
@@ -659,21 +659,37 @@ ply_create_directory (const char *directory)
 }
 
 bool 
-ply_create_scratch_directory (const char *directory)
+ply_create_detachable_directory (const char *directory)
 {
-  int dir_fd;
+
   assert (directory != NULL);
   assert (directory[0] != '\0');
   
   if (!ply_create_directory (directory))
     return false;
 
-  if (mount ("none", directory, "ramfs", 0, NULL) < 0)
+  if (mount ("none", directory, "tmpfs", 0, NULL) < 0)
     return false;
 
+  return true;
+}
+
+int
+ply_detach_directory (const char *directory)
+{
+  int dir_fd;
+
   dir_fd = open (directory, O_RDONLY);
 
   if (dir_fd < 0)
+    {
+      ply_save_errno ();
+      umount (directory);
+      ply_restore_errno ();
+      return dir_fd;
+    }
+
+  if (umount2 (directory, PLY_SUPER_SECRET_LAZY_UNMOUNT_FLAG) < 0)
     {
       ply_save_errno ();
       umount (directory);
@@ -681,16 +697,14 @@ ply_create_scratch_directory (const char *directory)
       return false;
     }
 
-  umount2 (directory, PLY_SUPER_SECRET_LAZY_UNMOUNT_FLAG);
+  rmdir (directory);
 
-  /* contents of directory will remain visible to process
-   * (and children) until the file descriptor is closed.
-   *
-   * We're leaking the file descriptor below, so it will
-   * remain around until the process exits
+  /* return a file descriptor to the directory because it's now been
+   * detached from the filesystem.  The user can fchdir to this
+   * directory and work from it that way
    */
 
-  return true;
+  return dir_fd;
 }
 
 static bool
index ff545dd1c9fa9855776a953aa3139546d888ff31..ec46fef2618509290ea93b2fe3444bfc12674184 100644 (file)
@@ -69,8 +69,6 @@ void ply_restore_errno (void);
 
 bool ply_directory_exists (const char *dir);
 bool ply_file_exists (const char *file);
-bool ply_file_system_is_mounted (const char *type,
-                                 const char *path);
 
 ply_module_handle_t *ply_open_module (const char *module_path);
 ply_module_function_t ply_module_look_up_function (ply_module_handle_t *handle,
@@ -78,8 +76,10 @@ ply_module_function_t ply_module_look_up_function (ply_module_handle_t *handle,
 void ply_close_module (ply_module_handle_t *handle);
 
 bool ply_create_directory (const char *directory);
-bool ply_create_scratch_directory (const char *directory);
-
+bool ply_create_detachable_directory (const char *directory);
+int ply_detach_directory (const char *directory);
+bool ply_copy_file (const char *source, const char *destination);
+bool ply_copy_directory (const char *source, const char *destination);
 #endif
 
 #endif /* PLY_UTILS_H */