From 94c0b79f3749f2f693ca48ea81b781140b0c1b85 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 18 May 2019 18:19:00 +0300 Subject: [PATCH] VFS: change vfs_class::nothingisopen members Do not free VFS before nested one. Signed-off-by: Andrew Borodin --- lib/vfs/direntry.c | 4 +--- src/vfs/extfs/extfs.c | 9 --------- src/vfs/local/local.c | 11 +++++++++++ src/vfs/smbfs/smbfs.c | 12 ++++++++++++ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/vfs/direntry.c b/lib/vfs/direntry.c index ff26434a3..21d688993 100644 --- a/lib/vfs/direntry.c +++ b/lib/vfs/direntry.c @@ -842,9 +842,7 @@ vfs_s_getid (const vfs_path_t * vpath) static gboolean vfs_s_nothingisopen (vfsid id) { - (void) id; - /* Our data structures should survive free of superblock at any time */ - return TRUE; + return (VFS_SUPER (id)->fd_usage <= 0); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/vfs/extfs/extfs.c b/src/vfs/extfs/extfs.c index bb33c25f6..1053a07d6 100644 --- a/src/vfs/extfs/extfs.c +++ b/src/vfs/extfs/extfs.c @@ -1373,14 +1373,6 @@ extfs_getid (const vfs_path_t * vpath) /* --------------------------------------------------------------------------------------------- */ -static gboolean -extfs_nothingisopen (vfsid id) -{ - return (VFS_SUPER (id)->fd_usage <= 0); -} - -/* --------------------------------------------------------------------------------------------- */ - static vfs_path_t * extfs_getlocalcopy (const vfs_path_t * vpath) { @@ -1614,7 +1606,6 @@ vfs_init_extfs (void) vfs_extfs_ops->ferrno = extfs_errno; vfs_extfs_ops->lseek = extfs_lseek; vfs_extfs_ops->getid = extfs_getid; - vfs_extfs_ops->nothingisopen = extfs_nothingisopen; vfs_extfs_ops->getlocalcopy = extfs_getlocalcopy; vfs_extfs_ops->ungetlocalcopy = extfs_ungetlocalcopy; vfs_extfs_ops->mkdir = extfs_mkdir; diff --git a/src/vfs/local/local.c b/src/vfs/local/local.c index f250c71e1..56097e287 100644 --- a/src/vfs/local/local.c +++ b/src/vfs/local/local.c @@ -421,6 +421,16 @@ local_lseek (void *data, off_t offset, int whence) /* --------------------------------------------------------------------------------------------- */ +static gboolean +local_nothingisopen (vfsid id) +{ + (void) id; + + return TRUE; +} + +/* --------------------------------------------------------------------------------------------- */ + void vfs_init_localfs (void) { @@ -455,6 +465,7 @@ vfs_init_localfs (void) vfs_local_ops->ungetlocalcopy = local_ungetlocalcopy; vfs_local_ops->mkdir = local_mkdir; vfs_local_ops->rmdir = local_rmdir; + vfs_local_ops->nothingisopen = local_nothingisopen; vfs_register_class (vfs_local_ops); } diff --git a/src/vfs/smbfs/smbfs.c b/src/vfs/smbfs/smbfs.c index 59d4116a0..aa0bd619e 100644 --- a/src/vfs/smbfs/smbfs.c +++ b/src/vfs/smbfs/smbfs.c @@ -2211,6 +2211,17 @@ smbfs_fstat (void *data, struct stat *buf) return 0; } +/* --------------------------------------------------------------------------------------------- */ + +static gboolean +smbfs_nothingisopen (vfsid id) +{ + /* FIXME */ + (void) id; + + return TRUE; +} + /* --------------------------------------------------------------------------------------------- */ /*** public functions ****************************************************************************/ /* --------------------------------------------------------------------------------------------- */ @@ -2274,6 +2285,7 @@ vfs_init_smbfs (void) vfs_smbfs_ops->mkdir = smbfs_mkdir; vfs_smbfs_ops->rmdir = smbfs_rmdir; vfs_smbfs_ops->setctl = smbfs_setctl; + vfs_smbfs_ops->nothingisopen = smbfs_nothingisopen; vfs_register_class (vfs_smbfs_ops); }