Improve the Read-Only mounting suggestion for additional volumes.
* Following a suggestion by BGA, even non-boot Haiku volumes will get the read-only popup, although with less emphasis in the wording. * BPartition does inherit the read-only flag from it's parent device when not yet mounted. This is now checked and at least prevents the read-only popup for volumes on read-only media. If I understood everything correctly, there is no easy way to tell if a file system supports writing. * Updated indentation style in the header. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27343 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e53fa536eb
commit
19a1d666b3
@ -182,8 +182,64 @@ AutoMounter::_MountVolumes(mount_mode normal, mount_mode removable,
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AutoMounter::_SuggestMountFlags(const BPartition* partition,
|
||||
uint32* _flags) const
|
||||
{
|
||||
uint32 mountFlags = 0;
|
||||
|
||||
bool askReadOnly = true;
|
||||
bool isBFS = false;
|
||||
|
||||
if (partition->ContentType() != NULL
|
||||
&& strcmp(partition->ContentType(), kPartitionTypeBFS) == 0) {
|
||||
#if 0
|
||||
askReadOnly = false;
|
||||
#endif
|
||||
isBFS = true;
|
||||
}
|
||||
|
||||
if (partition->IsReadOnly())
|
||||
askReadOnly = false;
|
||||
|
||||
if (askReadOnly) {
|
||||
// Suggest to the user to mount read-only until Haiku is more mature.
|
||||
// TODO: would be nice to skip this for file systems which don't have
|
||||
// support for writing anyways.
|
||||
BString string;
|
||||
// TODO: Use distro name instead of "Haiku"...
|
||||
if (!isBFS) {
|
||||
string << "The file system on this volume is not the Haiku file "
|
||||
"system. It is strongly suggested to mount it in read-only "
|
||||
"mode. ";
|
||||
} else {
|
||||
string << "It is suggested to mount all additional Haiku volumes "
|
||||
"in read-only mode. ";
|
||||
}
|
||||
string << "This will prevent unintentional data loss because of "
|
||||
"errors in Haiku.";
|
||||
BAlert* alert = new BAlert("Mount Warning", string.String(),
|
||||
"Mount Read/Write", "Cancel", "Mount Read-only",
|
||||
B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
|
||||
int32 choice = alert->Go();
|
||||
switch (choice) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
return false;
|
||||
case 2:
|
||||
mountFlags |= B_MOUNT_READ_ONLY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*_flags = mountFlags;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AutoMounter::_MountVolume(BMessage *message)
|
||||
AutoMounter::_MountVolume(const BMessage* message)
|
||||
{
|
||||
int32 id;
|
||||
if (message->FindInt32("id", &id) != B_OK)
|
||||
@ -195,33 +251,9 @@ AutoMounter::_MountVolume(BMessage *message)
|
||||
if (roster.GetPartitionWithID(id, &device, &partition) != B_OK)
|
||||
return;
|
||||
|
||||
uint32 mountFlags = 0;
|
||||
if (partition->ContentType() == NULL
|
||||
|| strcmp(partition->ContentType(), kPartitionTypeBFS) != 0) {
|
||||
// not a BFS volume, suggest to the user to mount read-only
|
||||
// until Haiku is more mature.
|
||||
// TODO: would be nice to skip this for file systems which don't have
|
||||
// support for writing anyways.
|
||||
BString string;
|
||||
// TODO: Use distro name instead of "Haiku"...
|
||||
string << "The file system on this volume is not the Haiku file "
|
||||
"system. It is strongly suggested to mount it in read-only mode."
|
||||
"This will prevent unintentional data loss because of errors "
|
||||
"in Haiku.";
|
||||
BAlert* alert = new BAlert("Mount Warning", string.String(),
|
||||
"Mount Read/Write", "Cancel", "Mount Read-only",
|
||||
B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
|
||||
int32 choice = alert->Go();
|
||||
switch (choice) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
return;
|
||||
case 2:
|
||||
mountFlags |= B_MOUNT_READ_ONLY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint32 mountFlags;
|
||||
if (!_SuggestMountFlags(partition, &mountFlags))
|
||||
return;
|
||||
|
||||
status_t status = partition->Mount(NULL, mountFlags);
|
||||
if (status < B_OK) {
|
||||
@ -237,7 +269,7 @@ AutoMounter::_SuggestForceUnmount(const char* name, status_t error)
|
||||
{
|
||||
BString text;
|
||||
text << "Could not unmount disk \"" << name << "\":\n\t" << strerror(error);
|
||||
text << "\n\nShould I force unmounting the disk?\n\n"
|
||||
text << "\n\nShould unmounting be forced?\n\n"
|
||||
"Note: if an application is currently writing to the volume, unmounting"
|
||||
" it now might result in loss of data.\n";
|
||||
|
||||
@ -510,7 +542,7 @@ AutoMounter::GetSettings(BMessage *message)
|
||||
|
||||
|
||||
void
|
||||
AutoMounter::MessageReceived(BMessage *message)
|
||||
AutoMounter::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kMsgInitialScan:
|
||||
|
@ -57,49 +57,56 @@ const uint32 kVolumeMounted = 'vmtd';
|
||||
// #pragma mark - Haiku Disk Device API
|
||||
|
||||
class AutoMounter : public BLooper {
|
||||
public:
|
||||
AutoMounter();
|
||||
virtual ~AutoMounter();
|
||||
public:
|
||||
AutoMounter();
|
||||
virtual ~AutoMounter();
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual bool QuitRequested();
|
||||
|
||||
void GetSettings(BMessage* message);
|
||||
void GetSettings(BMessage* message);
|
||||
|
||||
private:
|
||||
enum mount_mode {
|
||||
kNoVolumes,
|
||||
kOnlyBFSVolumes,
|
||||
kAllVolumes,
|
||||
kRestorePreviousVolumes
|
||||
};
|
||||
private:
|
||||
enum mount_mode {
|
||||
kNoVolumes,
|
||||
kOnlyBFSVolumes,
|
||||
kAllVolumes,
|
||||
kRestorePreviousVolumes
|
||||
};
|
||||
|
||||
void _MountVolumes(mount_mode normal, mount_mode removable,
|
||||
bool initialRescan);
|
||||
void _MountVolume(BMessage* message);
|
||||
bool _SuggestForceUnmount(const char* name, status_t error);
|
||||
void _ReportUnmountError(const char* name, status_t error);
|
||||
void _UnmountAndEjectVolume(BPartition* partition, BPath& mountPoint,
|
||||
const char* name);
|
||||
void _UnmountAndEjectVolume(BMessage* message);
|
||||
bool _SuggestMountFlags(const BPartition* partition,
|
||||
uint32* _flags) const;
|
||||
void _MountVolumes(mount_mode normal,
|
||||
mount_mode removable, bool initialRescan);
|
||||
void _MountVolume(const BMessage* message);
|
||||
bool _SuggestForceUnmount(const char* name,
|
||||
status_t error);
|
||||
void _ReportUnmountError(const char* name,
|
||||
status_t error);
|
||||
void _UnmountAndEjectVolume(BPartition* partition,
|
||||
BPath& mountPoint, const char* name);
|
||||
void _UnmountAndEjectVolume(BMessage* message);
|
||||
|
||||
void _FromMode(mount_mode mode, bool& all, bool& bfs, bool& restore);
|
||||
mount_mode _ToMode(bool all, bool bfs, bool restore = false);
|
||||
void _UpdateSettingsFromMessage(BMessage* message);
|
||||
void _ReadSettings();
|
||||
void _WriteSettings();
|
||||
void _FromMode(mount_mode mode, bool& all,
|
||||
bool& bfs, bool& restore);
|
||||
mount_mode _ToMode(bool all, bool bfs,
|
||||
bool restore = false);
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
void _UpdateSettingsFromMessage(BMessage* message);
|
||||
void _ReadSettings();
|
||||
void _WriteSettings();
|
||||
|
||||
private:
|
||||
mount_mode fNormalMode;
|
||||
mount_mode fRemovableMode;
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
BFile fPrefsFile;
|
||||
BMessage fSettings;
|
||||
private:
|
||||
mount_mode fNormalMode;
|
||||
mount_mode fRemovableMode;
|
||||
|
||||
BFile fPrefsFile;
|
||||
BMessage fSettings;
|
||||
};
|
||||
|
||||
#else // !__HAIKU__
|
||||
// #pragma mark - R5 DeviceMap API
|
||||
// #pragma mark - R5 DeviceMap API
|
||||
|
||||
const uint32 kSuspendAutomounter = 'amsp';
|
||||
const uint32 kResumeAutomounter = 'amsr';
|
||||
|
Loading…
Reference in New Issue
Block a user