From 311282ba6686a9410c7b3123b95b2281c0042f37 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 20 Mar 2018 21:58:17 +0100 Subject: rename file_operations -> cdev_operations Linux also has struct file_operations which are something different. Rename our file_operations to cdev_operations which better matches what we have. Signed-off-by: Sascha Hauer --- arch/arm/mach-mxs/ocotp.c | 2 +- arch/sandbox/board/hostfile.c | 2 +- commands/mem.c | 2 +- commands/stddev.c | 8 ++++---- common/block.c | 2 +- common/firmware.c | 2 +- drivers/base/regmap/regmap.c | 2 +- drivers/eeprom/at24.c | 2 +- drivers/eeprom/at25.c | 2 +- drivers/hw_random/core.c | 2 +- drivers/mfd/act8846.c | 2 +- drivers/mfd/lp3972.c | 2 +- drivers/mfd/mc34704.c | 2 +- drivers/mfd/mc9sdz60.c | 2 +- drivers/mfd/stmpe-i2c.c | 2 +- drivers/mfd/twl-core.c | 2 +- drivers/misc/jtag.c | 2 +- drivers/misc/sram.c | 2 +- drivers/mtd/core.c | 2 +- drivers/mtd/mtdoob.c | 2 +- drivers/mtd/mtdraw.c | 4 ++-- drivers/mtd/nand/nand-bb.c | 2 +- drivers/mtd/ubi/barebox.c | 4 ++-- drivers/net/e1000/eeprom.c | 4 ++-- drivers/net/ksz8864rmn.c | 2 +- drivers/net/phy/mdio_bus.c | 2 +- drivers/nvmem/core.c | 2 +- drivers/video/fb.c | 2 +- drivers/w1/slaves/w1_ds2431.c | 2 +- drivers/w1/slaves/w1_ds2433.c | 2 +- fs/devfs-core.c | 2 +- include/console.h | 2 +- include/driver.h | 4 ++-- include/mfd/twl-core.h | 2 +- 34 files changed, 41 insertions(+), 41 deletions(-) diff --git a/arch/arm/mach-mxs/ocotp.c b/arch/arm/mach-mxs/ocotp.c index 72f3e8240b..b41fde9919 100644 --- a/arch/arm/mach-mxs/ocotp.c +++ b/arch/arm/mach-mxs/ocotp.c @@ -172,7 +172,7 @@ free_mem: return ret; } -static struct file_operations mxs_ocotp_ops = { +static struct cdev_operations mxs_ocotp_ops = { .read = mxs_ocotp_cdev_read, .lseek = dev_lseek_default, }; diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c index e7d92ea031..3fc1503799 100644 --- a/arch/sandbox/board/hostfile.c +++ b/arch/sandbox/board/hostfile.c @@ -64,7 +64,7 @@ static void hf_info(struct device_d *dev) printf("file: %s\n", priv->filename); } -static struct file_operations hf_fops = { +static struct cdev_operations hf_fops = { .read = hf_read, .write = hf_write, .lseek = dev_lseek_default, diff --git a/commands/mem.c b/commands/mem.c index 29eaa80b23..eb91ade05a 100644 --- a/commands/mem.c +++ b/commands/mem.c @@ -81,7 +81,7 @@ int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, return 0; } -static struct file_operations memops = { +static struct cdev_operations memops = { .read = mem_read, .write = mem_write, .memmap = generic_memmap_rw, diff --git a/commands/stddev.c b/commands/stddev.c index 93da2c7398..4d1b6f5108 100644 --- a/commands/stddev.c +++ b/commands/stddev.c @@ -25,7 +25,7 @@ static ssize_t zero_read(struct cdev *cdev, void *buf, size_t count, loff_t offs return count; } -static struct file_operations zeroops = { +static struct cdev_operations zeroops = { .read = zero_read, .lseek = dev_lseek_default, }; @@ -53,7 +53,7 @@ static ssize_t full_read(struct cdev *cdev, void *buf, size_t count, loff_t offs return count; } -static struct file_operations fullops = { +static struct cdev_operations fullops = { .read = full_read, .lseek = dev_lseek_default, }; @@ -80,7 +80,7 @@ static ssize_t null_write(struct cdev *cdev, const void *buf, size_t count, loff return count; } -static struct file_operations nullops = { +static struct cdev_operations nullops = { .write = null_write, .lseek = dev_lseek_default, }; @@ -108,7 +108,7 @@ static ssize_t prng_read(struct cdev *cdev, void *buf, size_t count, loff_t offs return count; } -static struct file_operations prngops = { +static struct cdev_operations prngops = { .read = prng_read, .lseek = dev_lseek_default, }; diff --git a/common/block.c b/common/block.c index e2ba9d4296..55d8d1637e 100644 --- a/common/block.c +++ b/common/block.c @@ -332,7 +332,7 @@ static int block_op_flush(struct cdev *cdev) return writebuffer_flush(blk); } -static struct file_operations block_ops = { +static struct cdev_operations block_ops = { .read = block_op_read, #ifdef CONFIG_BLOCK_WRITE .write = block_op_write, diff --git a/common/firmware.c b/common/firmware.c index 664f9107d0..250fef5378 100644 --- a/common/firmware.c +++ b/common/firmware.c @@ -153,7 +153,7 @@ static int firmware_close(struct cdev *cdev) return 0; } -static struct file_operations firmware_ops = { +static struct cdev_operations firmware_ops = { .open = firmware_open, .write = firmware_write, .close = firmware_close, diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 67d95fe30a..8bbc2373fc 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -352,7 +352,7 @@ static ssize_t regmap_cdev_write(struct cdev *cdev, const void *buf, size_t coun return count; } -static struct file_operations regmap_fops = { +static struct cdev_operations regmap_fops = { .lseek = dev_lseek_default, .read = regmap_cdev_read, .write = regmap_cdev_write, diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c index 11f23319b6..4fae3a12e4 100644 --- a/drivers/eeprom/at24.c +++ b/drivers/eeprom/at24.c @@ -52,7 +52,7 @@ struct at24_data { struct at24_platform_data chip; struct cdev cdev; - struct file_operations fops; + struct cdev_operations fops; u8 *writebuf; unsigned write_max; diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c index 9f16f964a8..a9050d6c16 100644 --- a/drivers/eeprom/at25.c +++ b/drivers/eeprom/at25.c @@ -232,7 +232,7 @@ static ssize_t at25_ee_write(struct cdev *cdev, return written ? written : status; } -static struct file_operations at25_fops = { +static struct cdev_operations at25_fops = { .read = at25_ee_read, .write = at25_ee_write, .lseek = dev_lseek_default, diff --git a/drivers/hw_random/core.c b/drivers/hw_random/core.c index ef2a988c76..1c68a379f7 100644 --- a/drivers/hw_random/core.c +++ b/drivers/hw_random/core.c @@ -61,7 +61,7 @@ static ssize_t rng_dev_read(struct cdev *cdev, void *buf, size_t size, return cur; } -static struct file_operations rng_chrdev_ops = { +static struct cdev_operations rng_chrdev_ops = { .read = rng_dev_read, .lseek = dev_lseek_default, }; diff --git a/drivers/mfd/act8846.c b/drivers/mfd/act8846.c index 60029acf76..dfca0498b1 100644 --- a/drivers/mfd/act8846.c +++ b/drivers/mfd/act8846.c @@ -117,7 +117,7 @@ static ssize_t act8846_write(struct cdev *cdev, const void *_buf, size_t count, return count; } -static struct file_operations act8846_fops = { +static struct cdev_operations act8846_fops = { .lseek = dev_lseek_default, .read = act8846_read, .write = act8846_write, diff --git a/drivers/mfd/lp3972.c b/drivers/mfd/lp3972.c index ee794df2d8..054713b942 100644 --- a/drivers/mfd/lp3972.c +++ b/drivers/mfd/lp3972.c @@ -70,7 +70,7 @@ static ssize_t lp_read(struct cdev *cdev, void *_buf, size_t count, loff_t offse return count; } -static struct file_operations lp_fops = { +static struct cdev_operations lp_fops = { .lseek = dev_lseek_default, .read = lp_read, }; diff --git a/drivers/mfd/mc34704.c b/drivers/mfd/mc34704.c index 3dc85f5474..bfda169aaa 100644 --- a/drivers/mfd/mc34704.c +++ b/drivers/mfd/mc34704.c @@ -100,7 +100,7 @@ static ssize_t mc34704_write(struct cdev *cdev, const void *_buf, size_t count, return count; } -static struct file_operations mc34704_fops = { +static struct cdev_operations mc34704_fops = { .lseek = dev_lseek_default, .read = mc34704_read, .write = mc34704_write, diff --git a/drivers/mfd/mc9sdz60.c b/drivers/mfd/mc9sdz60.c index 0d2c56b480..9993efc5de 100644 --- a/drivers/mfd/mc9sdz60.c +++ b/drivers/mfd/mc9sdz60.c @@ -112,7 +112,7 @@ static ssize_t mc_write(struct cdev *cdev, const void *_buf, size_t count, loff_ return count; } -static struct file_operations mc_fops = { +static struct cdev_operations mc_fops = { .lseek = dev_lseek_default, .read = mc_read, .write = mc_write, diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c index fb91ffa008..51c56bbf56 100644 --- a/drivers/mfd/stmpe-i2c.c +++ b/drivers/mfd/stmpe-i2c.c @@ -101,7 +101,7 @@ static ssize_t stmpe_write(struct cdev *cdev, const void *_buf, size_t count, lo return count; } -static struct file_operations stmpe_fops = { +static struct cdev_operations stmpe_fops = { .lseek = dev_lseek_default, .read = stmpe_read, .write = stmpe_write, diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 20bde2cf89..fb435f510f 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -149,7 +149,7 @@ static ssize_t twl_write(struct cdev *cdev, const void *_buf, size_t count, return count; } -struct file_operations twl_fops = { +struct cdev_operations twl_fops = { .lseek = dev_lseek_default, .read = twl_read, .write = twl_write, diff --git a/drivers/misc/jtag.c b/drivers/misc/jtag.c index f5d0c72ed5..9accefa342 100644 --- a/drivers/misc/jtag.c +++ b/drivers/misc/jtag.c @@ -265,7 +265,7 @@ static int jtag_ioctl(struct cdev *inode, int cmd, void *arg) return ret; } -static struct file_operations jtag_operations = { +static struct cdev_operations jtag_operations = { .ioctl = jtag_ioctl, }; diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index 4fb6f801d2..27b4c681fd 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c @@ -25,7 +25,7 @@ struct sram { struct cdev cdev; }; -static struct file_operations memops = { +static struct cdev_operations memops = { .read = mem_read, .write = mem_write, .memmap = generic_memmap_rw, diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c index 1950ee87ee..d2012b5f70 100644 --- a/drivers/mtd/core.c +++ b/drivers/mtd/core.c @@ -438,7 +438,7 @@ int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) return ret_code >= mtd->bitflip_threshold ? -EUCLEAN : 0; } -static struct file_operations mtd_ops = { +static struct cdev_operations mtd_ops = { .read = mtd_op_read, #ifdef CONFIG_MTD_WRITE .write = mtd_op_write, diff --git a/drivers/mtd/mtdoob.c b/drivers/mtd/mtdoob.c index 86076f028d..ffaf9506f3 100644 --- a/drivers/mtd/mtdoob.c +++ b/drivers/mtd/mtdoob.c @@ -63,7 +63,7 @@ static ssize_t mtd_op_read_oob(struct cdev *cdev, void *buf, size_t count, return mtd->oobsize; } -static struct file_operations mtd_ops_oob = { +static struct cdev_operations mtd_ops_oob = { .read = mtd_op_read_oob, .ioctl = mtd_ioctl, .lseek = dev_lseek_default, diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c index ab360b7862..4f7c3b836c 100644 --- a/drivers/mtd/mtdraw.c +++ b/drivers/mtd/mtdraw.c @@ -287,7 +287,7 @@ static ssize_t mtdraw_erase(struct cdev *cdev, loff_t count, loff_t offset) } #endif -static const struct file_operations mtd_raw_fops = { +static const struct cdev_operations mtd_raw_fops = { .read = mtdraw_read, .write = mtdraw_write, .erase = mtdraw_erase, @@ -305,7 +305,7 @@ static int add_mtdraw_device(struct mtd_info *mtd, const char *devname, void **p mtdraw->writebuf = xmalloc(RAW_WRITEBUF_SIZE); mtdraw->mtd = mtd; - mtdraw->cdev.ops = (struct file_operations *)&mtd_raw_fops; + mtdraw->cdev.ops = (struct cdev_operations *)&mtd_raw_fops; mtdraw->cdev.size = mtd_div_by_wb(mtd->size, mtd) * (mtd->writesize + mtd->oobsize); mtdraw->cdev.name = basprintf("%s.raw", mtd->cdev.name); diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c index a1523c3c89..c1977381d4 100644 --- a/drivers/mtd/nand/nand-bb.c +++ b/drivers/mtd/nand/nand-bb.c @@ -264,7 +264,7 @@ static loff_t nand_bb_lseek(struct cdev *cdev, loff_t __offset) return -EINVAL; } -static struct file_operations nand_bb_ops = { +static struct cdev_operations nand_bb_ops = { .open = nand_bb_open, .close = nand_bb_close, .read = nand_bb_read, diff --git a/drivers/mtd/ubi/barebox.c b/drivers/mtd/ubi/barebox.c index d67e566db6..65f5456455 100644 --- a/drivers/mtd/ubi/barebox.c +++ b/drivers/mtd/ubi/barebox.c @@ -218,7 +218,7 @@ static int ubi_volume_cdev_ioctl(struct cdev *cdev, int cmd, void *buf) return err; } -static struct file_operations ubi_volume_fops = { +static struct cdev_operations ubi_volume_fops = { .open = ubi_volume_cdev_open, .close = ubi_volume_cdev_close, .read = ubi_volume_cdev_read, @@ -467,7 +467,7 @@ static int ubi_cdev_ioctl(struct cdev *cdev, int cmd, void *buf) return 0; } -static struct file_operations ubi_fops = { +static struct cdev_operations ubi_fops = { .ioctl = ubi_cdev_ioctl, }; diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c index 319910103e..3f39db7164 100644 --- a/drivers/net/e1000/eeprom.c +++ b/drivers/net/e1000/eeprom.c @@ -1294,7 +1294,7 @@ exit: return ret; } -static struct file_operations e1000_invm_ops = { +static struct cdev_operations e1000_invm_ops = { .read = e1000_invm_cdev_read, .write = e1000_invm_cdev_write, .lseek = dev_lseek_default, @@ -1320,7 +1320,7 @@ static ssize_t e1000_eeprom_cdev_read(struct cdev *cdev, void *buf, return (count / 2) * 2; }; -static struct file_operations e1000_eeprom_ops = { +static struct cdev_operations e1000_eeprom_ops = { .read = e1000_eeprom_cdev_read, .lseek = dev_lseek_default, }; diff --git a/drivers/net/ksz8864rmn.c b/drivers/net/ksz8864rmn.c index 860af448ea..8b9d66019b 100644 --- a/drivers/net/ksz8864rmn.c +++ b/drivers/net/ksz8864rmn.c @@ -120,7 +120,7 @@ static ssize_t micel_switch_write(struct cdev *cdev, const void *_buf, size_t co return count; } -static struct file_operations micrel_switch_ops = { +static struct cdev_operations micrel_switch_ops = { .read = micel_switch_read, .write = micel_switch_write, .lseek = dev_lseek_default, diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index d209716a14..5d4218f7c0 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -285,7 +285,7 @@ static ssize_t phydev_write(struct cdev *cdev, const void *_buf, size_t count, l return count; } -static struct file_operations phydev_ops = { +static struct cdev_operations phydev_ops = { .read = phydev_read, .write = phydev_write, .lseek = dev_lseek_default, diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 4e50a8843f..172fa8b720 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -82,7 +82,7 @@ static ssize_t nvmem_cdev_write(struct cdev *cdev, const void *buf, size_t count return retlen; } -static struct file_operations nvmem_chrdev_ops = { +static struct cdev_operations nvmem_chrdev_ops = { .read = nvmem_cdev_read, .write = nvmem_cdev_write, .lseek = dev_lseek_default, diff --git a/drivers/video/fb.c b/drivers/video/fb.c index 004df1e604..5e829e832d 100644 --- a/drivers/video/fb.c +++ b/drivers/video/fb.c @@ -221,7 +221,7 @@ static int fb_set_modename(struct param_d *param, void *priv) return 0; } -static struct file_operations fb_ops = { +static struct cdev_operations fb_ops = { .read = mem_read, .write = mem_write, .memmap = generic_memmap_rw, diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c index e3e929670d..13691d7bab 100644 --- a/drivers/w1/slaves/w1_ds2431.c +++ b/drivers/w1/slaves/w1_ds2431.c @@ -257,7 +257,7 @@ out_up: #define ds2431_cdev_write NULL #endif -static struct file_operations ds2431_ops = { +static struct cdev_operations ds2431_ops = { .read = ds2431_cdev_read, .write = ds2431_cdev_write, .lseek = dev_lseek_default, diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c index a907c6bf3c..f521a46a75 100644 --- a/drivers/w1/slaves/w1_ds2433.c +++ b/drivers/w1/slaves/w1_ds2433.c @@ -156,7 +156,7 @@ out_up: #define ds2433_cdev_write NULL #endif -static struct file_operations ds2433_ops = { +static struct cdev_operations ds2433_ops = { .read = ds2433_cdev_read, .write = ds2433_cdev_write, .lseek = dev_lseek_default, diff --git a/fs/devfs-core.c b/fs/devfs-core.c index ea5887c720..d06a534b57 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -457,7 +457,7 @@ static ssize_t loop_write(struct cdev *cdev, const void *buf, size_t count, return write(priv->fd, buf, count); } -static const struct file_operations loop_ops = { +static const struct cdev_operations loop_ops = { .read = loop_read, .write = loop_write, .memmap = generic_memmap_rw, diff --git a/include/console.h b/include/console.h index a8b2663a4c..3c14e35935 100644 --- a/include/console.h +++ b/include/console.h @@ -63,7 +63,7 @@ struct console_device { const char *linux_console_name; struct cdev devfs; - struct file_operations fops; + struct cdev_operations fops; }; int console_register(struct console_device *cdev); diff --git a/include/driver.h b/include/driver.h index f37805db17..91653b7946 100644 --- a/include/driver.h +++ b/include/driver.h @@ -420,7 +420,7 @@ int platform_driver_register(struct driver_d *drv); int platform_device_register(struct device_d *new_device); -struct file_operations { +struct cdev_operations { /*! Called in response of reading from this device. Required */ ssize_t (*read)(struct cdev*, void* buf, size_t count, loff_t offset, ulong flags); @@ -441,7 +441,7 @@ struct file_operations { #define MAX_PARTUUID_STR sizeof("00112233-4455-6677-8899-AABBCCDDEEFF") struct cdev { - const struct file_operations *ops; + const struct cdev_operations *ops; void *priv; struct device_d *dev; struct device_node *device_node; diff --git a/include/mfd/twl-core.h b/include/mfd/twl-core.h index f090032b3f..88d29f019b 100644 --- a/include/mfd/twl-core.h +++ b/include/mfd/twl-core.h @@ -21,7 +21,7 @@ struct twlcore { struct i2c_client *client; }; -extern struct file_operations twl_fops; +extern struct cdev_operations twl_fops; extern int twlcore_reg_read(struct twlcore *twlcore, u16 reg, u8 *val); extern int twlcore_reg_write(struct twlcore *twlcore, u16 reg, u8 val); -- cgit v1.2.3 From 26247900e9732d1d82ebaf3617ba2c294162f77d Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 27 Feb 2018 15:31:40 +0100 Subject: ubifs: remove dead code Remove stuff that was added to UBIFS for U-Boot which we do not need because we already have it in the Linux header files. Signed-off-by: Sascha Hauer --- fs/ubifs/ubifs.h | 187 ------------------------------------------------------- 1 file changed, 187 deletions(-) diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 5c5a82637e..5589f99401 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -96,193 +96,6 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp); /* uapi/linux/limits.h */ #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ -#ifndef __BAREBOX__ -/* linux/include/time.h */ -#define NSEC_PER_SEC 1000000000L -#define get_seconds() 0 -#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 }) - -struct timespec { - time_t tv_sec; /* seconds */ - long tv_nsec; /* nanoseconds */ -}; - -static struct timespec current_fs_time(struct super_block *sb) -{ - struct timespec now; - now.tv_sec = 0; - now.tv_nsec = 0; - return now; -}; - -/* linux/include/dcache.h */ - -/* - * "quick string" -- eases parameter passing, but more importantly - * saves "metadata" about the string (ie length and the hash). - * - * hash comes first so it snuggles against d_parent in the - * dentry. - */ -struct qstr { - unsigned int hash; - unsigned int len; -#ifndef __BAREBOX__ - const char *name; -#else - char *name; -#endif -}; - -/* include/linux/fs.h */ - -/* Possible states of 'frozen' field */ -enum { - SB_UNFROZEN = 0, /* FS is unfrozen */ - SB_FREEZE_WRITE = 1, /* Writes, dir ops, ioctls frozen */ - SB_FREEZE_PAGEFAULT = 2, /* Page faults stopped as well */ - SB_FREEZE_FS = 3, /* For internal FS use (e.g. to stop - * internal threads if needed) */ - SB_FREEZE_COMPLETE = 4, /* ->freeze_fs finished successfully */ -}; - -#define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1) - -struct sb_writers { -#ifndef __BAREBOX__ - /* Counters for counting writers at each level */ - struct percpu_counter counter[SB_FREEZE_LEVELS]; -#endif - wait_queue_head_t wait; /* queue for waiting for - writers / faults to finish */ - int frozen; /* Is sb frozen? */ - wait_queue_head_t wait_unfrozen; /* queue for waiting for - sb to be thawed */ -#ifdef CONFIG_DEBUG_LOCK_ALLOC - struct lockdep_map lock_map[SB_FREEZE_LEVELS]; -#endif -}; - -struct address_space { - struct inode *host; /* owner: inode, block_device */ -#ifndef __BAREBOX__ - struct radix_tree_root page_tree; /* radix tree of all pages */ -#endif - spinlock_t tree_lock; /* and lock protecting it */ - unsigned int i_mmap_writable;/* count VM_SHARED mappings */ - struct rb_root i_mmap; /* tree of private and shared mappings */ - struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ - struct mutex i_mmap_mutex; /* protect tree, count, list */ - /* Protected by tree_lock together with the radix tree */ - unsigned long nrpages; /* number of total pages */ - pgoff_t writeback_index;/* writeback starts here */ - const struct address_space_operations *a_ops; /* methods */ - unsigned long flags; /* error bits/gfp mask */ -#ifndef __BAREBOX__ - struct backing_dev_info *backing_dev_info; /* device readahead, etc */ -#endif - spinlock_t private_lock; /* for use by the address_space */ - struct list_head private_list; /* ditto */ - void *private_data; /* ditto */ -} __attribute__((aligned(sizeof(long)))); - -/* - * Keep mostly read-only and often accessed (especially for - * the RCU path lookup and 'stat' data) fields at the beginning - * of the 'struct inode' - */ -struct inode { - umode_t i_mode; - unsigned short i_opflags; - kuid_t i_uid; - kgid_t i_gid; - unsigned int i_flags; - -#ifdef CONFIG_FS_POSIX_ACL - struct posix_acl *i_acl; - struct posix_acl *i_default_acl; -#endif - - const struct inode_operations *i_op; - struct super_block *i_sb; - struct address_space *i_mapping; - -#ifdef CONFIG_SECURITY - void *i_security; -#endif - - /* Stat data, not accessed from path walking */ - unsigned long i_ino; - /* - * Filesystems may only read i_nlink directly. They shall use the - * following functions for modification: - * - * (set|clear|inc|drop)_nlink - * inode_(inc|dec)_link_count - */ - union { - const unsigned int i_nlink; - unsigned int __i_nlink; - }; - dev_t i_rdev; - loff_t i_size; - struct timespec i_atime; - struct timespec i_mtime; - struct timespec i_ctime; - spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ - unsigned short i_bytes; - unsigned int i_blkbits; - blkcnt_t i_blocks; - -#ifdef __NEED_I_SIZE_ORDERED - seqcount_t i_size_seqcount; -#endif - - /* Misc */ - unsigned long i_state; - struct mutex i_mutex; - - unsigned long dirtied_when; /* jiffies of first dirtying */ - - struct hlist_node i_hash; - struct list_head i_wb_list; /* backing dev IO list */ - struct list_head i_lru; /* inode LRU list */ - struct list_head i_sb_list; - union { - struct hlist_head i_dentry; - struct rcu_head i_rcu; - }; - u64 i_version; - atomic_t i_count; - atomic_t i_dio_count; - atomic_t i_writecount; - const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ - struct file_lock *i_flock; - struct address_space i_data; -#ifdef CONFIG_QUOTA - struct dquot *i_dquot[MAXQUOTAS]; -#endif - struct list_head i_devices; - union { - struct pipe_inode_info *i_pipe; - struct block_device *i_bdev; - struct cdev *i_cdev; - }; - - __u32 i_generation; - -#ifdef CONFIG_FSNOTIFY - __u32 i_fsnotify_mask; /* all events this inode cares about */ - struct hlist_head i_fsnotify_marks; -#endif - -#ifdef CONFIG_IMA - atomic_t i_readcount; /* struct files open RO */ -#endif - void *i_private; /* fs or device private pointer */ -}; -#endif - struct super_operations { struct inode *(*alloc_inode)(struct super_block *sb); void (*destroy_inode)(struct inode *); -- cgit v1.2.3 From ed8c4ba532b8853308226cdfeb12236511130f36 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 26 Mar 2018 20:20:59 +0200 Subject: ubifs: Remove Linux struct definitions we already have Signed-off-by: Sascha Hauer --- fs/ubifs/ubifs.h | 318 +------------------------------------------------------ 1 file changed, 1 insertion(+), 317 deletions(-) diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 5589f99401..1391bd7283 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include "ubifs-media.h" @@ -131,328 +132,11 @@ struct super_operations { long (*free_cached_objects)(struct super_block *, long, int); }; -#ifndef __BAREBOX__ -struct super_block { - struct list_head s_list; /* Keep this first */ - dev_t s_dev; /* search index; _not_ kdev_t */ - unsigned char s_blocksize_bits; - unsigned long s_blocksize; - loff_t s_maxbytes; /* Max file size */ - struct file_system_type *s_type; - const struct super_operations *s_op; - const struct dquot_operations *dq_op; - const struct quotactl_ops *s_qcop; - const struct export_operations *s_export_op; - unsigned long s_flags; - unsigned long s_magic; - struct dentry *s_root; - struct rw_semaphore s_umount; - int s_count; - atomic_t s_active; -#ifdef CONFIG_SECURITY - void *s_security; -#endif - const struct xattr_handler **s_xattr; - - struct list_head s_inodes; /* all inodes */ -#ifndef __BAREBOX__ - struct hlist_bl_head s_anon; /* anonymous dentries for (nfs) exporting */ -#endif - struct list_head s_mounts; /* list of mounts; _not_ for fs use */ - struct block_device *s_bdev; -#ifndef __BAREBOX__ - struct backing_dev_info *s_bdi; -#endif - struct mtd_info *s_mtd; - struct hlist_node s_instances; -#ifndef __BAREBOX__ - struct quota_info s_dquot; /* Diskquota specific options */ -#endif - - struct sb_writers s_writers; - - char s_id[32]; /* Informational name */ - u8 s_uuid[16]; /* UUID */ - - void *s_fs_info; /* Filesystem private info */ - unsigned int s_max_links; -#ifndef __BAREBOX__ - fmode_t s_mode; -#endif - - /* Granularity of c/m/atime in ns. - Cannot be worse than a second */ - u32 s_time_gran; - - /* - * The next field is for VFS *only*. No filesystems have any business - * even looking at it. You had been warned. - */ - struct mutex s_vfs_rename_mutex; /* Kludge */ - - /* - * Filesystem subtype. If non-empty the filesystem type field - * in /proc/mounts will be "type.subtype" - */ - char *s_subtype; - -#ifndef __BAREBOX__ - /* - * Saved mount options for lazy filesystems using - * generic_show_options() - */ - char __rcu *s_options; -#endif - const struct dentry_operations *s_d_op; /* default d_op for dentries */ - - /* - * Saved pool identifier for cleancache (-1 means none) - */ - int cleancache_poolid; - -#ifndef __BAREBOX__ - struct shrinker s_shrink; /* per-sb shrinker handle */ -#endif - - /* Number of inodes with nlink == 0 but still referenced */ - atomic_long_t s_remove_count; - - /* Being remounted read-only */ - int s_readonly_remount; - - /* AIO completions deferred from interrupt context */ - struct workqueue_struct *s_dio_done_wq; - -#ifndef __BAREBOX__ - /* - * Keep the lru lists last in the structure so they always sit on their - * own individual cachelines. - */ - struct list_lru s_dentry_lru ____cacheline_aligned_in_smp; - struct list_lru s_inode_lru ____cacheline_aligned_in_smp; -#endif - struct rcu_head rcu; -}; - -struct file_system_type { - const char *name; - int fs_flags; -#define FS_REQUIRES_DEV 1 -#define FS_BINARY_MOUNTDATA 2 -#define FS_HAS_SUBTYPE 4 -#define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ -#define FS_USERNS_DEV_MOUNT 16 /* A userns mount does not imply MNT_NODEV */ -#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ - struct dentry *(*mount) (struct file_system_type *, int, - const char *, void *); - void (*kill_sb) (struct super_block *); - struct module *owner; - struct file_system_type * next; - struct hlist_head fs_supers; - -#ifndef __BAREBOX__ - struct lock_class_key s_lock_key; - struct lock_class_key s_umount_key; - struct lock_class_key s_vfs_rename_key; - struct lock_class_key s_writers_key[SB_FREEZE_LEVELS]; - - struct lock_class_key i_lock_key; - struct lock_class_key i_mutex_key; - struct lock_class_key i_mutex_dir_key; -#endif -}; - -/* include/linux/mount.h */ -struct vfsmount { - struct dentry *mnt_root; /* root of the mounted tree */ - struct super_block *mnt_sb; /* pointer to superblock */ - int mnt_flags; -}; - -struct path { - struct vfsmount *mnt; - struct dentry *dentry; -}; - -struct file { - struct path f_path; -#define f_dentry f_path.dentry -#define f_vfsmnt f_path.mnt - const struct file_operations *f_op; - unsigned int f_flags; - loff_t f_pos; - unsigned int f_uid, f_gid; - - u64 f_version; -#ifdef CONFIG_SECURITY - void *f_security; -#endif - /* needed for tty driver, and maybe others */ - void *private_data; - -#ifdef CONFIG_EPOLL - /* Used by fs/eventpoll.c to link all the hooks to this file */ - struct list_head f_ep_links; - spinlock_t f_ep_lock; -#endif /* #ifdef CONFIG_EPOLL */ -#ifdef CONFIG_DEBUG_WRITECOUNT - unsigned long f_mnt_write_state; -#endif -}; -#endif - /* * get_seconds() not really needed in the read-only implmentation */ #define get_seconds() 0 -/* 4k page size */ -#define PAGE_CACHE_SHIFT 12 -#define PAGE_CACHE_SIZE (1 << PAGE_CACHE_SHIFT) - -#ifndef __BAREBOX__ -/* Page cache limit. The filesystems should put that into their s_maxbytes - limits, otherwise bad things can happen in VM. */ -#if BITS_PER_LONG==32 -#define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) -#elif BITS_PER_LONG==64 -#define MAX_LFS_FILESIZE 0x7fffffffffffffffUL -#endif - -/* - * These are the fs-independent mount-flags: up to 32 flags are supported - */ -#define MS_RDONLY 1 /* Mount read-only */ -#define MS_NOSUID 2 /* Ignore suid and sgid bits */ -#define MS_NODEV 4 /* Disallow access to device special files */ -#define MS_NOEXEC 8 /* Disallow program execution */ -#define MS_SYNCHRONOUS 16 /* Writes are synced at once */ -#define MS_REMOUNT 32 /* Alter flags of a mounted FS */ -#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */ -#define MS_DIRSYNC 128 /* Directory modifications are synchronous */ -#define MS_NOATIME 1024 /* Do not update access times. */ -#define MS_NODIRATIME 2048 /* Do not update directory access times */ -#define MS_BIND 4096 -#define MS_MOVE 8192 -#define MS_REC 16384 -#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence. - MS_VERBOSE is deprecated. */ -#define MS_SILENT 32768 -#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */ -#define MS_UNBINDABLE (1<<17) /* change to unbindable */ -#define MS_PRIVATE (1<<18) /* change to private */ -#define MS_SLAVE (1<<19) /* change to slave */ -#define MS_SHARED (1<<20) /* change to shared */ -#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */ -#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */ -#define MS_I_VERSION (1<<23) /* Update inode I_version field */ -#define MS_ACTIVE (1<<30) -#define MS_NOUSER (1<<31) - -#define I_NEW 8 - -/* Inode flags - they have nothing to superblock flags now */ - -#define S_SYNC 1 /* Writes are synced at once */ -#define S_NOATIME 2 /* Do not update access times */ -#define S_APPEND 4 /* Append-only file */ -#define S_IMMUTABLE 8 /* Immutable file */ -#define S_DEAD 16 /* removed, but still open directory */ -#define S_NOQUOTA 32 /* Inode is not counted to quota */ -#define S_DIRSYNC 64 /* Directory modifications are synchronous */ -#define S_NOCMTIME 128 /* Do not update file c/mtime */ -#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */ -#define S_PRIVATE 512 /* Inode is fs-internal */ - -/* include/linux/stat.h */ - -#define S_IFMT 00170000 -#define S_IFSOCK 0140000 -#define S_IFLNK 0120000 -#define S_IFREG 0100000 -#define S_IFBLK 0060000 -#define S_IFDIR 0040000 -#define S_IFCHR 0020000 -#define S_IFIFO 0010000 -#define S_ISUID 0004000 -#define S_ISGID 0002000 -#define S_ISVTX 0001000 - -/* include/linux/fs.h */ - -/* - * File types - * - * NOTE! These match bits 12..15 of stat.st_mode - * (ie "(i_mode >> 12) & 15"). - */ -#define DT_UNKNOWN 0 -#define DT_FIFO 1 -#define DT_CHR 2 -#define DT_DIR 4 -#define DT_BLK 6 -#define DT_REG 8 -#define DT_LNK 10 -#define DT_SOCK 12 -#define DT_WHT 14 - -#define I_DIRTY_SYNC 1 -#define I_DIRTY_DATASYNC 2 -#define I_DIRTY_PAGES 4 -#define I_NEW 8 -#define I_WILL_FREE 16 -#define I_FREEING 32 -#define I_CLEAR 64 -#define __I_LOCK 7 -#define I_LOCK (1 << __I_LOCK) -#define __I_SYNC 8 -#define I_SYNC (1 << __I_SYNC) - -#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) - -/* linux/include/dcache.h */ - -#define DNAME_INLINE_LEN_MIN 36 - -struct dentry { - unsigned int d_flags; /* protected by d_lock */ - spinlock_t d_lock; /* per dentry lock */ - struct inode *d_inode; /* Where the name belongs to - NULL is - * negative */ - /* - * The next three fields are touched by __d_lookup. Place them here - * so they all fit in a cache line. - */ - struct hlist_node d_hash; /* lookup hash list */ - struct dentry *d_parent; /* parent directory */ - struct qstr d_name; - - struct list_head d_lru; /* LRU list */ - /* - * d_child and d_rcu can share memory - */ - struct list_head d_subdirs; /* our children */ - struct list_head d_alias; /* inode alias list */ - unsigned long d_time; /* used by d_revalidate */ - struct super_block *d_sb; /* The root of the dentry tree */ - void *d_fsdata; /* fs-specific data */ -#ifdef CONFIG_PROFILING - struct dcookie_struct *d_cookie; /* cookie, if any */ -#endif - int d_mounted; - unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */ -}; -#endif -static inline ino_t parent_ino(struct dentry *dentry) -{ - ino_t res; - - spin_lock(&dentry->d_lock); - res = dentry->d_parent->d_inode->i_ino; - spin_unlock(&dentry->d_lock); - return res; -} - /* debug.c */ #define module_param_named(...) -- cgit v1.2.3 From fc90829f1cbc31122da9e9985af65fab02df16f3 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 29 Mar 2018 10:23:38 +0200 Subject: ubifs: remove dead code Remove code that was added to UBIFS for U-Boot but that is not needed for barebox. Signed-off-by: Sascha Hauer --- fs/ubifs/ubifs.c | 475 ------------------------------------------------------- 1 file changed, 475 deletions(-) diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index 0bb1c26d7d..a525b044b8 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -273,135 +273,6 @@ int __init ubifs_compressors_init(void) * ubifsls... */ -#ifndef __BAREBOX__ -static int filldir(struct ubifs_info *c, const char *name, int namlen, - u64 ino, unsigned int d_type) -{ - struct inode *inode; - char filetime[32]; - - switch (d_type) { - case UBIFS_ITYPE_REG: - printf("\t"); - break; - case UBIFS_ITYPE_DIR: - printf("\t"); - break; - case UBIFS_ITYPE_LNK: - printf("\t"); - break; - default: - printf("other\t"); - break; - } - - inode = ubifs_iget(c->vfs_sb, ino); - if (IS_ERR(inode)) { - printf("%s: Error in ubifs_iget(), ino=%lld ret=%p!\n", - __func__, ino, inode); - return -1; - } - ctime_r((time_t *)&inode->i_mtime, filetime); - printf("%9lld %24.24s ", inode->i_size, filetime); -#ifndef __BAREBOX__ - ubifs_iput(inode); -#endif - - printf("%s\n", name); - - return 0; -} - -static int ubifs_printdir(struct file *file, void *dirent) -{ - int err, over = 0; - struct qstr nm; - union ubifs_key key; - struct ubifs_dent_node *dent; - struct inode *dir = file->f_path.dentry->d_inode; - struct ubifs_info *c = dir->i_sb->s_fs_info; - - dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, file->f_pos); - - if (file->f_pos > UBIFS_S_KEY_HASH_MASK || file->f_pos == 2) - /* - * The directory was seek'ed to a senseless position or there - * are no more entries. - */ - return 0; - - if (file->f_pos == 1) { - /* Find the first entry in TNC and save it */ - lowest_dent_key(c, &key, dir->i_ino); - nm.name = NULL; - dent = ubifs_tnc_next_ent(c, &key, &nm); - if (IS_ERR(dent)) { - err = PTR_ERR(dent); - goto out; - } - - file->f_pos = key_hash_flash(c, &dent->key); - file->private_data = dent; - } - - dent = file->private_data; - if (!dent) { - /* - * The directory was seek'ed to and is now readdir'ed. - * Find the entry corresponding to @file->f_pos or the - * closest one. - */ - dent_key_init_hash(c, &key, dir->i_ino, file->f_pos); - nm.name = NULL; - dent = ubifs_tnc_next_ent(c, &key, &nm); - if (IS_ERR(dent)) { - err = PTR_ERR(dent); - goto out; - } - file->f_pos = key_hash_flash(c, &dent->key); - file->private_data = dent; - } - - while (1) { - dbg_gen("feed '%s', ino %llu, new f_pos %#x", - dent->name, (unsigned long long)le64_to_cpu(dent->inum), - key_hash_flash(c, &dent->key)); - ubifs_assert(le64_to_cpu(dent->ch.sqnum) > ubifs_inode(dir)->creat_sqnum); - - nm.len = le16_to_cpu(dent->nlen); - over = filldir(c, (char *)dent->name, nm.len, - le64_to_cpu(dent->inum), dent->type); - if (over) - return 0; - - /* Switch to the next entry */ - key_read(c, &dent->key, &key); - nm.name = (char *)dent->name; - dent = ubifs_tnc_next_ent(c, &key, &nm); - if (IS_ERR(dent)) { - err = PTR_ERR(dent); - goto out; - } - - kfree(file->private_data); - file->f_pos = key_hash_flash(c, &dent->key); - file->private_data = dent; - cond_resched(); - } - -out: - if (err != -ENOENT) { - ubifs_err(c, "cannot find next direntry, error %d", err); - return err; - } - - kfree(file->private_data); - file->private_data = NULL; - file->f_pos = 2; - return 0; -} -#endif - static int ubifs_finddir(struct super_block *sb, char *dirname, unsigned long root_inum, unsigned long *inum) { @@ -549,117 +420,6 @@ static unsigned long ubifs_findfile(struct super_block *sb, const char *filename return 0; } -#ifndef __BAREBOX__ -int ubifs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info) -{ - if (rbdd) { - debug("UBIFS cannot be used with normal block devices\n"); - return -1; - } - - /* - * Should never happen since get_device_and_partition() already checks - * this, but better safe then sorry. - */ - if (!ubifs_is_mounted()) { - debug("UBIFS not mounted, use ubifsmount to mount volume first!\n"); - return -1; - } - - return 0; -} - -int ubifs_ls(const char *filename) -{ - struct ubifs_info *c = ubifs_sb->s_fs_info; - struct file *file; - struct dentry *dentry; - struct inode *dir; - void *dirent = NULL; - unsigned long inum; - int ret = 0; - - c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY); - inum = ubifs_findfile(ubifs_sb, (char *)filename); - if (!inum) { - ret = -1; - goto out; - } - - file = kzalloc(sizeof(struct file), 0); - dentry = kzalloc(sizeof(struct dentry), 0); - dir = kzalloc(sizeof(struct inode), 0); - if (!file || !dentry || !dir) { - printf("%s: Error, no memory for malloc!\n", __func__); - ret = -ENOMEM; - goto out_mem; - } - - dir->i_sb = ubifs_sb; - file->f_path.dentry = dentry; - file->f_path.dentry->d_parent = dentry; - file->f_path.dentry->d_inode = dir; - file->f_path.dentry->d_inode->i_ino = inum; - file->f_pos = 1; - file->private_data = NULL; - ubifs_printdir(file, dirent); - -out_mem: - if (file) - free(file); - if (dentry) - free(dentry); - if (dir) - free(dir); - -out: - ubi_close_volume(c->ubi); - return ret; -} - -int ubifs_exists(const char *filename) -{ - struct ubifs_info *c = ubifs_sb->s_fs_info; - unsigned long inum; - - c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY); - inum = ubifs_findfile(ubifs_sb, (char *)filename); - ubi_close_volume(c->ubi); - - return inum != 0; -} - -int ubifs_size(const char *filename, loff_t *size) -{ - struct ubifs_info *c = ubifs_sb->s_fs_info; - unsigned long inum; - struct inode *inode; - int err = 0; - - c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY); - - inum = ubifs_findfile(ubifs_sb, (char *)filename); - if (!inum) { - err = -1; - goto out; - } - - inode = ubifs_iget(ubifs_sb, inum); - if (IS_ERR(inode)) { - printf("%s: Error reading inode %ld!\n", __func__, inum); - err = PTR_ERR(inode); - goto out; - } - - *size = inode->i_size; - - ubifs_iput(inode); -out: - ubi_close_volume(c->ubi); - return err; -} -#endif - /* * ubifsload... */ @@ -718,241 +478,6 @@ dump: return -EINVAL; } -#ifndef __BAREBOX__ -static int do_readpage(struct ubifs_info *c, struct inode *inode, - struct page *page, int last_block_size) -{ - void *addr; - int err = 0, i; - unsigned int block, beyond; - struct ubifs_data_node *dn; - loff_t i_size = inode->i_size; - - dbg_gen("ino %lu, pg %lu, i_size %lld", - inode->i_ino, page->index, i_size); - - addr = kmap(page); - - block = page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT; - beyond = (i_size + UBIFS_BLOCK_SIZE - 1) >> UBIFS_BLOCK_SHIFT; - if (block >= beyond) { - /* Reading beyond inode */ - memset(addr, 0, PAGE_CACHE_SIZE); - goto out; - } - - dn = kmalloc(UBIFS_MAX_DATA_NODE_SZ, GFP_NOFS); - if (!dn) - return -ENOMEM; - - i = 0; - while (1) { - int ret; - - if (block >= beyond) { - /* Reading beyond inode */ - err = -ENOENT; - memset(addr, 0, UBIFS_BLOCK_SIZE); - } else { - /* - * Reading last block? Make sure to not write beyond - * the requested size in the destination buffer. - */ - if (((block + 1) == beyond) || last_block_size) { - void *buff; - int dlen; - - /* - * We need to buffer the data locally for the - * last block. This is to not pad the - * destination area to a multiple of - * UBIFS_BLOCK_SIZE. - */ - buff = kzalloc(UBIFS_BLOCK_SIZE, 0); - if (!buff) { - printf("%s: Error, malloc fails!\n", - __func__); - err = -ENOMEM; - break; - } - - /* Read block-size into temp buffer */ - ret = read_block(inode, buff, block, dn); - if (ret) { - err = ret; - if (err != -ENOENT) { - free(buff); - break; - } - } - - if (last_block_size) - dlen = last_block_size; - else - dlen = le32_to_cpu(dn->size); - - /* Now copy required size back to dest */ - memcpy(addr, buff, dlen); - - free(buff); - } else { - ret = read_block(inode, addr, block, dn); - if (ret) { - err = ret; - if (err != -ENOENT) - break; - } - } - } - if (++i >= UBIFS_BLOCKS_PER_PAGE) - break; - block += 1; - addr += UBIFS_BLOCK_SIZE; - } - if (err) { - if (err == -ENOENT) { - /* Not found, so it must be a hole */ - dbg_gen("hole"); - goto out_free; - } - ubifs_err(c, "cannot read page %lu of inode %lu, error %d", - page->index, inode->i_ino, err); - goto error; - } - -out_free: - kfree(dn); -out: - return 0; - -error: - kfree(dn); - return err; -} - -int ubifs_read(const char *filename, void *buf, loff_t offset, - loff_t size, loff_t *actread) -{ - struct ubifs_info *c = ubifs_sb->s_fs_info; - unsigned long inum; - struct inode *inode; - struct page page; - int err = 0; - int i; - int count; - int last_block_size = 0; - - *actread = 0; - - if (offset & (PAGE_SIZE - 1)) { - printf("ubifs: Error offset must be a multple of %d\n", - PAGE_SIZE); - return -1; - } - - c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY); - /* ubifs_findfile will resolve symlinks, so we know that we get - * the real file here */ - inum = ubifs_findfile(ubifs_sb, (char *)filename); - if (!inum) { - err = -1; - goto out; - } - - /* - * Read file inode - */ - inode = ubifs_iget(ubifs_sb, inum); - if (IS_ERR(inode)) { - printf("%s: Error reading inode %ld!\n", __func__, inum); - err = PTR_ERR(inode); - goto out; - } - - if (offset > inode->i_size) { - printf("ubifs: Error offset (%lld) > file-size (%lld)\n", - offset, size); - err = -1; - goto put_inode; - } - - /* - * If no size was specified or if size bigger than filesize - * set size to filesize - */ - if ((size == 0) || (size > (inode->i_size - offset))) - size = inode->i_size - offset; - - count = (size + UBIFS_BLOCK_SIZE - 1) >> UBIFS_BLOCK_SHIFT; - - page.addr = buf; - page.index = offset / PAGE_SIZE; - page.inode = inode; - for (i = 0; i < count; i++) { - /* - * Make sure to not read beyond the requested size - */ - if (((i + 1) == count) && (size < inode->i_size)) - last_block_size = size - (i * PAGE_SIZE); - - err = do_readpage(c, inode, &page, last_block_size); - if (err) - break; - - page.addr += PAGE_SIZE; - page.index++; - } - - if (err) { - printf("Error reading file '%s'\n", filename); - *actread = i * PAGE_SIZE; - } else { - *actread = size; - } - -put_inode: - ubifs_iput(inode); - -out: - ubi_close_volume(c->ubi); - return err; -} - -void ubifs_close(void) -{ -} - -/* Compat wrappers for common/cmd_ubifs.c */ -int ubifs_load(char *filename, u32 addr, u32 size) -{ - loff_t actread; - int err; - - printf("Loading file '%s' to addr 0x%08x...\n", filename, addr); - - err = ubifs_read(filename, (void *)addr, 0, size, &actread); - if (err == 0) { - setenv_hex("filesize", actread); - printf("Done\n"); - } - - return err; -} -#endif - -void uboot_ubifs_umount(void) -{ - if (ubifs_sb) { - printf("Unmounting UBIFS volume %s!\n", - ((struct ubifs_info *)(ubifs_sb->s_fs_info))->vi.name); - ubifs_umount(ubifs_sb->s_fs_info); - ubifs_sb = NULL; - } -} - - - - struct ubifs_file { struct inode *inode; void *buf; -- cgit v1.2.3 From 99ae5d04065323d25c27af0c92b155d6e17e85a8 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 26 Mar 2018 20:33:08 +0200 Subject: fs: Add super_operations Add a struct super_operations we can use later when we get a fs implementation closer to Linux. Only add the functions we'll likely need though. Signed-off-by: Sascha Hauer --- fs/ubifs/super.c | 4 ---- fs/ubifs/ubifs.h | 35 ----------------------------------- include/linux/fs.h | 5 +++++ 3 files changed, 5 insertions(+), 39 deletions(-) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index ce6e95e373..b4eb76202b 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -556,7 +556,6 @@ out: done: clear_inode(inode); } -#endif static void ubifs_dirty_inode(struct inode *inode, int flags) { @@ -569,7 +568,6 @@ static void ubifs_dirty_inode(struct inode *inode, int flags) } } -#ifndef __BAREBOX__ static int ubifs_statfs(struct dentry *dentry, struct kstatfs *buf) { struct ubifs_info *c = dentry->d_sb->s_fs_info; @@ -2107,9 +2105,7 @@ const struct super_operations ubifs_super_operations = { .write_inode = ubifs_write_inode, .evict_inode = ubifs_evict_inode, .statfs = ubifs_statfs, -#endif .dirty_inode = ubifs_dirty_inode, -#ifndef __BAREBOX__ .remount_fs = ubifs_remount_fs, .show_options = ubifs_show_options, .sync_fs = ubifs_sync_fs, diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 1391bd7283..22b24a1161 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -97,41 +97,6 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp); /* uapi/linux/limits.h */ #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ -struct super_operations { - struct inode *(*alloc_inode)(struct super_block *sb); - void (*destroy_inode)(struct inode *); - - void (*dirty_inode) (struct inode *, int flags); -#ifndef __BAREBOX__ - int (*write_inode) (struct inode *, struct writeback_control *wbc); -#endif - int (*drop_inode) (struct inode *); - void (*evict_inode) (struct inode *); - void (*put_super) (struct super_block *); - int (*sync_fs)(struct super_block *sb, int wait); - int (*freeze_fs) (struct super_block *); - int (*unfreeze_fs) (struct super_block *); -#ifndef __BAREBOX__ - int (*statfs) (struct dentry *, struct kstatfs *); -#endif - int (*remount_fs) (struct super_block *, int *, char *); - void (*umount_begin) (struct super_block *); - -#ifndef __BAREBOX__ - int (*show_options)(struct seq_file *, struct dentry *); - int (*show_devname)(struct seq_file *, struct dentry *); - int (*show_path)(struct seq_file *, struct dentry *); - int (*show_stats)(struct seq_file *, struct dentry *); -#endif -#ifdef CONFIG_QUOTA - ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); - ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); -#endif - int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); - long (*nr_cached_objects)(struct super_block *, int); - long (*free_cached_objects)(struct super_block *, long, int); -}; - /* * get_seconds() not really needed in the read-only implmentation */ diff --git a/include/linux/fs.h b/include/linux/fs.h index c1a5802eea..153c464470 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -252,6 +252,11 @@ struct file { #endif }; +struct super_operations { + struct inode *(*alloc_inode)(struct super_block *sb); + void (*destroy_inode)(struct inode *); +}; + /* * Inode flags - they have no relation to superblock flags now */ -- cgit v1.2.3 From 74e20630f23319f62b3aeb805dd1e444a5159725 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 26 Mar 2018 20:41:56 +0200 Subject: fs: Move mem_write/mem_read to devfs-core fs.c is already heavily filled with code. Move mem_write/mem_read to devfs-core where it fits better. Signed-off-by: Sascha Hauer --- fs/devfs-core.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/fs.c | 66 ------------------------------------------------------- 2 files changed, 68 insertions(+), 66 deletions(-) diff --git a/fs/devfs-core.c b/fs/devfs-core.c index d06a534b57..6b5e6da6a8 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -513,3 +513,71 @@ void cdev_remove_loop(struct cdev *cdev) free(cdev->name); free(cdev); } + +static void memcpy_sz(void *dst, const void *src, size_t count, int rwsize) +{ + /* no rwsize specification given. Do whatever memcpy likes best */ + if (!rwsize) { + memcpy(dst, src, count); + return; + } + + rwsize = rwsize >> O_RWSIZE_SHIFT; + + count /= rwsize; + + while (count-- > 0) { + switch (rwsize) { + case 1: + *((u8 *)dst) = *((u8 *)src); + break; + case 2: + *((u16 *)dst) = *((u16 *)src); + break; + case 4: + *((u32 *)dst) = *((u32 *)src); + break; + case 8: + *((u64 *)dst) = *((u64 *)src); + break; + } + dst += rwsize; + src += rwsize; + } +} + +ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, + unsigned long flags) +{ + unsigned long size; + struct device_d *dev; + + if (!cdev->dev || cdev->dev->num_resources < 1) + return -1; + dev = cdev->dev; + + size = min((resource_size_t)count, + resource_size(&dev->resource[0]) - + (resource_size_t)offset); + memcpy_sz(buf, dev_get_mem_region(dev, 0) + offset, size, flags & O_RWSIZE_MASK); + return size; +} +EXPORT_SYMBOL(mem_read); + +ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, + unsigned long flags) +{ + unsigned long size; + struct device_d *dev; + + if (!cdev->dev || cdev->dev->num_resources < 1) + return -1; + dev = cdev->dev; + + size = min((resource_size_t)count, + resource_size(&dev->resource[0]) - + (resource_size_t)offset); + memcpy_sz(dev_get_mem_region(dev, 0) + offset, buf, size, flags & O_RWSIZE_MASK); + return size; +} +EXPORT_SYMBOL(mem_write); diff --git a/fs/fs.c b/fs/fs.c index 5135112c8b..ca4fe70e15 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -1739,72 +1739,6 @@ out: } EXPORT_SYMBOL(rmdir); -static void memcpy_sz(void *dst, const void *src, size_t count, int rwsize) -{ - /* no rwsize specification given. Do whatever memcpy likes best */ - if (!rwsize) { - memcpy(dst, src, count); - return; - } - - rwsize = rwsize >> O_RWSIZE_SHIFT; - - count /= rwsize; - - while (count-- > 0) { - switch (rwsize) { - case 1: - *((u8 *)dst) = *((u8 *)src); - break; - case 2: - *((u16 *)dst) = *((u16 *)src); - break; - case 4: - *((u32 *)dst) = *((u32 *)src); - break; - case 8: - *((u64 *)dst) = *((u64 *)src); - break; - } - dst += rwsize; - src += rwsize; - } -} - -ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags) -{ - ulong size; - struct device_d *dev; - - if (!cdev->dev || cdev->dev->num_resources < 1) - return -1; - dev = cdev->dev; - - size = min((resource_size_t)count, - resource_size(&dev->resource[0]) - - (resource_size_t)offset); - memcpy_sz(buf, dev_get_mem_region(dev, 0) + offset, size, flags & O_RWSIZE_MASK); - return size; -} -EXPORT_SYMBOL(mem_read); - -ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags) -{ - ulong size; - struct device_d *dev; - - if (!cdev->dev || cdev->dev->num_resources < 1) - return -1; - dev = cdev->dev; - - size = min((resource_size_t)count, - resource_size(&dev->resource[0]) - - (resource_size_t)offset); - memcpy_sz(dev_get_mem_region(dev, 0) + offset, buf, size, flags & O_RWSIZE_MASK); - return size; -} -EXPORT_SYMBOL(mem_write); - /* * cdev_get_mount_path - return the path a cdev is mounted on * -- cgit v1.2.3 From 0afcc779a2b8aa1b9893ce2eff484750661d6045 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 19 Mar 2018 15:11:00 +0100 Subject: fs: Cleanup whitespace damage fs.c has some whitespaces where there should be tabs. Fix it. Signed-off-by: Sascha Hauer --- fs/fs.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index ca4fe70e15..92f336b821 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -99,13 +99,13 @@ char *normalise_path(const char *pathname) slashes[0] = in = out = path; - while (*in) { - if(*in == '/') { + while (*in) { + if(*in == '/') { slashes[sl++] = out; - *out++ = *in++; - while(*in == '/') - in++; - } else { + *out++ = *in++; + while(*in == '/') + in++; + } else { if (*in == '.' && (*(in + 1) == '/' || !*(in + 1))) { sl--; if (sl < 0) @@ -123,16 +123,16 @@ char *normalise_path(const char *pathname) continue; } *out++ = *in++; - } - } + } + } *out-- = 0; - /* - * Remove trailing slash - */ - if (*out == '/') - *out = 0; + /* + * Remove trailing slash + */ + if (*out == '/') + *out = 0; if (!*path) { *path = '/'; -- cgit v1.2.3 From 7156e859b6ddf2415a3c572c686df180c90ab249 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 19 Mar 2018 15:16:37 +0100 Subject: fs: Fix finding correct directory for mkdir/rmdir When there are links in the path mkdir/rmdir are called with then canonicalize_path is needed which resolves the links. Signed-off-by: Sascha Hauer --- fs/fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 92f336b821..b66cc9b178 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -1660,7 +1660,7 @@ int mkdir (const char *pathname, mode_t mode) { struct fs_driver_d *fsdrv; struct fs_device_d *fsdev; - char *p = normalise_path(pathname); + char *p = canonicalize_path(pathname); char *freep = p; int ret; struct stat s; @@ -1700,7 +1700,7 @@ int rmdir (const char *pathname) { struct fs_driver_d *fsdrv; struct fs_device_d *fsdev; - char *p = normalise_path(pathname); + char *p = canonicalize_path(pathname); char *freep = p; int ret; struct stat s; -- cgit v1.2.3 From b7df35d081673097a5e4f2cc5fcdfeaceaba16a9 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 28 Mar 2018 14:23:57 +0200 Subject: glob: do not unnecessarily opendir() a directory opendir() can trigger automounts, so do not use it when the pattern we examine doesn't have any wildcards. Signed-off-by: Sascha Hauer --- lib/glob.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/glob.c b/lib/glob.c index 5a997ca092..32f7afdce8 100644 --- a/lib/glob.c +++ b/lib/glob.c @@ -313,7 +313,7 @@ static int prefix_array(const char *dirname, char **array, size_t n, static int glob_in_dir(const char *pattern, const char *directory, int flags, int (*errfunc) __P((const char *, int)), glob_t *pglob) { - __ptr_t stream; + __ptr_t stream = NULL; struct globlink { struct globlink *next; @@ -323,7 +323,13 @@ static int glob_in_dir(const char *pattern, const char *directory, size_t nfound = 0; int meta; - stream = opendir(directory); + meta = glob_pattern_p(pattern, !(flags & GLOB_NOESCAPE)); + + if (meta) + flags |= GLOB_MAGCHAR; + + if (meta) + stream = opendir(directory); if (stream == NULL) { if ((errfunc != NULL && (*errfunc) (directory, errno)) || @@ -331,11 +337,6 @@ static int glob_in_dir(const char *pattern, const char *directory, return GLOB_ABORTED; } - meta = glob_pattern_p(pattern, !(flags & GLOB_NOESCAPE)); - - if (meta) - flags |= GLOB_MAGCHAR; - while (1) { const char *name; size_t len; -- cgit v1.2.3 From 70d65438e5fdc8ff7505175299e2d63c0b56db03 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 29 Mar 2018 13:59:57 +0200 Subject: ls: Do not depend on normalise_path() When we want to show a directory we want to show the path ls is passed, not the normalised one. Signed-off-by: Sascha Hauer --- commands/ls.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/commands/ls.c b/commands/ls.c index 771477b6e0..e54991862d 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -115,11 +115,8 @@ int ls(const char *path, ulong flags) continue; } - if (s.st_mode & S_IFDIR) { - char *norm = normalise_path(tmp); - ls(norm, flags); - free(norm); - } + if (s.st_mode & S_IFDIR) + ls(tmp, flags); } out: @@ -158,7 +155,7 @@ static int do_ls(int argc, char *argv[]) flags |= LS_SHOWARG; if (optind == argc) { - ret = ls(getcwd(), flags); + ret = ls(".", flags); return ret ? 1 : 0; } -- cgit v1.2.3 From 46e7bfbac6fa7d674e0536e012a2cb6af16abd34 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 29 Mar 2018 13:50:57 +0200 Subject: loadenv: Do not depend on normalise_path() normalise_path() will go away, so do without it. Signed-off-by: Sascha Hauer --- commands/loadenv.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/commands/loadenv.c b/commands/loadenv.c index 44e96c3b60..6469affadb 100644 --- a/commands/loadenv.c +++ b/commands/loadenv.c @@ -62,20 +62,16 @@ static int do_loadenv(int argc, char *argv[]) if (argc - optind < 1) { filename = default_environment_path_get(); } else { - char *str = normalise_path(argv[optind]); - /* * /dev/defaultenv use to contain the defaultenvironment. * we do not have this file anymore, but maintain compatibility * to the 'loadenv -s /dev/defaultenv' command to restore the * default environment for some time. */ - if (!strcmp(str, "/dev/defaultenv")) + if (!strcmp(argv[optind], "/dev/defaultenv")) defaultenv = 1; else filename = argv[optind]; - - free(str); } if (scrub) { -- cgit v1.2.3