summaryrefslogtreecommitdiff
path: root/fs
Commit message (Collapse)AuthorAgeFilesLines
...
| * tftp: allow to change tftp portEnrico Scholz2022-08-311-2/+5
| | | | | | | | | | | | | | | | | | | | This adds a 'port=<port>' mount option for tftp filesystems. Useful e.g. when working with a local, non-privileged tftp server Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-3-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * tftp: add some 'const' annotationsEnrico Scholz2022-08-311-1/+1
| | | | | | | | | | | | Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Link: https://lore.barebox.org/20220830073816.2694734-2-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2022-09-144-45/+53
|\ \
| * | ubifs: Fix pointer type mismatch in gzip decompressorSascha Hauer2022-09-131-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | deflate_decompress() takes a unsigned int * for the out_len argument whereas ubifs passes a size_t * argument. Adjust the argument type accordingly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: ubifs: remove always-false checkAhmad Fatoum2022-09-131-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC correctly warns that two bit wide compr_type can't exceed or be equal to UBIFS_COMPR_TYPES_CNT (== 4). Remove the check. The check is there in the kernel as well, but the warning is disabled there. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220811135804.271071-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: export cdev_get_linux_rootarg() for reuseAhmad Fatoum2022-08-161-15/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We've the root=PARTUUID=%s generation at two places: Once to populate fsdev->linux_rootarg and once to handle struct bootm_data::root_dev. In preparation for dropping the duplicate out-of-sync code in the bootm code, export the originl fs/fs.c code as cdev_get_linux_rootarg(). Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220815114835.2277946-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | pstore: ram: use new of_fixup_reserved_memory() helperAhmad Fatoum2022-08-161-23/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new of_fixup_reserved_memory() can handle everything that the opencoded version in pstore can with the added benefit that it correctly handles #address-cells/#size-cells != 1, which previously were just assumed to be 1. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220815114246.2275465-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | pstore: disable double memory reservation fixupAhmad Fatoum2022-08-161-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Device tree fixup ramoops_of_fixup registered directly after of_add_reserve_entry already takes care to create a /reserved-memory entry, so adding one to the FDT reserved memory list is redundant. Thus keep only the /reserved-memory entry. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220815064001.702879-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | fs: drop duplicate follow_managed() callAhmad Fatoum2022-09-121-10/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | lookup_fast called above already calls follow_managed with the same argument, so no need to duplicate the call here. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905095557.596891-30-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | fs: fat: propagate f_lseek failureAhmad Fatoum2022-09-121-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | We store an error code to ret, but don't act on it. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905095557.596891-29-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | fs: ext4: ext_barebox: handle ext_get_inode() errorsAhmad Fatoum2022-09-121-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | Static analyzer laments ext_get_inode, which can fail not having its failure condition checked. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905095557.596891-28-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | fs: remove never-read initializer in mount_all()Ahmad Fatoum2022-09-121-1/+1
| |/ |/| | | | | | | | | | | | | | | list_for_each_entry will initialize cdev for each iteration, so the initial assignment is never used, thus drop it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905095557.596891-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: ubootvarfs: fix double-free unlinking U-Boot variablesAhmad Fatoum2022-08-221-0/+1
|/ | | | | | | | | | | | We free the struct ubootvarfs_inode::var as part of destroy_inode. In case we have unlinked the U-Boot variable beforehand, we will end up double-freeing. Set the member to NULL, so it's skipped in destory_inode. We keep the free in destroy_inode, because that's still needed for all the other inodes that aren't unlinked. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220819105521.3848169-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2022-08-111-0/+4
|\
| * fs: Check if automount actually mounts somethingSascha Hauer2022-07-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | An automount command that returns successfully but doesn't mount anything makes barebox hang as can be reproduced with: automount -d /mnt/foo true ls /mnt/foo Check if the current dentry is a mountpoint after running the automount command, otherwise return with an error from automount_mount(). Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/compression'Sascha Hauer2022-08-112-4/+4
|\ \
| * | lib: zstd: sync with LinuxAhmad Fatoum2022-08-082-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Import the Linux v5.18.3 state of the zstd decompression code. The compressor was omitted and error strings were disabled for PBL. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220713100922.1880282-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/at91'Sascha Hauer2022-08-111-1/+1
|\ \ \ | |/ / |/| |
| * | pbl: factor out pbl_bio API into pbl/bio.hAhmad Fatoum2022-08-081-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | We'll be adding more PBL driver interface definitions into include/pbl, so move the block I/O stuff there as well. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220805082137.2202560-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ubifs: fix crash building without decompressorsAhmad Fatoum2022-07-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When building barebox with ubifs support, but without decompressors enabled, we run into a NULL pointer dereference: BUG: failure at lib/string.c:249/strncmp()! BUG! [<4fd8ea59>] (unwind_backtrace+0x1/0x78) from [<4fd014e5>] (panic+0x1d/0x34) [<4fd014e5>] (panic+0x1d/0x34) from [<4fd65ed1>] (strncmp+0x2d/0x50) [<4fd65ed1>] (strncmp+0x2d/0x50) from [<4fd784bb>] (compr_init+0x4b/0x70) [<4fd784bb>] (compr_init+0x4b/0x70) from [<4fd78915>] (ubifs_compressors_init+0x15/0x40) [<4fd78915>] (ubifs_compressors_init+0x15/0x40) from [<4fd78e89>] (ubifs_init+0x2d/0x48) [<4fd78e89>] (ubifs_init+0x2d/0x48) from [<4fd01159>] (start_barebox+0x35/0x6c) [<4fd01159>] (start_barebox+0x35/0x6c) from [<4fd8c9f3>] (barebox_non_pbl_start+0x127/0x170) [<4fd8c9f3>] (barebox_non_pbl_start+0x127/0x170) from [<4fd00005>] (__bare_init_start+0x1/0xc) This is because the loop in crypto_alloc_comp iterates over all possible decompressors and then accesses comp->capi_name, which will be NULL for unusable decompressors. Add a NULL check to handle this gracefully. A check for alg_name isn't needed because it's already checked in compr_init. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220713092047.1588210-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | devfs: Fix device name in overlap error messageUwe Kleine-König2022-07-111-1/+1
| | | | | | | | | | | | | | | | | | cpart->name contains the partition name, not the device name. Use cdev->name instead. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.barebox.org/20220711090915.1487105-2-u.kleine-koenig@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | devfs: take into account for the partitions check that mtd is differentUwe Kleine-König2022-07-111-2/+13
|/ | | | | | | | | | | mtd partitions are separate devices. Their partition info is relative to these subdevices and so offset is 0 for them. This needs to be taken into account for the overlap check. Fixes: 7f9f45b9bfef ("devfs: Do not create overlapping partitions") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.barebox.org/20220711090915.1487105-1-u.kleine-koenig@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Remove duplicate incudesAlexander Shiyan2022-06-105-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix warning fwterated by checkincludes.pl: ./net/nfs.c: libgen.h is included more than once. ./net/ifup.c: globalvar.h is included more than once. ./crypto/rsa.c: asm/types.h is included more than once. ./lib/decompress_unlz4.c: linux/decompress/mm.h is included more than once. ./scripts/stb_image.h: stdio.h is included more than once. ./scripts/kwbimage.c: unistd.h is included more than once. ./scripts/common.c: sys/types.h is included more than once. ./scripts/bareboximd.c: sys/types.h is included more than once. ./scripts/bareboximd.c: sys/mman.h is included more than once. ./fs/pstore/ram_core.c: linux/rslib.h is included more than once. ./fs/pstore/fs.c: fs.h is included more than once. ./fs/pstore/fs.c: linux/pstore.h is included more than once. ./fs/nfs.c: fs.h is included more than once. ./fs/uimagefs.c: fs.h is included more than once. ./fs/fs.c: command.h is included more than once. ./arch/sandbox/board/hostfile.c: linux/err.h is included more than once. ./arch/sandbox/board/devices.c: mach/linux.h is included more than once. ./arch/sandbox/os/common.c: signal.h is included more than once. ./arch/arm/boards/zii-imx51-rdu1/board.c: envfs.h is included more than once. ./arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c: generated/mach-types.h is ./arch/arm/mach-stm32mp/ddrctrl.c: mach/stm32.h is included more than once. ./arch/arm/mach-imx/cpu_init.c: common.h is included more than once. ./arch/arm/mach-imx/imx8m.c: mach/imx8m-ccm-regs.h is included more than once. ./common/efi/payload/init.c: efi.h is included more than once. ./common/state/backend_format_raw.c: common.h is included more than once. ./common/state/backend_format_raw.c: crc.h is included more than once. ./common/hush.c: libbb.h is included more than once. ./drivers/spi/atmel-quadspi.c: linux/clk.h is included more than once. ./drivers/spi/atmel-quadspi.c: linux/err.h is included more than once. ./drivers/net/virtio.c: net.h is included more than once. ./drivers/net/phy/phy.c: linux/phy.h is included more than once. ./drivers/net/cpsw.c: net.h is included more than once. ./drivers/virtio/virtio_pci_common.h: linux/list.h is included more than once. ./drivers/usb/host/ohci-hcd.c: dma.h is included more than once. ./drivers/usb/gadget/fsl_udc.c: dma.h is included more than once. ./drivers/nvmem/eeprom_93xx46.c: spi/spi.h is included more than once. ./drivers/nvmem/eeprom_93xx46.c: of.h is included more than once. ./drivers/video/imx-ipu-v3/imx-ldb.c: linux/clk.h is included more than once. ./drivers/video/imx-ipu-v3/imx-hdmi.c: linux/clk.h is included more than once. ./drivers/video/omap.c: common.h is included more than once. ./drivers/mtd/nand/nand_s3c24xx.c: asm/sections.h is included more than once. ./drivers/clk/imx/clk-imx6sx.c: linux/clk.h is included more than once. ./drivers/clk/imx/clk-imx6sl.c: linux/clk.h is included more than once. ./commands/bootm.c: of.h is included more than once. Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220607051957.2497-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* block: set S_IFBLK for block devices instead of S_IFCHRAhmad Fatoum2022-06-102-1/+7
| | | | | | | | | | | | | | | | | | In barebox, block devices are a special case of character devices. Nevertheless, differentiation can be useful to allow scripts iterating over all block devices without accounting for naming, e.g. for dev in /dev/*; do test -b $dev && echo $dev: blockdevice done Add the necessary support. This will break scripts that assume test -c blockdevice to be true, but that's a quite improbable check. Tested-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20220602195916.9061-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ubifs'Sascha Hauer2022-02-183-0/+59
|\
| * ubifs: Add zstd supportSascha Hauer2022-02-073-0/+59
| | | | | | | | | | | | | | zstd shows a good compression rate and is faster than lzo. This adds UBIFS support for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/efi'Sascha Hauer2022-02-183-58/+103
|\ \
| * | cdev: create iterator for cdev listSascha Hauer2022-02-082-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | This creates an iterator to iterate over all availabe cdevs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20220207094953.949868-7-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | cdev: Create missing cdev_* functionsSascha Hauer2022-02-082-40/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have several functions like cdev_read(), cdev_write() and others. For consistency create the remaining functions: cdev_lseek(), cdev_protect(), cdev_discard_range(), cdev_memmap() and cdev_truncate() Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20220207094953.949868-6-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | cdev: implement cdev_open()Sascha Hauer2022-02-081-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement cdev_open() with the expected semantics that takes a struct cdev * argument. We already have an unimplemented prototype cdev_do_open(), remove this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220207094953.949868-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | rename cdev_open() -> cdev_open_by_name()Sascha Hauer2022-02-082-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The cdev_* functions normally take a struct cdev * argument, with the exception of cdev_open(). Rename cdev_open() to cdev_open_by_name() to be able to implement cdev_open() with the expected semantics in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220207094953.949868-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | cdev: add diskuuid supportMichael Olbrich2022-02-081-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows identifying disks by UUID. For disks with GPT the disk GUID is used. For DOS partition tables the NT signature ist used, similar to how the partuuid is generated. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Link: https://lore.barebox.org/20220124100458.2924679-3-m.olbrich@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20220207094953.949868-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | cdev: rename partuuid to uuidMichael Olbrich2022-02-082-3/+3
| |/ | | | | | | | | | | | | | | | | | | | | Partitions are not the only devices that can have UUIDs. Change the name to something more generic to prepare for other users. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Link: https://lore.barebox.org/20220124100458.2924679-2-m.olbrich@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20220207094953.949868-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/doc'Sascha Hauer2022-02-181-0/+2
|\ \
| * | commands: add missing command groupsAhmad Fatoum2022-01-261-0/+2
| |/ | | | | | | | | | | | | | | | | CMD_GRP_MISC is assumed in absence of an explicit group. Let's be explicit instead to silence the warnings during documentation build. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220124151827.3313412-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: jffs2: fix error when reading blocks with offsetHolger Assmann2022-02-081-1/+5
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | This bug resulted in a panic when trying to read a file partially with an offset, e.g. when starting Linux. In such a case a header is loaded by a separate call of jffs2_read(), which then copies only the first n bytes out of the respective block. When the remaining data of the block is then subsequently going to to be read the system deviates in its behaviour from that under Linux by not calling jffs2_read_inode_range() in a 4k-alignment, but with an offset. jffs2_read_inode_range() originates from the Linux jffs2 driver. When being called with an offset it still reads 4096 bytes of data and eventually returns fragments of two consecutive blocks. jffs2_read() then reads this result whilst again applying the offset, therefore returning faulty data. We fix that problem by calling jffs2_get_block() without an offset and therefore reading the whole block. The offset is then applied when we actually perform memcpy with the returned buffer. This fix might also increase the performance since the respective block is likely to be cached from the previous call. Signed-off-by: Holger Assmann <h.assmann@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220207173239.772421-1-h.assmann@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spdx'Sascha Hauer2022-01-1945-73/+70
|\
| * treewide: add SPDX-License-Identifier for files without explicit licenseAhmad Fatoum2022-01-056-0/+12
| | | | | | | | | | | | | | | | | | Record GPL-2.0-only as license for all files lacking an explicit license statement. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-12-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: jffs2: add SPDX-License-Identifier: GPL-2.0-onlyAhmad Fatoum2022-01-0524-73/+29
| | | | | | | | | | | | | | | | | | The files refer to the (Linux) top-level LICENSE file. Replace that with GPL-2.0-only. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * treewide: add SPDX-License-Identifier for Kbuild/KconfigAhmad Fatoum2022-01-0515-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To verify only Kconfig/Makefile is touched: git show --numstat --format=oneline HEAD | grep -v 'Kconfig\|Makefile' will print only arch/powerpc/Kbuild. To verify nothing unexpected is added: git show -U0 | grep '^-[^-]\|^+[^+]' | sort -u Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: implement pushd/popd chdir wrappersAhmad Fatoum2022-01-121-0/+30
|/ | | | | | | | | | | We don't have dirfd's, so running operations relative to the current working directory always involves some allocation/freeing boilerplate. Add pushd/popd helpers to move the boilerplate out of the callsites. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220108171555.588426-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/efi'Sascha Hauer2021-12-153-107/+29
|\
| * efi: centralize efivarfs_parse_filenameAhmad Fatoum2021-11-251-76/+0
| | | | | | | | | | | | | | | | | | Turning an EFI varfs filename into its components will be useful for the EFI loader as well, so factor that out. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211122084732.2597109-15-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * efi: rename <efi/efi.h> to <efi/efi-payload.h>Ahmad Fatoum2021-11-252-2/+2
| | | | | | | | | | | | | | | | | | | | | | The split between <efi.h> and <efi/efi.h> is confusing: The former contains universal definitions, while the latter contains barebox utilities on top. To make the distinction clear, rename <efi/efi.h> to <efi/efi-payload.h> as it's used for EFI payloads. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211122084732.2597109-14-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: remove useless AT_FDCWD referencesAhmad Fatoum2021-11-251-29/+27
| | | | | | | | | | | | | | | | | | | | All name lookups by barebox are AT_FDCWD and there are no dirfd support that could be used in its place, so just remove that parameter altogether from the FS functions. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211122084732.2597109-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: /dev/mem: handle copy at offset 0 correctlyAhmad Fatoum2021-12-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Despite that /dev/mem has a size of 0, the check preventing out-of-bounds access works for /dev/mem as well, because of unsigned wrap around. Corner case is when offset is zero. There will be no wrap around and count = min(count, 0 - 0) = 0 Leading to unexpected behavior with e.g. memcmp -s /dev/mem 0 on systems without MMU. Fix this. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20211129071454.2014315-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: jffs2: remove unnecessary slab cache structureHolger Assmann2021-11-303-124/+20
| | | | | | | | | | | | | | | | | | | | | | | | jffs2_create_slab_caches() and its subsequent kmem_cache calls are not needed in Barebox since they can directly be replaced by malloc calls. This patch performs that replacement as well as the related clean up. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Holger Assmann <h.assmann@pengutronix.de> Link: https://lore.barebox.org/20211129124545.14171-3-h.assmann@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: jffs2: introduce reference counting at probeHolger Assmann2021-11-301-12/+22
|/ | | | | | | | | | | | | | | | | | | | | | | The Barebox jffs2 driver initialises global slab caches and compressors within the probing stage [1]. In Barebox, jffs2_create_slab_caches() has several calls to kmem_cache_create() which does nothing more than allocating the context data structure for the kmem_cache. Probing a second jffs2 however will overwrite the original pointers returned by kmem_cache_create(), leading to a double free when more than one jffs2 file system gets unmounted and jffs2_destroy_slab_caches() is called. The same issue exists regarding jffs2_compressors_init(). We can fix this bug by introducing reference counting for both the slab caches and the compressors so that the global data structures are kept as long as at least one file system is present. [1] jffs2_compressors_init(), jffs2_create_slab_caches() in probe() Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Holger Assmann <h.assmann@pengutronix.de> Link: https://lore.barebox.org/20211129124545.14171-2-h.assmann@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: add dedicated header for printf/printkAhmad Fatoum2021-11-013-3/+3
| | | | | | | | | | | | Including <stdio.h> for printf is a bit problematic, because it pulls in other headers for <console.h>, which includes quite a few more headers as well. To make it easier to share code between barebox and host tools make <printk.h> the new minimal header for printf and move the extra logging stuff into <linux/printk.h>. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030141739.2207431-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ramfs: drop free of unused dev->privAhmad Fatoum2021-11-011-1/+0
| | | | | | | | | This probably was a benign free(NULL) so far, but it serves no point, so drop it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030141707.2207152-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>