mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 06:32:08 +00:00
vfs: prevent remount read-only if pending removes
If there are any inodes on the super block that have been unlinked (i_nlink == 0) but have not yet been deleted then prevent the remounting the super block read-only. Reported-by: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Tested-by: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
7ada4db886
commit
8e8b87964b
4 changed files with 7 additions and 29 deletions
|
@ -474,29 +474,6 @@ void file_sb_list_del(struct file *file)
|
|||
|
||||
#endif
|
||||
|
||||
int fs_may_remount_ro(struct super_block *sb)
|
||||
{
|
||||
struct file *file;
|
||||
/* Check that no files are currently opened for writing. */
|
||||
lg_global_lock(files_lglock);
|
||||
do_file_list_for_each_entry(sb, file) {
|
||||
struct inode *inode = file->f_path.dentry->d_inode;
|
||||
|
||||
/* File with pending delete? */
|
||||
if (inode->i_nlink == 0)
|
||||
goto too_bad;
|
||||
|
||||
/* Writeable file? */
|
||||
if (S_ISREG(inode->i_mode) && (file->f_mode & FMODE_WRITE))
|
||||
goto too_bad;
|
||||
} while_file_list_for_each_entry;
|
||||
lg_global_unlock(files_lglock);
|
||||
return 1; /* Tis' cool bro. */
|
||||
too_bad:
|
||||
lg_global_unlock(files_lglock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* mark_files_ro - mark all files read-only
|
||||
* @sb: superblock in question
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue