summaryrefslogtreecommitdiffstats
path: root/include/fs.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-03-29 13:47:12 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-07-11 09:58:38 +0200
commitb3fbfad7aeaf8ee36216e1d14b5d7be27ba612de (patch)
tree61299cecd2c49902ff831813daa81926bacd69db /include/fs.h
parent4c7b877a5c90bcf80d42086d246981f0686d1e27 (diff)
downloadbarebox-b3fbfad7aeaf8ee36216e1d14b5d7be27ba612de.tar.gz
barebox-b3fbfad7aeaf8ee36216e1d14b5d7be27ba612de.tar.xz
fs: dentry cache implementation
This adds the Linux dentry cache implementation to barebox. Until now every filesystem driver resolves the full path to a file for itself. This leads to code duplication and is error prone since resolving paths is a complicated task. Also it can narrow down the lookup performance since barebox only knows ASCII paths and has no way of caching lookups. With this patch we get the Linux dcache implementation. The path resolving code from fs/namei.c is nearly taken as-is, minus the RCU and locking code. Dcaching is made simple as of now: We simply cache everything and never release any dentries. Although we do reference counting for inodes and dentries it is effectively not used yet. We never free anything until a fs is unmounted in which case we free everything no matter if references are taken or not. This patch also contains a wrapper in fs/legacy.c to support filesystems with the old API. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/fs.h')
-rw-r--r--include/fs.h38
1 files changed, 20 insertions, 18 deletions
diff --git a/include/fs.h b/include/fs.h
index e6fcd044dd..181318f404 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -31,14 +31,15 @@ typedef struct filep {
/* private fields. Mapping between FILE and filedescriptor number */
int no;
char in_use;
+
+ struct inode *f_inode;
+ struct dentry *dentry;
} FILE;
#define FS_DRIVER_NO_DEV 1
struct fs_driver_d {
int (*probe) (struct device_d *dev);
- int (*mkdir)(struct device_d *dev, const char *pathname);
- int (*rmdir)(struct device_d *dev, const char *pathname);
/* create a file. The file is guaranteed to not exist */
int (*create)(struct device_d *dev, const char *pathname, mode_t mode);
@@ -47,11 +48,6 @@ struct fs_driver_d {
/* Truncate a file to given size */
int (*truncate)(struct device_d *dev, FILE *f, ulong size);
- int (*symlink)(struct device_d *dev, const char *pathname,
- const char *newpath);
- int (*readlink)(struct device_d *dev, const char *pathname, char *name,
- size_t size);
-
int (*open)(struct device_d *dev, FILE *f, const char *pathname);
int (*close)(struct device_d *dev, FILE *f);
int (*read)(struct device_d *dev, FILE *f, void *buf, size_t size);
@@ -59,11 +55,6 @@ struct fs_driver_d {
int (*flush)(struct device_d *dev, FILE *f);
loff_t (*lseek)(struct device_d *dev, FILE *f, loff_t pos);
- struct dir* (*opendir)(struct device_d *dev, const char *pathname);
- struct dirent* (*readdir)(struct device_d *dev, struct dir *dir);
- int (*closedir)(struct device_d *dev, DIR *dir);
- int (*stat)(struct device_d *dev, const char *file, struct stat *stat);
-
int (*ioctl)(struct device_d *dev, FILE *f, int request, void *buf);
int (*erase)(struct device_d *dev, FILE *f, loff_t count,
loff_t offset);
@@ -72,6 +63,18 @@ struct fs_driver_d {
int (*memmap)(struct device_d *dev, FILE *f, void **map, int flags);
+ /* legacy */
+ int (*mkdir)(struct device_d *dev, const char *pathname);
+ int (*rmdir)(struct device_d *dev, const char *pathname);
+ int (*symlink)(struct device_d *dev, const char *pathname,
+ const char *newpath);
+ int (*readlink)(struct device_d *dev, const char *pathname, char *name,
+ size_t size);
+ struct dir* (*opendir)(struct device_d *dev, const char *pathname);
+ struct dirent* (*readdir)(struct device_d *dev, struct dir *dir);
+ int (*closedir)(struct device_d *dev, DIR *dir);
+ int (*stat)(struct device_d *dev, const char *file, struct stat *stat);
+
struct driver_d drv;
enum filetype type;
@@ -99,6 +102,10 @@ struct fs_device_d {
struct list_head list;
char *options;
char *linux_rootarg;
+
+ struct super_block sb;
+
+ struct vfsmount vfsmount;
};
bool __is_tftp_fs(const char *path);
@@ -135,12 +142,6 @@ int ls(const char *path, ulong flags);
char *mkmodestr(unsigned long mode, char *str);
-/*
- * This function turns 'path' into an absolute path and removes all occurrences
- * of "..", "." and double slashes. The returned string must be freed wit free().
- */
-char *normalise_path(const char *path);
-
char *canonicalize_path(const char *pathname);
char *get_mounted_path(const char *path);
@@ -154,6 +155,7 @@ void automount_remove(const char *_path);
int automount_add(const char *path, const char *cmd);
void automount_print(void);
+int fs_init_legacy(struct fs_device_d *fsdev);
int fsdev_open_cdev(struct fs_device_d *fsdev);
const char *cdev_get_mount_path(struct cdev *cdev);
const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions);