summaryrefslogtreecommitdiffstats
path: root/fs/devfs.c
Commit message (Collapse)AuthorAgeFilesLines
* 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: 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: let truncate take a loff_t argumentSascha Hauer2019-02-061-1/+1
| | | | | | | 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: devfs: Change .lseek callbacks to return 'int'Andrey Smirnov2019-02-041-3/+3
| | | | | | | | | | | 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-291-2/+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: Update FILE position in lseek()Andrey Smirnov2019-01-291-2/+0
| | | | | | | | | | 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>
* 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: 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: 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: devfs: Switch to dentry cache implementationSascha Hauer2018-07-111-65/+85
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: Add optional truncate callback for device filesTeresa Remmet2017-01-111-0/+5
| | | | | | | | Not all device files have trivial fix device sizes like static ubi volumes. Here the device file size equals the image size it contains. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Fix erasing of devices >4GiBSascha Hauer2016-02-091-1/+1
| | | | | | | | | When a device >4GiB is erased, not only the offset can be bigger than 4GiB, but also the size. This happens with the simplest command to erase a device: erase /dev/nand0. Make the size argument a 64bit type to make this work. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: Add symlink supportSascha Hauer2016-01-081-1/+26
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: devfs: Allow mounting only on /dev/Sascha Hauer2015-10-151-0/+7
| | | | | | | We have places in the code where we assume that devfs is mounted on /dev/, so enforce this path to avoid surprises. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: rename inode member of struct filep to privSascha Hauer2015-03-091-10/+10
| | | | | | | Because that's what it is. 'inode' will become confusing once we support real inodes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: store pointer to fsdev instead of dev in struct filepSascha Hauer2014-10-081-2/+2
| | | | | | | | The struct device_d * in struct filep is never of interest, instead it is always converted to a struct fs_device_d *, so simplify the code by storing the struct fs_device_d * directly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-3/+0
| | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: fix standard zero, full devicesSascha Hauer2012-07-041-1/+2
| | | | | | | | | | | | | | | | The standard devices are currently broken since they have the size ~0. As now files use loff_t as file size which is a signed type the read implementation gets confused and now returns -1. The current implementation also has the (somewhat theorical) problem that we do not have real streaming devices, so /dev/zero went out of zeroes after reading 4GB (or now LLONG_MAX). This patch introduces a new cdev flag DEVFS_IS_CHARACTER_DEV and a new file size flag FILE_SIZE_STREAM which makes it possible to create real stream devices instead. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/resource-size'Sascha Hauer2012-07-021-1/+1
|\ | | | | | | | | | | Conflicts: drivers/base/resource.c fs/fs.c
| * resource: store 'end' instead of 'size' in struct resourceSascha Hauer2012-07-011-1/+1
| | | | | | | | | | | | | | | | | | | | Storing the size instead of the resource end in struct resource was a mistake. 'size' ranges from 0 to UINT[32|64]_MAX + 1 which obviously leads to problems. 'end' on the other hand will never exceed UINT[32|64]_MAX. Also this way we can express a iomem region covering the whole address space. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2012-07-021-0/+6
|\ \
| * | fs/devfs.c: disallow write and erase if a partition is read-onlyJan Luebbe2012-06-301-0/+6
| |/ | | | | | | | | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | make cdev 64bit capableSascha Hauer2012-06-301-2/+2
| | | | | | | | | | | | Next step to 64bit support: Make cdev size a 64bit type. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | use loff_t for file offsetsSascha Hauer2012-06-301-3/+3
|/ | | | | | | This is a first step for 64bit file support: Make the file sizes/offsets 64bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: don't erase past the end of the partitionJohannes Stezenbach2012-06-071-0/+3
| | | | | | | | "erase /dev/myflash0.mypart 0xf0000+0xf0000" could erase past the end of the partition. Signed-off-by: Johannes Stezenbach <js@sig21.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: get fs device using container_ofSascha Hauer2012-02-251-1/+0
| | | | | | This reduces the usage of dev->type_data. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cdev: pass flags to open functionSascha Hauer2011-12-151-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: switch to resourceJean-Christophe PLAGNIOL-VILLARD2011-07-301-1/+3
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* devfs: factor out core devfs functionalitySascha Hauer2011-04-111-165/+2
| | | | | | | | | This makes it possible to compile without devfs. devfs_create/devfs_remove is used by drivers and thus must still be present even without devfs support. Also, this patch adds cdev_open/cdev_close/cdev_flush/cdev_ioctl calls to work with devices without using the file api. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: implement flush functionSascha Hauer2011-04-111-0/+11
| | | | | | | Once we have caching in file functions we need a way to sync the the underlying devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: remove unused struct filep* argument from open/closeSascha Hauer2011-04-111-2/+2
| | | | | | | the cdev layer is under the file layer, so it should not use struct filep*. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: remove unused field 'type' from struct fs_driver_dSascha Hauer2011-04-111-1/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: only check for ioctl function when neededSascha Hauer2010-07-051-8/+7
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* add partition mtd supportSascha Hauer2010-07-051-0/+31
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rename U-Boot-v2 project to bareboxSascha Hauer2009-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This has been done with the following script: find -path ./.git -prune -o -type f -print0 | xargs -0 -r sed -i \ -e 's/u2boot/barebox/g' \ -e 's/U2Boot/barebox/g' \ -e 's/U-boot V2/barebox/g' \ -e 's/u-boot v2/barebox/g' \ -e 's/U-Boot V2/barebox/g' \ -e 's/U-Boot-v2/barebox/g' \ -e 's/U_BOOT/BAREBOX/g' \ -e 's/UBOOT/BAREBOX/g' \ -e 's/uboot/barebox/g' \ -e 's/u-boot/barebox/g' \ -e 's/u_boot/barebox/g' \ -e 's/U-Boot/barebox/g' \ -e 's/U-boot/barebox/g' \ -e 's/U-BOOT/barebox/g' find -path ./.git -prune -o \( -name "*u-boot*" -o -name "*uboot*" -o -name "*u_boot*" \) -print0 | \ xargs -0 -r rename 's/u[-_]?boot/barebox/' It needs some manual fixup following in the next patch Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: fix return value for lseek in partitionsSascha Hauer2009-09-251-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: add open counterSascha Hauer2009-09-111-7/+29
| | | | | | | Add an open counter for device files so that we cannot accidently remove an opened device. This happened with bb devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* get rid of device idsSascha Hauer2009-07-211-13/+25
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* make sure ramfs/devfs are initialised when neededSascha Hauer2009-07-211-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Get rid of DEVICE_TYPE_FS usageSascha Hauer2009-07-211-2/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: add missing remove functionSascha Hauer2009-07-211-0/+5
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* introduce cdevSascha Hauer2009-07-211-47/+183
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lseek: return -1 for errors and check for that return valueSascha Hauer2008-08-011-2/+2
| | | | | | We cannot check for < 0 in lseek, otherwise we get problems with files > 0x7fffffff Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* - introduce ioctl callSascha Hauer2008-06-061-6/+30
| | | | - pass open/close/lseek through to drivers
* Use Linux kernel list for drivers and devices instead of handmadeSascha Hauer2007-10-111-8/+12
| | | | list.
* declare lots of functions staticSascha Hauer2007-09-281-6/+6
|
* implement flash protectionSascha Hauer2007-07-161-0/+8
|