summaryrefslogtreecommitdiffstats
path: root/fs
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/net' into masterSascha Hauer2020-09-251-0/+34
|\
| * fs: Warn when filesystem operations are called from a pollerSascha Hauer2020-08-191-0/+34
| | | | | | | | | | | | | | | | | | Filesystem operations possibly call into arbitrary devices, so shouldn't be used from a poller. This patch sprinkles some WARN_ONCE() when this happens. One exception is when the file which is accessed is on ramfs which doesn't have any dependencies to devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: Fix use after freeSascha Hauer2020-09-141-3/+3
| | | | | | | | | | | | | | | | | | | | In case of the fs mounted to '/' the root dentry of the mounted filesystem is the place where it's mounted itself, so sb->s_root is the same as fsdev->vfsmount.mountpoint. In that case make sure we only access it before it has been killed in dentry_delete_subtree(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: Drop unnecessary dput()Sascha Hauer2020-09-141-1/+0
| | | | | | | | | | | | | | Calling dput() on the root dentry during unmount time is unnecessary, the dentry will be removed later in dentry_delete_subtree() anyway. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: don't free device in remove callbackAhmad Fatoum2020-09-141-2/+9
| | | | | | | | | | | | | | | | | | | | | | The probe doesn't allocate the device, so remove shouldn't free it either. This fixes a use-after-free on barebox shutdown: Iterating over the list of devices requires that remove callbacks don't remove the devices. This happened to work so far, because apparently not much new allocations are going on during barebox shutdown, but let's do it right. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
* | fs: Use iget_locked() rather than squashfs specific functionSascha Hauer2020-08-202-18/+1
| | | | | | | | | | | | | | | | | | | | | | | | Use iget_locked() to let the core allocate the inode. This properly initializes all fields in the new inode, especially it adds the new inode to the list of all inodes for the filesystem. This prevents a NULL pointer derefence when iput() removes the inode from that list. This fixes squashfs support which is broken since 43902e5763 ("fs: free inodes we no longer need") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: squashfs: Do not free root inodeSascha Hauer2020-08-201-1/+0
| | | | | | | | | | | | | | With inode reference counting in place the core will free the root inode, so do not free it in the squashfs code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: squashfs: set s_op in timeSascha Hauer2020-08-201-2/+1
|/ | | | | | | When calling squashfs_mount() s_op needs to be set already, otherwise calling alloc_inode() yields in a NULL pointer derefence. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ramfs'Sascha Hauer2020-07-276-164/+228
|\
| * fs: ramfs: Implement memmapSascha Hauer2020-07-051-0/+20
| | | | | | | | | | | | | | When an inode only has a single chunk then we can support memmap for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: ramfs: Use dynamically sized chunksSascha Hauer2020-07-051-148/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes the way ramfs stores its data. So far we used equally sized chunks, this patch changes it to use chunks in a size that fits our needs. The chunks are always allocated in the size they are needed for the current truncation. Only if we fail to allocate all desired memory at once we fall back to allocating smaller chunks. Together with using the generic list implementation this results in smaller code and has the advantage that many image files end up being contiguously in memory and thus we can provide a memmap for them. Files will end up contiguously in memory when they are first created, then truncated to the final size and then filled up with data. This is something which is normally easily achievable when desired. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: ramfs: Drop dead codeSascha Hauer2020-07-051-14/+0
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: ramfs: Return -ENOSPCSascha Hauer2020-07-051-2/+2
| | | | | | | | | | | | | | When ramfs fails to allocate more memory then returning -ENOSPC is more appropriate then -ENOMEM. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: free inodes we no longer needSascha Hauer2020-07-051-3/+5
| | | | | | | | | | | | | | | | So far we freed the no longer needed inodes only at unmount time. Let's trust our reference counting a bit more and free them once the reference counter hits zero. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: Make iput() accept NULL pointersSascha Hauer2020-07-051-0/+3
| | | | | | | | | | | | | | Let iput() accept NULL pointers so that users do not have to test for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: Add destroy_inode callbacks to filesystemsSascha Hauer2020-07-055-1/+43
| | | | | | | | | | | | | | | | | | | | | | Several filesystems rely on the default function which frees the struct inode * rather than the filesystem specific inode which the inode is embedded in. This works because the inode is the first element in the filesystem specific inode. Let's not depend on this behaviour and for clarity add the destroy_inode callbacks to all filesystems. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: fat: extend for in-PBL supportAhmad Fatoum2020-07-119-83/+175
|/ | | | | | | | | | | The AT91 BootROM loads a boot.bin file from the first FAT partition into SRAM, when booting from MMC. To avoid the need for two barebox configurations for each of the bootloader stages, add PBL support for reading from FAT. This way each stage need only have a different PBL entry point. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2020-05-1410-30/+0
|\
| * treewide: remove references to CREDITSUwe Kleine-König2020-04-2710-30/+0
| | | | | | | | | | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: Fix inode size setting in ftruncateSascha Hauer2020-05-051-0/+1
|/ | | | | | | When changing a file size the size of the corresponding inode has to be changed as well. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: Do not allow to abortSascha Hauer2020-03-301-3/+0
| | | | | | | | | | | | | | When ctrl-c is pressed then ctrlc() will return true until ctrlc_handled() is called. This means that once ctrl-c is pressed every NFS operation will fail until the upper layer calls ctrlc_handled(). When for example we are doing a 'ls -l' on an NFS directory then after a ctrl-c press not the 'ls -l' aborts, but instead the retrieving of the directory entries which is not what we want. Simply do not call ctrlc() in the fs layer. the NFS timeout is 2 seconds which we have to wait until we have a chance to abort. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: nfs: don't maintain nfs dentries in dcacheSascha Hauer2020-03-301-0/+1
| | | | | | | nfs dentries may change underneath barebox, so do not maintain them in the dcache. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: queue received packetsSascha Hauer2020-03-301-23/+29
| | | | | | | | | It may happen that we receive more than one RPC packet before we come along to check the result. Instead of handling just a single received packet and possibly overwriting the last one queue the received RPC packets. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: Fix polling for packetsSascha Hauer2020-03-301-2/+5
| | | | | | | | | It can happen that the first packet we receive is not the desired one. In this case we have to poll for further packets. set nfs_state back to STATE_START before polling for more packets, otherwise we check the same packet again and again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: Fix rpc_check_reply() return value for stale packetsSascha Hauer2020-03-301-7/+2
| | | | | | | | | | | When we receive a packet with the previous rpc_id then we have the comment "stale packet, wait a bit longer", but that's not what the code does. rpc_check_reply() returns 0 in this case and the caller then interprets the packet as valid. Always return -EAGAIN for invalid rpc_ids. This lets the caller ignore the packets as intented. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: remove unnecessary checkSascha Hauer2020-03-301-3/+0
| | | | | | In rpc_check_reply() pkt is never NULL, drop the unnecessary patch. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: Add missing freeSascha Hauer2020-03-301-0/+1
| | | | | | Add forgotten packet free in error path. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: Add function to free packetsSascha Hauer2020-03-301-11/+16
| | | | | | | | Add to function to free packets rather than freeing them directly. We will introduce received packet qeueuing with one of the next patches, this patch is meant to make it better readable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/block'Sascha Hauer2020-03-182-0/+46
|\
| * cdev: Add discard_range hookSascha Hauer2020-02-141-0/+21
| | | | | | | | | | | | | | To pass though discard_range() to the underlying drivers add a discard_range hook to struct cdev_operations. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: Introduce discard_range()Sascha Hauer2020-02-141-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | discard_range() is a way to tell the lower layers that we are no longer interested in a data range of a file, so that the lower layers can discard the underlying data if desired. This is mainly designed to bypass the deficiencies of our block layer. We cache the block data in chunks of multiple KiB (16 currently) if we fall into the block layer with write requests smaller than that we have to read/modify/write a chunk. With the help of discard_range() code writing files to a raw block device can now discard the range the file will be written to. The block layer then no longer has to read the chunks first that are inside the discard range. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: jffs2: add initial support for reading jffs2Steffen Trumtrar2020-02-1028-0/+8459
|/ | | | | | | | | | | | | | | | | | | | | Import the jffs2 filesystem code from Linux v5.5-rc1 and convert it to work with barebox. Writing is *not* supported. Testing was done with a n25q256a-compatible QuadSPI chip on a SoCFPGA-based Socrates board. Testing was done with a combination of: user@somelinuxhost: mkfs.jffs2 --eraseblock=4 -d fs/jffs2/ -o jffs2.img root@target:~ flash_erase -j /dev/mtd5 0 0 root@target:~ dd if=jffs2.img of=/dev/mtd5 barebox@EBV SOCrates:/ mount /dev/mtd0.data (...) mounted /dev/mtd0.data on /mnt/mtd0.data Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pstore: ramoops: use correct format specifier for size_t variablesLucas Stach2019-12-021-4/+4
| | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pstore: don't try to grab non-existent logbufLucas Stach2019-12-021-0/+3
| | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pstore: remove unused goto labelAhmad Fatoum2019-11-271-1/+0
| | | | | | | Previous refactoring removed jumps to fail_clear. Remove it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pstore: fix build by re-resolving botched merge conflictAhmad Fatoum2019-11-271-29/+0
| | | | | | | | | | | | | | | 297ac7288 ("pstore: Only capture log messages") removed the pstore console. v3 of the eventually merged 75a74b5c ("console: fix out-of-bounds read in dputc(/dev/*, ...)") reinstated part of this code, which broke the pstore build because the now removed bufsize member had a user reintroduced in the patch. Fix this by reverting the offending patch's changes to the pstore code. It wasn't applicable to begin with. Fixes: 75a74b5c ("console: fix out-of-bounds read in dputc(/dev/*, ...)") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2019-11-072-2/+2
|\
| * fs: ubootvarfs: use correct format specifier for pointer diffLucas Stach2019-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The difference between two pointers is represented as a ptrdiff_t, use the correct format specifier when printing to get rid of the following warning in a 64bit build: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long int' [-Wformat=] Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: devfs-core: do a case-insensitive compare of partuuidsAhmad Fatoum2019-10-231-1/+1
| | | | | | | | | | | | | | | | | | | | partuuids are represented as hexadecimal strings, where case doesn't matter. barebox formats them as lower case internally, forcing the partuuid device tree property to be lower case too. Use strcasecmp to be case-insensitive. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/ext4'Sascha Hauer2019-11-072-70/+23
|\ \
| * | fs: ext4: return NULL instead of 0Sascha Hauer2019-10-291-2/+2
| | | | | | | | | | | | | | | | | | | | | ext4fs_get_extent_block() returns a pointer, so return NULL instead of integer 0. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: ext4: Fix handling of sparse filesSascha Hauer2019-10-291-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adoption of U-Boot commit: | commit f81db56f2fd6dc16efeaec2961121244765a1f11 | Author: Stefan Brüns <stefan.bruens@rwth-aachen.de> | Date: Sat Nov 5 22:17:14 2016 +0100 | | ext4: Fix handling of sparse files | | A sparse file may have regions not mapped by any extents, at the start | or at the end of the file, or anywhere between, thus not finding a | matching extent region is never an error. | | Found by python filesystem tests. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: ext4: remove unnecessarily clever file readSascha Hauer2019-10-291-53/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | ext4fs_read_file() tries to tries to bundle contiguous block reads into longer reads from the device. In barebox we cache in the block layer already, so this is unnecessary. Simplify the code by removing the bundled reads. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: ext4: Fix out of bounds memsetSascha Hauer2019-10-291-1/+1
| |/ | | | | | | | | | | | | | | | | When a block we read is a sparse block, we memset the corresponding output buffer to zero. If that block is the last block we read, we may not memset the whole block, but only up to the length of the output buffer, which may be shorter than a full block. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / efi: use efi_guidcmp helper where appropriateAhmad Fatoum2019-10-181-1/+1
|/ | | | | | | We have a helper for it. Let's use it. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: devfs-core: have device_find_partition search symlinksAhmad Fatoum2019-10-151-0/+21
| | | | | | | | | | | | | | | | | The barebox,environment binding documentation notes following for the device-path property's second string: > <partname> can be the label for MTD partitions, the number for DOS > partitions (beginning with 0) or the name for GPT partitions. This doesn't work currently because the named partitions are realized as symlinks and those aren't searched by device_find_partition. Fix this by having symlinks feature an appropriate partname if the cdev they link at has one and then have device_find_partition search those as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* chdir(): add LOOKUP_DIRECTORY flag to filename_lookup()Robert Karszniewicz2019-10-141-1/+1
| | | | | | | | This makes sure that automount points get handled even if the path doesn't end with a '/'. Signed-off-by: Robert Karszniewicz <r.karszniewicz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* trivial: fix typo lenght -> lengthUwe Kleine-König2019-10-141-1/+1
| | | | | | | | | | | | Generated by perl -p -i -e 's/lenghte?/length/' arch/arm/boards/chumby_falconwing/falconwing.c arch/arm/mach-samsung/mem-s3c64xx.c fs/ext4/ext_common.h lib/gui/lodepng.c include/jtag.h There is another instance in dts/Bindings/usb/s3c2410-usb.txt, this is fixed in Linux v5.3-rc1 so supposed to be fixed soon in barebox, too. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/tftp'Sascha Hauer2019-09-122-1/+10
|\
| * fs: tftp: don't maintain tftp dentries in dcacheAhmad Fatoum2019-08-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Currently a negative dentry is cached whenever a non-existing file was looked up over TFTP. Short of a barebox reset, there is no way to invalidate that dentry, so barebox retries the look up. Fix this by always reporting TFTP dentries as invalid in the d_revalidate callback. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>