diff options
| author | Ray Strode <rstrode@redhat.com> | 2007-06-13 18:15:27 -0400 |
|---|---|---|
| committer | Ray Strode <rstrode@redhat.com> | 2007-06-13 18:15:27 -0400 |
| commit | 6e06a88f7363804b0ab8b548f29b06206f144272 (patch) | |
| tree | 977194c8086ba8d85ea20e0a305a72d744ab83fb /src/libply/ply-utils.c | |
| parent | 3ac8809ce928643fdeb854fd28ea29dec79aef85 (diff) | |
| download | plymouth-6e06a88f7363804b0ab8b548f29b06206f144272.tar.gz plymouth-6e06a88f7363804b0ab8b548f29b06206f144272.tar.xz plymouth-6e06a88f7363804b0ab8b548f29b06206f144272.zip | |
change ply_create_scratch directory to be a two step,
ply_create_detachable_directory/ply_detach_directory process,
because the former semantics couldn't actually work
Diffstat (limited to 'src/libply/ply-utils.c')
| -rw-r--r-- | src/libply/ply-utils.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c index f98f21a..0467b78 100644 --- a/src/libply/ply-utils.c +++ b/src/libply/ply-utils.c @@ -659,18 +659,26 @@ 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) @@ -678,19 +686,25 @@ ply_create_scratch_directory (const char *directory) 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); + ply_restore_errno (); 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 |
