summaryrefslogtreecommitdiffstats
path: root/fs
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/warnings'Sascha Hauer2019-04-093-110/+2
|\
| * fs: squashfs: Remove unused functionSascha Hauer2019-03-181-108/+0
| | | | | | | | | | | | squashfs_lookup_next() isn't used in the tree. Remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * treewide: Make locally used functions staticSascha Hauer2019-03-182-2/+2
| | | | | | | | | | | | | | Many functions are only used locally but still are globally visible. Make these function static. Avoids warnings generated with -Wmissing-prototypes Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/pstore'Sascha Hauer2019-04-096-131/+447
|\ \
| * | pstore: ramoops: allow zapping invalid buffers in read-only modePhilipp Zabel2019-03-182-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The FS_PSTORE_RAMOOPS_RO configuration option keeps barebox from zapping (clearing and fixing header ecc) all ramoops buffers on initialization. It also stops barebox from zapping invalid buffers. This causes issues when the console writing code tries to use the uninitialized, invalid console buffer. Therefore, allow barebox to zap invalid buffers, the kernel will do so anyway if it finds broken buffers during its initialization. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | pstore: pass ramoops configuration to kernel via device treePhilipp Zabel2019-03-181-18/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of setting ramoops module parameters on the kernel command line, add a /reserved-memory/ramoops node to the device tree via of_fixup. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Documentation-added-by: Juergen Borleis <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | pstore: Replace arguments for write() APIKees Cook2019-03-181-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to the pstore_info read() callback, there were too many arguments. This switches to the new struct pstore_record pointer instead. This adds "reason" and "part" to the record structure as well. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | pstore: Replace arguments for read() APIKees Cook2019-03-182-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | The argument list for the pstore_read() interface is unwieldy. This changes passes the new struct pstore_record instead. The erst backend was already doing something similar internally. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | pstore: Switch pstore_mkfile to pass recordKees Cook2019-03-183-29/+26
| | | | | | | | | | | | | | | | | | | | | Instead of the long list of arguments, just pass the new record struct. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | pstore: add console supportPhilipp Zabel2019-03-182-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | Add support for writing console messages to pstore. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Documentation-added-by: Juergen Borleis <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | pstore: Extract common arguments into structureKees Cook2019-03-181-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The read/mkfile pair pass the same arguments and should be cleared between calls. Move to a structure and wipe it after every loop. Signed-off-by: Kees Cook <keescook@chromium.org> [p.zabel@pengutronix.de: ported to Barebox from Linux commit 9abdcccc3d5f] Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | 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-04-092-15/+7
|\ \
| * | treewide: surround Kconfig file paths with double quotesMasahiro Yamada2019-03-211-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Based on Linux commit 8636a1f9677db4f883f29a072f401303acfc2edd This will be needed when you sync Kconfig with Linux 5.0 or later. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: ramfs: Drop unnecessary check in ramfs_mknod()Andrey Smirnov2019-03-131-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | There's already an early exit statement triggered by "inode" being NULL. Drop an extra check that will always be true. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: ramfs: Drop unused 'chunks' conterAndrey Smirnov2019-03-131-4/+0
| | | | | | | | | | | | | | | | | | | | | This variable doesn't appear to be used anywhere in the code. Drop it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: ramfs: Drop unused 'handle' filed from struct ramfs_inodeAndrey Smirnov2019-03-131-2/+0
| |/ | | | | | | | | | | | | There are no users of this field in the code. Drop it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / bpkfs: Fix lseek error check in bpkfs_probe()Andrey Smirnov2019-03-111-2/+2
|/ | | | | | | | | Don't use 'int' to store lseek()'s return value to avoid problems with large seek offsets. While at it, make sure to populate return error code from 'errno'. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> 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>