From 61784ba644ae4798e454564a98ac847e69da13ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 16 Dec 2004 02:32:56 +0000 Subject: [PATCH] The DataEditor class now only redirects root directories to volumes; it can now also open directories and symlinks, in which case nothing can be done (but theoretically, the attributes could be changed). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10472 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/diskprobe/DataEditor.cpp | 42 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/apps/diskprobe/DataEditor.cpp b/src/apps/diskprobe/DataEditor.cpp index c95cbd9611..5749ffd9f5 100644 --- a/src/apps/diskprobe/DataEditor.cpp +++ b/src/apps/diskprobe/DataEditor.cpp @@ -1,13 +1,14 @@ -/* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ +/* + * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ #include "DataEditor.h" #include #include +#include #include #include #include @@ -408,23 +409,27 @@ DataEditor::SetTo(BEntry &entry, const char *attribute) bool isFileSystem = false; + fBlockSize = 512; + if (entry.IsDirectory()) { - // we redirect directories to their volumes - fs_info info; - if (fs_stat_dev(stat.st_dev, &info) != 0) - return errno; + // we redirect root directories to their volumes + BDirectory directory(&entry); + if (directory.InitCheck() == B_OK && directory.IsRootDirectory()) { + fs_info info; + if (fs_stat_dev(stat.st_dev, &info) != 0) + return errno; - status = entry.SetTo(info.device_name); - if (status < B_OK) - return status; + status = entry.SetTo(info.device_name); + if (status < B_OK) + return status; - entry.GetStat(&stat); + entry.GetStat(&stat); - fBlockSize = info.block_size; - if (fBlockSize > 0 && fBlockSize <= 65536) - isFileSystem = true; - } else - fBlockSize = 512; + fBlockSize = info.block_size; + if (fBlockSize > 0 && fBlockSize <= 65536) + isFileSystem = true; + } + } status = fFile.SetTo(&entry, B_READ_WRITE); if (status < B_OK) { @@ -472,6 +477,9 @@ DataEditor::SetTo(BEntry &entry, const char *attribute) if (!isFileSystem) fBlockSize = geometry.bytes_per_sector; + } else if (entry.IsDirectory() || entry.IsSymLink()) { + fSize = 0; + fIsReadOnly = true; } else { status = fFile.GetSize(&fSize); if (status < B_OK) {