summaryrefslogtreecommitdiffstats
path: root/fs
Commit message (Collapse)AuthorAgeFilesLines
* pstore/ram: Clarify resource reservation labelsKees Cook2019-03-182-4/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When ramoops reserved a memory region in the kernel, it had an unhelpful label of "persistent ram". When reading iomem, it would be repeated many times, did not hint that it was ramoops in particular, and didn't clarify very much about what each was used for: 0x4fdd4000 - 0x4fdf3fff (size 0x00020000) persistent ram 0x4fdf4000 - 0x4fe13fff (size 0x00020000) persistent ram ... 0x4ff74000 - 0x4ff93fff (size 0x00020000) persistent ram 0x4ff94000 - 0x4ffb3fff (size 0x00020000) persistent ram 0x4ffb4000 - 0x4ffd3fff (size 0x00020000) persistent ram Instead, this adds meaningful labels for how the various regions are being used: 0x4fdd4000 - 0x4fdf3fff (size 0x00020000) ramoops:dump(0/12) 0x4fdf4000 - 0x4fe13fff (size 0x00020000) ramoops:dump(1/12) ... 0x4ff74000 - 0x4ff93fff (size 0x00020000) ramoops:console 0x4ff94000 - 0x4ffb3fff (size 0x00020000) ramoops:ftrace 0x4ffb4000 - 0x4ffd3fff (size 0x00020000) ramoops:pmsg Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> [p.zabel@pengutronix.de: ported to Barebox from Linux commit 1227daa43bce] Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pstore: improve error report for failed setupKees Cook2019-03-181-17/+32
| | | | | | | | | | | When setting ramoops record sizes, sometimes it's not clear which parameters contributed to the allocation failure. This adds a per-zone name and expands the failure reports. Signed-off-by: Kees Cook <keescook@chromium.org> [p.zabel@pengutronix.de: ported to Barebox from Linux commit c443a5f3f1f1] Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pstore/ram: Do not use stack VLA for parity workspaceKees Cook2019-03-181-7/+21
| | | | | | | | | | | | Instead of using a stack VLA for the parity workspace, preallocate a memory region. The preallocation is done to keep from needing to perform allocations during crash dump writing, etc. This also fixes a missed release of librs on free. Signed-off-by: Kees Cook <keescook@chromium.org> [p.zabel@pengutronix.de: ported to Barebox from Linux commit f2531f1976d9] Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pstore: Make ramoops_init_przs generic for other prz arraysKees Cook2019-03-181-28/+58
| | | | | | | | | | | | | Currently ramoops_init_przs() is hard wired only for panic dump zone array. In preparation for the ftrace zone array (one zone per-cpu) and pmsg zone array, make the function more generic to be able to handle this case. Heavily based on similar work from Joel Fernandes. Signed-off-by: Kees Cook <keescook@chromium.org> [p.zabel@pengutronix.de: ported to Barebox from Linux commit de83209249d6] Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ramoops: use DT reserved-memory bindingsKees Cook2019-03-181-15/+7
| | | | | | | | | | | | | | Instead of a ramoops-specific node, use a child node of /reserved-memory. This requires that of_platform_device_create() be explicitly called for the node, though, since "/reserved-memory" does not have its own "compatible" property. Suggested-by: Rob Herring <robh@kernel.org> Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Rob Herring <robh@kernel.org> [p.zabel@pengutronix.de: ported to Barebox from Linux commit 529182e204db] Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* pstore/ram: add Device Tree bindingsGreg Hackmann2019-03-181-0/+83
| | | | | | | | | | | | | | | | | | | | | | | ramoops is one of the remaining places where ARM vendors still rely on board-specific shims. Device Tree lets us replace those shims with generic code. These bindings mirror the ramoops module parameters, with two small differences: (1) dump_oops becomes an optional "no-dump-oops" property, since ramoops sets dump_oops=1 by default. (2) mem_type=1 becomes the more self-explanatory "unbuffered" property. Signed-off-by: Greg Hackmann <ghackmann@google.com> [fixed platform_get_drvdata() crash, thanks to Brian Norris] [switched from u64 to u32 to simplify code, various whitespace fixes] [use dev_of_node() to gain code-elimination for CONFIG_OF=n] Signed-off-by: Kees Cook <keescook@chromium.org> [p.zabel@pengutronix.de: ported to Barebox from Linux commit 35da60941e44] Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ramoops: probe from device tree if OFTREE is enabledPhilipp Zabel2019-03-181-4/+32
| | | | | | | | | | Switch to a device driver probed from device tree if CONFIG_OFTREE is enabled. Also switch from postcore_initcall to device_initcall, to make sure that memory banks have been initialized before request_sdram_region is called. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* 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
|\ \