hrev51294 adds 1 changeset to branch 'master'
old head: 84edb1a177c32dd651ecf3234559d492a867edb4
new head: a1eceb461039d6f9d6e88006a70920be92b300ef
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=a1eceb461039+%5E84edb1a177c3
----------------------------------------------------------------------------
a1eceb461039: rootfs: directories must not be opened writable.
* Also added support for O_DIRECTORY while at it.
* This fixes bug #13573.
[ Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev51294
Commit: a1eceb461039d6f9d6e88006a70920be92b300ef
URL: http://cgit.haiku-os.org/haiku/commit/?id=a1eceb461039
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Thu Jul 20 08:10:20 2017 UTC
Ticket: https://dev.haiku-os.org/ticket/13573
----------------------------------------------------------------------------
1 file changed, 9 insertions(+), 2 deletions(-)
src/system/kernel/fs/rootfs.cpp | 11 +++++++++--
----------------------------------------------------------------------------
diff --git a/src/system/kernel/fs/rootfs.cpp b/src/system/kernel/fs/rootfs.cpp
index 21214fa..61678a6 100644
--- a/src/system/kernel/fs/rootfs.cpp
+++ b/src/system/kernel/fs/rootfs.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * Copyright 2002-2017, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
* Distributed under the terms of the MIT License.
*
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -583,8 +583,15 @@ rootfs_create(fs_volume* _volume, fs_vnode* _dir, const
char* name, int omode,
static status_t
-rootfs_open(fs_volume* _volume, fs_vnode* _v, int oflags, void** _cookie)
+rootfs_open(fs_volume* _volume, fs_vnode* _v, int openMode, void** _cookie)
{
+ struct rootfs_vnode* vnode = (rootfs_vnode*)_v->private_node;
+
+ if (S_ISDIR(vnode->stream.type) && (openMode & O_RWMASK) != O_RDONLY)
+ return B_IS_A_DIRECTORY;
+ if ((openMode & O_DIRECTORY) != 0 && !S_ISDIR(vnode->stream.type))
+ return B_NOT_A_DIRECTORY;
+
// allow to open the file, but it can't be done anything with it
*_cookie = NULL;