diff options
-rw-r--r-- | hurd/lookup-at.c | 21 | ||||
-rw-r--r-- | sysdeps/mach/hurd/bits/fcntl.h | 4 |
2 files changed, 25 insertions, 0 deletions
diff --git a/hurd/lookup-at.c b/hurd/lookup-at.c index 25dab5a..88c8377 100644 --- a/hurd/lookup-at.c +++ b/hurd/lookup-at.c @@ -29,6 +29,7 @@ __file_name_lookup_at (int fd, int at_flags, error_t err; file_t result; int empty = at_flags & AT_EMPTY_PATH; + int orig_flags; at_flags &= ~AT_EMPTY_PATH; @@ -53,6 +54,10 @@ __file_name_lookup_at (int fd, int at_flags, return err ? (__hurd_dfail (fd, err), MACH_PORT_NULL) : result; } + orig_flags = flags; + if (flags & O_TMPFILE) + flags = O_DIRECTORY; + if (fd == AT_FDCWD || file_name[0] == '/') { err = __hurd_file_name_lookup (&_hurd_ports_use, &__getdport, 0, @@ -90,6 +95,22 @@ __file_name_lookup_at (int fd, int at_flags, } } + if (orig_flags & O_TMPFILE) + { + /* What we have looked up is not the file itself, but actually + the directory to create the file in. Do that now. */ + file_t dir = result; + + err = __dir_mkfile (dir, orig_flags & ~(O_TMPFILE | O_DIRECTORY), + mode, &result); + __mach_port_deallocate (__mach_task_self (), dir); + if (err) + { + __hurd_fail (err); + return MACH_PORT_NULL; + } + } + return result; } diff --git a/sysdeps/mach/hurd/bits/fcntl.h b/sysdeps/mach/hurd/bits/fcntl.h index 970f79b..c24a819 100644 --- a/sysdeps/mach/hurd/bits/fcntl.h +++ b/sysdeps/mach/hurd/bits/fcntl.h @@ -123,6 +123,10 @@ # define O_CLOEXEC 0x00400000 /* Set FD_CLOEXEC. */ #endif +#ifdef __USE_GNU +# define O_TMPFILE 0x00800000 /* Make a new unnamed file. */ +#endif + /* Controlling terminal flags. These are understood only by `open', and are not preserved once the file has been opened. */ |