When we dynamically create a mount point directory, add a special marker subdirectory in it so the disk system knows the directory was not created by the user. When unmounting, look for the marker and remove the mountpoint directory if found. This fixes the issue where mount / unmount / mounting a volume via Tracker would result in extra empty dirs in the rootfs. Ideally I'd rather solve this by being able to tag the mount points with attributes, but this isn't currently possible since the attribute overlay is a module and thus not available when mounting the rootfs.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30934 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f2e0ac2cd7
commit
6a004bd33c
@ -41,6 +41,7 @@
|
||||
|
||||
using std::nothrow;
|
||||
|
||||
static const char *skAutoCreatePrefix = "_HaikuAutoCreated";
|
||||
|
||||
/*! \class BPartition
|
||||
\brief A BPartition object represent a partition and provides a lot of
|
||||
@ -546,7 +547,7 @@ BPartition::Mount(const char* mountPoint, uint32 mountFlags,
|
||||
|
||||
// create a mount point, if none is given
|
||||
bool deleteMountPoint = false;
|
||||
BPath mountPointPath;
|
||||
BPath mountPointPath, markerPath;
|
||||
if (!mountPoint) {
|
||||
// get a unique mount point
|
||||
error = GetMountPoint(&mountPointPath);
|
||||
@ -554,10 +555,17 @@ BPartition::Mount(const char* mountPoint, uint32 mountFlags,
|
||||
return error;
|
||||
|
||||
mountPoint = mountPointPath.Path();
|
||||
|
||||
markerPath = mountPointPath;
|
||||
markerPath.Append(skAutoCreatePrefix);
|
||||
|
||||
// create the directory
|
||||
if (mkdir(mountPoint, S_IRWXU | S_IRWXG | S_IRWXO) < 0)
|
||||
return errno;
|
||||
|
||||
if (mkdir(markerPath.Path(), S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
|
||||
rmdir(mountPoint);
|
||||
return errno;
|
||||
}
|
||||
|
||||
deleteMountPoint = true;
|
||||
}
|
||||
@ -567,8 +575,10 @@ BPartition::Mount(const char* mountPoint, uint32 mountFlags,
|
||||
mountFlags, parameters);
|
||||
|
||||
// delete the mount point on error, if we created it
|
||||
if (device < B_OK && deleteMountPoint)
|
||||
if (device < B_OK && deleteMountPoint) {
|
||||
rmdir(markerPath.Path());
|
||||
rmdir(mountPoint);
|
||||
}
|
||||
|
||||
// update object, if successful
|
||||
if (device >= 0)
|
||||
@ -605,9 +615,20 @@ BPartition::Unmount(uint32 unmountFlags)
|
||||
status = fs_unmount_volume(path.Path(), unmountFlags);
|
||||
|
||||
// update object, if successful
|
||||
if (status == B_OK)
|
||||
if (status == B_OK) {
|
||||
status = Device()->Update();
|
||||
|
||||
// Check if we created this mount point on the fly.
|
||||
// If so, clean it up.
|
||||
BPath markerPath = path;
|
||||
markerPath.Append(skAutoCreatePrefix);
|
||||
BEntry pathEntry (markerPath.Path());
|
||||
if (pathEntry.InitCheck() == B_OK && pathEntry.Exists()) {
|
||||
rmdir(markerPath.Path());
|
||||
rmdir(path.Path());
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user