summaryrefslogtreecommitdiffstats
path: root/fs
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/misc'Sascha Hauer2019-03-074-91/+1
|\
| * fs: ubifs: Remove unused crc16 functionsSascha Hauer2019-03-044-91/+1
| | | | | | | | | | | | | | | | The crc16 functions in ubifs are unused, so remove them. (They were only used in the LPT functions which are completely removed for the barebox readonly implementation) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/fs'Sascha Hauer2019-03-073-69/+32
|\ \
| * | fs: Simplify fd to FILE lookup codeAndrey Smirnov2019-02-271-53/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid a bit of repeating code by merging checking fd for correctness and fd to FILE lookup into a single routine and converting the rest of the code to use it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: Drop unused code in fstat()Andrey Smirnov2019-02-271-3/+0
| | | | | | | | | | | | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: Make use of cdev_flush()Andrey Smirnov2019-02-271-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | Drop extra checks and explicit indirect call in devfs_flush() in favour of using cdev_flush(), since it already does all of the above. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: Make use of cdev_erase()Andrey Smirnov2019-02-271-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | Drop extra checks and explicit indirect call in devfs_erase() in favour of using cdev_erase(), since it already does all of the above. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: ramfs: Drop needless OOM checkAndrey Smirnov2019-02-271-2/+0
| | | | | | | | | | | | | | | | | | | | | Drop needless OOM check since xzalloc() will never return NULL. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: Drop needless OOM checkAndrey Smirnov2019-02-271-3/+0
| |/ | | | | | | | | | | | | Drop needless OOM check since xzalloc() will never return NULL. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / efi: cleanupsOleksij Rempel2019-02-182-2/+2
|/ | | | | | | make local functions static and remove unused code Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/nfs'Sascha Hauer2019-02-131-58/+86
|\
| * fs/nfs: stop using a global variable for nfs packet payloadUwe Kleine-König2019-01-221-58/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | The lifetime of the data provided by a global variable is hard to track. So move the data pointer into the nfs_priv structure and let rpc_req return the data to its callers which in turn are responsible to free it. The callers are changed to use a local variable accordingly. This makes it plausible that the previous commit catched all usages of the global data. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs/nfs: copy data from rpc replies to local storageUwe Kleine-König2019-01-221-5/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The nfs code uses data provided to the packet handler after net_poll() returned. But the life time of this data already ended when net_poll() returns. Most of the time it is possible to get away here but on i.MX28 the data is overwritten since commit 82ec28929cc9 ("net: fec_imx: Do not use DMA coherent memory for Rx buffers"). So the data from the packet is copied to a malloced buffer that needs free()ing when the data is not used any more. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs/nfs: don't try to set nfs error code from mount rpc callUwe Kleine-König2019-01-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A packet from a mount rpc call doesn't have an NFS error field, so don't try to access this. In the case of the MOUNT_UMOUNT procedure the reply package is short such that accessing the u32 after the rpc_reply structure is already after the end of the packet. Apart from the access to out-of-packet data there is no harm because the wrongly read value is unused. But make this more explicit by only using nfserr if the call was an NFS request. Fixes: 9ede56ad2476 ("fs: Add NFS support") 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/misc'Sascha Hauer2019-02-131-1/+1
|\ \
| * | treewide: Remove trailing whitespaces and tabsAlexander Shiyan2019-01-211-1/+1
| |/ | | | | | | | | | | | | Just a cleanup over barebox tree Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/lseek'Sascha Hauer2019-02-1319-160/+99
|\ \
| * | fs: Share code between mem_write()/mem_read()Andrey Smirnov2019-02-061-22/+24
| | | | | | | | | | | | | | | | | | | | | | | | Rename memcpy_sz() to mem_copy() and move all of the identical code from mem_write()/mem_read() there. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: devfs: forbid truncation when cdev has no truncate operationSascha Hauer2019-02-061-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a cdev doesn't have a truncate callback then forbid truncation and fail with -EPERM. Before this we had always failed with -ENOSPC in this situation. We checked for f->fsdev->dev.num_resources being nonzero, but this check was absolutely meaningless. It goes back to ancient times when the resources of a device were automatically added to devfs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: do not call truncate for FILE_SIZE_STREAM sized filesSascha Hauer2019-02-061-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | open_and_lseek() increases the file size when the file is opened in write mode and scrolled past the files end. This fails badly on /dev/mem because loff_t which we use for the file size is signed variable, which is used as an unsigned variable in /dev/mem. To catch this case do not try to truncate FILE_SIZE_STREAM sized files. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: set errno in ftruncate()Sascha Hauer2019-02-061-1/+3
| | | | | | | | | | | | | | | | | | ftruncate needs to set errno correctly on error. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: let truncate take a loff_t argumentSascha Hauer2019-02-0610-10/+10
| | | | | | | | | | | | | | | | | | | | | loff_t is the correct type for file sizes. Use it to allow to truncate to sizes bigger than 32bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: Avoid division in memcpy_sz()Andrey Smirnov2019-02-061-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | Instead of dividing count by rwsize, use ALIGN_DOWN() and change the loop to decrement by "rwsize" bytes. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: Simplify new position calculation in lseek()Andrey Smirnov2019-02-041-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All these checks are really testing is that resulting position is within [0; f->size] interval. Convert all of the custom checks into a signle one done after the switch statement to simplify the code. Note this change also disables the validity check for f->size == FILE_SIZE_STREAM and whence == SEEK_END, but lseek(stream_fd, offset, SEEK_END) wasn't a meaningful operation to begin with, so this shouldn't be a problem. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: Do not use IS_ERR_VALUE() to validate offset in lseek()Andrey Smirnov2019-02-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On 32-bit systems, checking for IS_ERR_VALUE(pos) is not correct. Expanding that code we get (loff_t cast is added for clarity): (loff_t)pos >= (unsigned long)-MAX_ERRNO given that loff_t is a 64-bit signed value, any perfectly valid seek offset that is greater than 0xffffc000 will result in false positive. Moreso, as a part of fix introduced in e10efc5080 ("fs: fix memory access via /dev/mem for MIPS64") it doesn't really solve the problem completely on on 64-bit platforms, becuase it still leaves out a number of perfectly valid offsets (e.g. "md 0xffffffffffffff00" doesn't work) Undo the original change and convert the check to simply test if offset is negative. Changes neccessary to alllow access to end of 64-bit address space will be implemented in the follow-up patch. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: devfs: Change .lseek callbacks to return 'int'Andrey Smirnov2019-02-0410-27/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Returning requested offset from .lseek() callback doesn't really give us any new information while bringing unnecessary complications. Change all .lseek() types (both in struct struct cdev_operations and in struct fs_driver_d) to return 'int' and adjust the rest of the codebase accordingly. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | devfs: Drop dev_lseek_default()Andrey Smirnov2019-01-292-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only the following cdevs do not declare an .lseek() operation: - Console devices in common/console.c - Firmware framework in common/firmware.c - JTAG driver in drivers/misc/jtag.c - UBI in drivers/mtd/ubi/barebox.c Of those four, first two are marked DEVFS_IS_CHARACTER_DEV and implement only .write() operation and the last two don't implement anything but .ioctl(). While there's probably no meaningful way to use lseek() against any of those devices, there doesn't seem to be any harm in allowing it either. Change devfs_lseek() to ignore absense of .lseek() callback and drop dev_lseek_default() and all references to it in the codebase. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: Drop trivial .lseek() implementaitons in FS driversAndrey Smirnov2019-01-299-58/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are no FS drivers that do not implement .lseek callback in the codebase, so there doesn't seem to exist a use-case where lseek() would return -ENOSYS due to fsdrv->lseek being NULL. At the same time a large number of FS drivers implement only the most basic "always succeeds" custom .lseek() hook. Change the code of lseek() to treat absense of .lseek() to mean that no special actions needs to be taken by FS driver and seek is always successful and drop all of the trivial .lseek() implementations. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: Update FILE position in lseek()Andrey Smirnov2019-01-2915-34/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead on relying on driver callbacks to update 'pos' in FILE, do it as a part of lseek() code. This allows us to drop a bit of repeating code as well as making lseek() implementation consistent with write() and read(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | devfs: Fix incorrect error check for cdev->ops->lseek()Andrey Smirnov2019-01-291-5/+9
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cdev->ops->lseek() will either return a negative error code on failure or requested position on success. In order to properly check for errors we need to test if the return value is negative, not just that it's not -1. Returning ret - cdev->offset, doesn't appear to be correct either, even if ret is -1, since on failure this will lead us to return (-1 - cdev->offset). Simplify that part by just returning 'pos', which is what we'd end up returning on success in original code as well. Third, make sure to return -ENOSYS, when no .lseek() callback is provided. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / treewide: Introduce MAP_FAILED and replace ad-hoc constants with itAndrey Smirnov2019-01-161-1/+1
|/ | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs/fat: fix FAT32 detectionAlexander Kurz2019-01-041-5/+7
| | | | | | | | | | | | Limits for the number of clusters were used to determine the FAT fs type. This fails e.g. for FAT32 fs with low cluster number that can be found in certain Android images. Sync the FAT fs type detection to the method used in linux by checking the sectors/FAT entries at offset 0x16 (must be zero for FAT32) and offset 0x24 (must be non-zero for FAT32). Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net'Sascha Hauer2018-12-072-6/+19
|\
| * fs: tftp: Make filesize a 64bit typeSascha Hauer2018-11-291-4/+4
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * net: dns: return error codesSascha Hauer2018-11-292-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The resolv() function used to return the IP address. When net_udp_new() fails we return an error code though which the callers of resolv() take as an IP address. This is wrong of course and we could return 0 in this case. Instead we return an error code and pass the resolved IP as a pointer which allows us to return proper error codes. This patch also adds error messages and error returns to the various callers of resolv() which used to just continue with a zero IP and let the user figure out what went wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/missing-prototypes'Sascha Hauer2018-12-073-11/+3
|\ \
| * | fs: devfs: Make locally used function staticSascha Hauer2018-11-121-1/+1
| | | | | | | | | | | | | | | | | | devfs_iterate() is only used locally, so make it static. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: ubifs: Avoid missing prototype warningSascha Hauer2018-11-122-10/+2
| |/ | | | | | | | | | | Remove unused ubifs_iput() and make locally used functions static. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: fix possible null pointer dereference of base.Oleksij Rempel2018-11-211-1/+2
| | | | | | | | | | | | | | we use base before checking if it is NULL Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: closedir: remove uninitialized variable retOleksij Rempel2018-11-211-3/+1
|/ | | | | Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net-switch-mv88e6xxx'Sascha Hauer2018-11-091-1/+1
|\
| * drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-1/+1
| | | | | | | | | | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/missing-prototypes'Sascha Hauer2018-11-091-18/+18
|\ \
| * | fs: Make locally used functions staticSascha Hauer2018-10-191-18/+18
| |/ | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | 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>