summaryrefslogtreecommitdiffstats
path: root/fs
Commit message (Collapse)AuthorAgeFilesLines
* fs: devfs: implement d_revalidate hookSascha Hauer2018-10-291-0/+27
| | | | | | | | | | | | | | | | | | | The files in devfs can change withouut the fs layer noticing, so we have to revalidate dentries before using them. A failure could be triggered with: ls /dev/nand0.root.ubi; ubiattach /dev/nand0.root; ls /dev/nand0.root.ubi The first 'ls' would create a dentry for nand0.root.ubi with no inode associated since it does not yet exist. 'ubiattach' then creates that file, but the second 'ls' does not show it since the dentry is not revalidated and thus no inode is added to that dentry. This patch fixes this and also the opposite case when a file is removed (for example with ubidetach). Reported-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: implement d_revalidateSascha Hauer2018-10-291-1/+36
| | | | | | | d_revalidate is useful when filesystems change under the hood of the fs layer. This can happen with network filesystems or with devfs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ubifs'Sascha Hauer2018-10-0927-16421/+1769
|\
| * fs: ubifs: optionally allow to mount UBIFS images with encrypted filesSascha Hauer2018-10-083-1/+11
| | | | | | | | | | | | | | | | | | Currently we do not support the UBIFS file encryption feature. Nevertheless we can allow read clear files from UBIFS to be able to boot an unencrypted kernel. This differs from the Kernel behaviour, so add a globalvar to make that configurable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ubifs: Update to v4.18-rc6Sascha Hauer2018-10-0821-550/+2147
| | | | | | | | | | | | | | | | | | | | | | | | This syncs the UBIFS code with Linux-4.19-rc6. There are many functions in the Linux UBIFS codebase that we do not need for a readonly implementation. These are missing here, but all removed functions are annotated as such so it should be relatively easy to copy a newer codebase over the current one and to see which functions shall be removed from the newer version. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: ubifs: remove not needed codeSascha Hauer2018-10-0823-16206/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch aggressively removes stuff that we do not need in a readonly implementation: - write buffering support - lpt/ltab code - garbage collector - everything under #ifndef __BAREBOX__ This decreases the binary size by about 5k on ARM, but the main reason for doing this is the idea that things that are not there don't need to be synced with upstream ubifs code. The __BAREBOX__ ifdeffery makes the code very hard to read and is a maintenance burden by itself, so it is removed here aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: implement clear_nlink and set_nlinkSascha Hauer2018-10-082-35/+16
| | | | | | | | | | | | | | Implement clear_nlink and set_nlink and remove the private versions from UBIFS. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: implement iget_locked and iget_failedSascha Hauer2018-10-082-29/+24
| | | | | | | | | | | | Implement in fs core rather than using a private version in UBIFS. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: implement file_inodeSascha Hauer2018-10-081-0/+1
| | | | | | | | | | | | To ease code porting from Linux Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * Add more mutex no-opsSascha Hauer2018-10-081-3/+0
| | | | | | | | | | | | | | Add mutex_lock_nested, mutex_unlock_nested and mutex_is_locked to include/linux/mutex.h and remove them from UBIFS. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * Add kmemdupSascha Hauer2018-10-082-19/+0
| | | | | | | | | | | | | | | | We have kmemdup as a UBIFS specific variant, put it into the correct header files. Instead of reimplementing it just use memdup we already have. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * Add linux/slab.hSascha Hauer2018-10-082-24/+2
| | | | | | | | | | | | | | | | | | Move stuff we already have in include/linux/barebox-wrapper.h that really belongs to include/linux/slab.h to there. Also add kmem_cache_* functions. UBIFS uses them in there own implementation, so we have to remove it there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/fs'Sascha Hauer2018-10-091-6/+7
|\ \ | |/ |/|
| * fs: improve ramfs_truncate speedMarcin Niestroj2018-10-081-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During sequential writes into single file, fs layer is consequently calling ramfs_truncate() function. When file size grows ramfs_truncate() takes more and more time to complete, due to interations through all already written data chunks. As an example loading ~450M image using usb fastboot protocol took over 500s to complete. Use ramfs_find_chunk() function to search for last chunk of data in ramfs_truncate() implementation, which saves a lot of loop iterations. As a result loading ~450M image using usb fastboot protocol takes around 25s now. Tested-by: Maciej Zagrabski <m.zagrabski@grinn-global.com> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs: ramfs: make chunk counting in truncate() better readableSascha Hauer2018-09-271-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In ramfs_truncate() "newchunks" denotes the number of chunks we want to have after the call. We decrease that number while iterating over the existing chunks and decrease it further with every newly allocated chunk until "newchunks" is zero. This is a bit hard to read. Instead we drop the decreasing while iterating over existing chunks and increase "oldchunks" while allocating until it reaches "newchunks". This is mainly done to make the next patch easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: ubifs: Do not free memory not allocated by ubifsSascha Hauer2018-09-281-1/+0
| | | | | | | | | | | | | | | | | | Since the switch to dentry cache implementation we no longer allocate the super block, so we must not free it in the error path. Fixes: ("4d2b23bcf9 fs: ubifs: Switch to dentry cache implementation") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: stat: Do not forget to set errnoSascha Hauer2018-09-261-0/+3
| | | | | | | | | | | | | | | | stat() needs to set errno correctly when returning with an error. Fixes: b3fbfad7ae ("fs: dentry cache implementation") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: open: Do not forget to set errnoSascha Hauer2018-09-261-1/+1
|/ | | | | | | | | When the initial lookup fails in open we have to go to the error path which sets errno correctly rather than returning directly. Fixes: b3fbfad7ae ("fs: dentry cache implementation") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: ramfs: Free data when file is unlinkedSascha Hauer2018-09-261-1/+23
| | | | | | | | | Since the switch to dentry cache implementation the memory is no longer freed when a file in ramfs is deleted. Fix this. Fixes: b283b72639 ("fs: ramfs: Switch to dentry cache implementation") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: devfs: fix r/w permissionsSascha Hauer2018-09-171-1/+6
| | | | | | | | | The real r/w flags were lost in the switch to dentry cache implementation. Restore them. Fixes: 9137c41915 ("fs: devfs: Switch to dentry cache implementation") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: devfs: Create device files as character devicesSascha Hauer2018-09-171-2/+2
| | | | | | | | | | | | Without this files in /dev/ appear as regular files. copy_file() stumbles upon this as it tries a truncate() on that files which then fails. Create the files as character devices so that copy_file() works as expected. Fixes: 9137c41915 ("fs: devfs: Switch to dentry cache implementation") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Tested-by: Giorgio Dal Molin <giorgio.nicole@arcor.de>
* fs: tftp: Use pr_debug for errorsSascha Hauer2018-09-101-1/+1
| | | | | | | This has been debug output before for good reasons. The users will usually print the error messages when they want to. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: improve file size handlingSascha Hauer2018-08-301-2/+8
| | | | | | | | Previously we used FILE_SIZE_STREAM unconditionally. Instead, fill the inode size with a valid filesize if we have one and only if not fall back to FILE_SIZE_STREAM. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: hide files which are actually not present on the serverSascha Hauer2018-08-301-8/+25
| | | | | | | | | | In tftp_lookup we claimed that every desired file is there. This leads to problems when a user only tests if a file is present and makes decisions upon this information. Rather than claiming that all files are present do a tftp_do_open() on the files and see if it is really there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: fix return valueSascha Hauer2018-08-301-1/+1
| | | | | | | | When tftp_get_inode() fails it is a sign for a out of memory situtation rather than an indicator for no space left on the filesystem, so return -ENOMEM. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: fix memory holeSascha Hauer2018-08-301-10/+7
| | | | | | | dpath() returns a pointer to an allocated string, so we have to free it. Put the pointer into our file private data and free it on close time. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: tftp: overhaul debuggingSascha Hauer2018-08-301-10/+25
| | | | | | | | | - use pr_* instead of debug() - use pr_vdebug for the less interesting messages - use pr_err for error messages - print state as clear text and not as number Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/memcmds'Sascha Hauer2018-08-131-1/+1
|\
| * fs: ramfs: get chunks zero initializedSascha Hauer2018-08-101-1/+1
| | | | | | | | | | | | | | Initialize new chunks to zero, otherwise a ->truncate call may result in uninitialized data in files. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: squashfs: Switch to dentry cache implementationSascha Hauer2018-07-139-177/+365
| | | | | | | | | | | | While at it implement symlink support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: cramfs: Switch to dentry cache implementationSascha Hauer2018-07-132-251/+273
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: tftp: Switch to dentry cache implementationSascha Hauer2018-07-132-43/+55
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: nfs: Switch to dentry cache implementationSascha Hauer2018-07-132-309/+234
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: ubifs: Switch to dentry cache implementationSascha Hauer2018-07-136-484/+313
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: ext4: Switch to dentry cache implementationSascha Hauer2018-07-113-123/+160
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: devfs: Switch to dentry cache implementationSascha Hauer2018-07-112-66/+85
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: ramfs: Switch to dentry cache implementationSascha Hauer2018-07-112-303/+99
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: dentry cache implementationSascha Hauer2018-07-1111-1005/+2635
|/ | | | | | | | | | | | | | | | | | | | | | | This adds the Linux dentry cache implementation to barebox. Until now every filesystem driver resolves the full path to a file for itself. This leads to code duplication and is error prone since resolving paths is a complicated task. Also it can narrow down the lookup performance since barebox only knows ASCII paths and has no way of caching lookups. With this patch we get the Linux dcache implementation. The path resolving code from fs/namei.c is nearly taken as-is, minus the RCU and locking code. Dcaching is made simple as of now: We simply cache everything and never release any dentries. Although we do reference counting for inodes and dentries it is effectively not used yet. We never free anything until a fs is unmounted in which case we free everything no matter if references are taken or not. This patch also contains a wrapper in fs/legacy.c to support filesystems with the old API. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: devfs-core: Make use of devpath_to_name()Andrey Smirnov2018-06-251-4/+2
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: fix memory access via /dev/mem for MIPS64Peter Mamonov2018-06-141-2/+2
| | | | | | | | lseek checks for non-negative in-memory offsets (addresses), failing otherwise. However negative address 0xffffffffXXXXXXXX is a valid MIPS64 virtual address. Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Fix finding correct directory for mkdir/rmdirSascha Hauer2018-04-061-2/+2
| | | | | | | 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 <s.hauer@pengutronix.de>
* fs: Cleanup whitespace damageSascha Hauer2018-04-061-13/+13
| | | | | | fs.c has some whitespaces where there should be tabs. Fix it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Move mem_write/mem_read to devfs-coreSascha Hauer2018-04-062-66/+68
| | | | | | | 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 <s.hauer@pengutronix.de>
* fs: Add super_operationsSascha Hauer2018-04-062-39/+0
| | | | | | | | 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 <s.hauer@pengutronix.de>
* ubifs: remove dead codeSascha Hauer2018-04-061-475/+0
| | | | | | | Remove code that was added to UBIFS for U-Boot but that is not needed for barebox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubifs: Remove Linux struct definitions we already haveSascha Hauer2018-04-061-317/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubifs: remove dead codeSascha Hauer2018-04-061-187/+0
| | | | | | | 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 <s.hauer@pengutronix.de>
* rename file_operations -> cdev_operationsSascha Hauer2018-04-061-1/+1
| | | | | | | | 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 <s.hauer@pengutronix.de>
* fs: check pointer returned by get_fsdevice_by_path before dereferencingGaël PORTAY2018-03-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In __canonicalize_path() we dereference the pointer returned by get_fsdevice_by_path() without checking if the pointer is NULL or not. When the pointer is NULL it leads to an Ooops. Ooops, address error on load or ifetch! $ 0 : 00000000 00000001 a0000026 a0811c10 $ 4 : a0402e60 a0402e48 a0811c00 a0402e58 $ 8 : 00000001 00000000 0000005a 00000023 $12 : 00000000 00000002 00601021 00000000 $16 : a0402e60 a0402e50 a0402e39 a0810000 $20 : a0402e38 a0811420 a0811424 00000000 $24 : 00000000 a080de10 $28 : 87f87d40 a03ffa68 a0810000 a080ce30 Hi : 00000002 Lo : 00000000 epc : a080ce34 ra : a080ce30 Status: 00000006 Cause : 40008010 Config: 80040483 ### ERROR ### Please RESET the board ### Fixes: d79a81736 fs: Don't bother filesystems without link support with additional stat() calls Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: allow building without full console supportAleksander Morgado2018-03-011-1/+1
| | | | | | | | | | | | | Make CONFIG_RATP a selectable config option, so that the user can enable RATP support without explicitly needing to enable the full console support over RATP (e.g. only for RATP FS or built-in command support). The full console can still be explicitly enabled with CONFIG_CONSOLE_RATP. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>