aboutsummaryrefslogtreecommitdiff
path: root/fs/hostfs/hostfs_user.c
AgeCommit message (Collapse)AuthorFilesLines
2023-06-12hostfs: Fix ephemeral inodesGravatar Mickaël Salaün 1-0/+1
hostfs creates a new inode for each opened or created file, which created useless inode allocations and forbade identifying a host file with a kernel inode. Fix this uncommon filesystem behavior by tying kernel inodes to host file's inode and device IDs. Even if the host filesystem inodes may be recycled, this cannot happen while a file referencing it is opened, which is the case with hostfs. It should be noted that hostfs inode IDs may not be unique for the same hostfs superblock because multiple host's (backed) superblocks may be used. Delete inodes when dropping them to force backed host's file descriptors closing. This enables to entirely remove ARCH_EPHEMERAL_INODES, and then makes Landlock fully supported by UML. This is very useful for testing changes. These changes also factor out and simplify some helpers thanks to the new hostfs_inode_update() and the hostfs_iget() revamp: read_name(), hostfs_create(), hostfs_lookup(), hostfs_mknod(), and hostfs_fill_sb_common(). A following commit with new Landlock tests check this new hostfs inode consistency. Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> Cc: Johannes Berg <johannes@sipsolutions.net> Acked-by: Richard Weinberger <richard@nod.at> Link: https://lore.kernel.org/r/20230612191430.339153-2-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net>
2018-04-02hostfs: rename do_rmdir() to hostfs_do_rmdir()Gravatar Dominik Brodowski 1-1/+1
do_rmdir() is used in the VFS layer at fs/namei.c, so use a different name in hostfs. Cc: Jeff Dike <jdike@addtoit.com> Cc: user-mode-linux-devel@lists.sourceforge.net Acked-by: Richard Weinberger <richard@nod.at> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2015-04-13um: hostfs: Reduce number of syscalls in readdirGravatar Richard Weinberger 1-3/+9
Currently hostfs issues every time a seekdir(), in fact it has to do this only upon the first call. Also telldir() can be omitted as we can obtain the directory offset from readdir(). Signed-off-by: Richard Weinberger <richard@nod.at>
2015-03-26hostfs: No need to box and later unbox the file modeGravatar Richard Weinberger 1-14/+3
There is really no point in having a function with 10 arguments. Reported-by: Daniel Walter <d.walter@0x90.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2014-08-07hostfs: support rename flagsGravatar Miklos Szeredi 1-0/+28
Support RENAME_NOREPLACE and RENAME_EXCHANGE flags on hostfs if the underlying filesystem supports it. Since renameat2(2) is not yet in any libc, use syscall(2) to invoke the renameat2 syscall. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Cc: Richard Weinberger <richard@nod.at> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-10-09um: get rid of pointless include "..." where include <...> will doGravatar Al Viro 1-1/+0
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Richard Weinberger <richard@nod.at>
2012-03-25uml/hostfs: Propagate dirent.d_type to filldir()Gravatar Geert Uytterhoeven 1-1/+3
Currently the (optional) d_type member in struct dirent is always DT_UNKNOWN on hostfs, which may confuse buggy software using readdir(). Make sure to propagate its value from the underlying filesystem if it's available there. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Richard Weinberger <richard@nod.at>
2011-11-02um: kill useless include of user.hGravatar Al Viro 1-1/+0
everything in USER_OBJ gets it via -include user.h Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Richard Weinberger <richard@nod.at>
2010-10-26hostfs: code cleanupsGravatar Richard Weinberger 1-3/+2
Some code cleanups for hostfs. Signed-off-by: Richard Weinberger <richard@nod.at> Cc: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-10-26hostfs: fix UML crash: remove f_spare from hostfsGravatar Richard Weinberger 1-7/+2
365b1818 ("add f_flags to struct statfs(64)") resized f_spare within struct statfs which caused a UML crash. There is no need to copy f_spare. Signed-off-by: Richard Weinberger <richard@nod.at> Reported-by: Toralf Förster <toralf.foerster@gmx.de> Tested-by: Toralf Förster <toralf.foerster@gmx.de> Cc: Christoph Hellwig <hch@lst.de> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Jeff Dike <jdike@addtoit.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-08-09try to get rid of races in hostfs open()Gravatar Al Viro 1-0/+5
In case of mode mismatch, do *not* blindly close the descriptor another openers might be using right now. Open the underlying file with currently sufficient mode, then * if current mode has grown so that it's sufficient for us now, just close our new fd * if current mode has grown and our fd is *not* enough to cover it, close and repeat. * otherwise, install our fd if the file hadn't been opened at all or dup2() our fd over the current one (and close our fd). Critical section is protected by mutex; yes, system-wide. All we do under it is a bunch of comparison and maybe an overwriting dup2() on host. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2010-08-09hostfs: get rid of file_type(), fold init_inode()Gravatar Al Viro 1-30/+0
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2010-08-09switch stat_file() to passing a single struct rather than fsckloads of pointersGravatar Al Viro 1-44/+31
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2010-08-09Deal with missing exports for hostfsGravatar Al Viro 1-3/+3
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2008-11-19hostfs: fix a duplicated global function nameGravatar WANG Cong 1-1/+1
fs/hostfs/hostfs_user.c defines do_readlink() as non-static, and so does fs/xfs/linux-2.6/xfs_ioctl.c when CONFIG_XFS_DEBUG=y. So rename do_readlink() in hostfs to hostfs_do_readlink(). I think it's better if XFS guys will also rename their do_readlink(), it's not necessary to use such a general name. Signed-off-by: WANG Cong <wangcong@zeuux.org> Cc: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05uml: fix hostfs tv_usec calculationsGravatar Dominique Quatravaux 1-4/+4
To convert from tv_nsec to tv_usec, one needs to divide by 1000, not multiply. Signed-off-by: Dominique Quatravaux <dominique@quatravaux.org> Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-16uml: fix hostfs styleGravatar Jeff Dike 1-58/+81
Style fixes in hostfs. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-16uml: remove unneeded if from hostfsGravatar Jeff Dike 1-1/+1
Get rid of an empty if statement which might look like a bug to a casual reader. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-08uml: hostfs style fixesGravatar Jeff Dike 1-68/+73
hostfs needed some style goodness. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-08uml: make hostfs_setattr() support operations on unlinked open filesGravatar Alberto Bertogli 1-40/+68
This patch allows hostfs_setattr() to work on unlinked open files by calling set_attr() (the userspace part) with the inode's fd. Without this, applications that depend on doing attribute changes to unlinked open files will fail. It works by using the fd versions instead of the path ones (for example fchmod() instead of chmod(), fchown() instead of chown()) when an fd is available. Signed-off-by: Alberto Bertogli <albertito@gmail.com> Signed-off-by: Jeff Dike <jdike@linux.intel.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-01-30[PATCH] uml: fix mknodGravatar Johannes Stezenbach 1-2/+2
Fix UML hostfs mknod(): userspace has differernt dev_t size and encoding than kernel, so extract major/minor and reencode using glibc makedev() macro. Signed-off-by: Johannes Stezenbach <js@linuxtv.org> Acked-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Jeff Dike <jdike@addtoit.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2006-03-27[PATCH] uml: fix hostfs stack corruptionGravatar Jeff Dike 1-1/+0
Noted by Oleg Drokin: We initialized an extra slot of struct kstatfs.spare, sometimes causing stack corruption. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Oleg Drokin <green@clusterfs.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-28[PATCH] uml: implement hostfs syncingGravatar Paolo 'Blaisorblade' Giarrusso 1-1/+15
Actually implement the hostfs "sync" method. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-16Linux-2.6.12-rc2v2.6.12-rc2Gravatar Linus Torvalds 1-0/+362
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!