From df66588b0f6daf99573153cb384a676ced27f0b1 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 3 Dec 2013 17:46:58 +0100 Subject: trans: fix the creation of files in fakeroot Previously, fakeroot failed to create files in certain circumstances, e. g. assuming /tmp is a tmpfs and /tmp/some_file does not exist: % cd /tmp && fakeroot-hurd /bin/sh -c ':>/tmp/some_file' /bin/sh: 1: cannot create /tmp/some_file: Is a directory Fix this by sanitizing the flags value not to contain O_WRITE if we're not at the last path component. * trans/fakeroot.c (netfs_S_dir_lookup): Strip O_WRITE from flags when looking up all but the last path component. --- trans/fakeroot.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'trans') diff --git a/trans/fakeroot.c b/trans/fakeroot.c index 679e4765..b6938dce 100644 --- a/trans/fakeroot.c +++ b/trans/fakeroot.c @@ -307,6 +307,10 @@ netfs_S_dir_lookup (struct protid *diruser, /* We already know about this node. */ mach_port_deallocate (mach_task_self (), idport); pthread_mutex_lock (&np->lock); + if (retry_name[0] != '\0') + /* This was not the last component, remove O_WRITE to + avoid opening directories with it. */ + flags &= ~O_WRITE; err = check_openmodes (np->nn, (flags & (O_RDWR|O_EXEC)), file); if (!err) netfs_nref (np); -- cgit v1.2.3