Fix the bug in is_mount_root method
This commit is contained in:
parent
96adc3dc82
commit
c2a224e757
|
|
@ -140,11 +140,6 @@ impl Dentry {
|
|||
}
|
||||
}
|
||||
|
||||
/// Currently, the root `Dentry` of a fs is the root of a mount.
|
||||
pub(super) fn is_mount_root(&self) -> bool {
|
||||
self.name_and_parent.read().as_ref().is_none()
|
||||
}
|
||||
|
||||
/// Creates a `Dentry_` by creating a new inode of the `type_` with the `mode`.
|
||||
pub(super) fn create(
|
||||
&self,
|
||||
|
|
|
|||
|
|
@ -61,6 +61,11 @@ impl Path {
|
|||
&self.mount
|
||||
}
|
||||
|
||||
/// Returns true if the current `Path` is the root of its mount.
|
||||
pub(super) fn is_mount_root(&self) -> bool {
|
||||
Arc::ptr_eq(&self.dentry, self.mount.root_dentry())
|
||||
}
|
||||
|
||||
/// Lookups the target `Path` given the `name`.
|
||||
pub fn lookup(&self, name: &str) -> Result<Self> {
|
||||
if self.type_() != InodeType::Dir {
|
||||
|
|
@ -119,7 +124,7 @@ impl Path {
|
|||
/// If it is the root of a mount, it will go up to the mountpoint
|
||||
/// to get the name of the mountpoint recursively.
|
||||
fn effective_name(&self) -> String {
|
||||
if !self.dentry.is_mount_root() {
|
||||
if !self.is_mount_root() {
|
||||
return self.dentry.name();
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +144,7 @@ impl Path {
|
|||
/// If it is the root of a mount, it will go up to the mountpoint
|
||||
/// to get the parent of the mountpoint recursively.
|
||||
fn effective_parent(&self) -> Option<Self> {
|
||||
if !self.dentry.is_mount_root() {
|
||||
if !self.is_mount_root() {
|
||||
return Some(Self::new(self.mount.clone(), self.dentry.parent().unwrap()));
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +206,7 @@ impl Path {
|
|||
///
|
||||
/// Note that the root mount cannot be unmounted.
|
||||
pub fn unmount(&self) -> Result<Arc<Mount>> {
|
||||
if !self.dentry.is_mount_root() {
|
||||
if !self.is_mount_root() {
|
||||
return_errno_with_message!(Errno::EINVAL, "not mounted");
|
||||
}
|
||||
|
||||
|
|
@ -291,7 +296,6 @@ impl Path {
|
|||
pub fn set_ctime(&self, time: Duration);
|
||||
pub fn key(&self) -> DentryKey;
|
||||
pub fn inode(&self) -> &Arc<dyn Inode>;
|
||||
pub fn is_mount_root(&self) -> bool;
|
||||
pub fn is_mountpoint(&self) -> bool;
|
||||
pub fn set_xattr(
|
||||
&self,
|
||||
|
|
|
|||
Loading…
Reference in New Issue