From 8c5ad61d4bbe993c8758f1cc6007751dd132a4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 29 Aug 2009 10:43:51 +0000 Subject: [PATCH] * Prevent the /boot entry from ever being renamed. You couldn't even try to switch /boot to a different volume in two operations, unless you have first linked /system/lib into /bin. This patch assumes that / will always have the ID 1. Don't know if that is proper. Note that I also thought about solving this in the VFS, since perhaps it isn't the job of root-fs to know about /boot, but that would of course introduce another check for every rename operation, which I decided against. +alphabranch git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32806 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/rootfs.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/fs/rootfs.cpp b/src/system/kernel/fs/rootfs.cpp index b0147ec39b..bad69c96e6 100644 --- a/src/system/kernel/fs/rootfs.cpp +++ b/src/system/kernel/fs/rootfs.cpp @@ -930,9 +930,16 @@ rootfs_rename(fs_volume* _volume, fs_vnode* _fromDir, const char* fromName, struct rootfs_vnode* fromDirectory = (rootfs_vnode*)_fromDir->private_node; struct rootfs_vnode* toDirectory = (rootfs_vnode*)_toDir->private_node; - TRACE(("rootfs_rename: from %p (0x%Lx), fromName '%s', to %p (0x%Lx), " - "toName '%s'\n", fromDirectory, fromDirectory->id, fromName, toDirectory, - toDirectory->id, toName)); + TRACE(("rootfs_rename: from %p (0x%Lx, %s), fromName '%s', to %p " + "(0x%Lx, %s), toName '%s'\n", fromDirectory, fromDirectory->id, + fromDirectory->name != NULL ? fromDirectory->name : "NULL", + fromName, toDirectory, toDirectory->id, + toDirectory->name != NULL ? toDirectory->name : "NULL", + toName)); + + // Prevent renaming /boot, since that will stop everything from working. + if (fromDirectory->id == 1 && strcmp(fromName, "boot") == 0) + return EPERM; MutexLocker _(&fs->lock);