summaryrefslogtreecommitdiffstats
path: root/include/fs.h
Commit message (Collapse)AuthorAgeFilesLines
* fs: remove now unused function can_lseek_backward()Sascha Hauer2018-01-251-20/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: implement is_tftp_fs()Sascha Hauer2018-01-251-0/+10
| | | | | | | | | | Some commands need files in which they can lseek backwards which is particularly not possible on TFTP. Instead of hiding this behind can_lseek_backward() create a function for it which tests if the file is on TFTP directly rather than using different lseek operations. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Introduce devpath_to_name()Andrey Smirnov2017-12-061-0/+9
| | | | | | | | Add a simple function to simplify the task of accepting both full path in "/dev" and just device name as a parameter. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Fix can_lseek_backward()Andrey Smirnov2017-11-171-1/+1
| | | | | | | | | | | | | | | | To quote corresponding man page: "... Upon successful completion, lseek() returns the resulting offset location as measured in bytes from the beginning of the file." Which for lseek(fd, 0, SEEK_SET) would be 0, so returning 'ret' as final step of the function would mean it'd never return anything but 0 as well. Change the code to explicitly return '1' to fix the problem. Fixes: 7c3f8d366 ("uimage: fix: add can_lseek_backward and use in uimage_open") Cc: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* uimage: fix: add can_lseek_backward and use in uimage_openMichael Grzeschik2017-11-101-0/+20
| | | | | | | | | | Since commit ce0cc7fe we support forward seek on tftpfs. This feature breaks the condition to check rather we open an uimage over tftp. Since backward seeking is the problem here, we add the function can_lseek_backward and check for it instead of the simple lseek. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2017-06-141-0/+1
|\
| * fs: add cdev_create_loop and cdev_remove_loop for loop mount optionPhilipp Zabel2017-06-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow to create a loopback cdev from a file. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Fixed up with: fs: Makefile: Add parseopt to all builds parseopt.h was included to fs.c with commit 9248b, but parseopt.o has a dependency to CONFIG_FS_NFS. Moved parseopt.o to the default build to eliminate build failures. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: Implement links to directoriesSascha Hauer2017-05-111-1/+2
|/ | | | | | | | | | | | So far links can only point to files. Implement links to directories. With this all kinds of links are supported: - relative links - absolute links - links including ".." - link loops (are detected, return -EMLINK) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/include-cleanup'Sascha Hauer2016-05-091-50/+6
|\
| * fs: move libc function prototypes to their correct locationsSascha Hauer2016-04-151-45/+6
| | | | | | | | | | | | | | | | | | | | | | This moves the function prototypes in include/fs.h which also exist in the libc to the locations they would have in libc. With this it becomes easier to share code between barebox and userspace since the usual libc include files will exist. Also users of the libc functions no longer have to include the barebox internal fs.h header. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * move unlink_recursive declaration to libfile.hSascha Hauer2016-04-151-2/+0
| | | | | | | | | | | | | | unlink_recursive is a file utility function, so move the prototype to libfile.h Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * move make_directory declaration to libfile.hSascha Hauer2016-04-151-3/+0
| | | | | | | | | | | | | | As a utility function for file handling make_directory() is well suited for libfile. Move it there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fix erasing/protecting flashes with unspecified sizeSascha Hauer2016-04-191-0/+1
|/ | | | | | | | | | | | | | | | | fixes: 81737c1 mtd: Fix erasing of devices >4GiB Several places erased a complete flash partition passing ~0 as count to erase(). With the above commit count to erase was changed from an unsigned type to a signed type, so the (count > f->size - offset) check in erase() no longer triggers and the ~0 count is no longer adjusted to the whole device size. Among other things this results in saveenv failures on NOR flashes. This patch fixes this by introducing an explicit macro for erasing the whole device which is tested for in erase(). All other negative values are rejected. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Giorgio <giorgio.nicole@arcor.de>
* fs: umount based on device path and mount pathMarkus Pargmann2016-04-081-0/+1
| | | | | | | umount on Linux can be used on a mount pathes and device pathes. This patch adds this functionality to barebox. Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
* fs: Add for_each_fs_device_safe()Markus Pargmann2016-04-081-0/+1
| | | | | | | We need to be able to umount specific filesystems while iterating all of them. This helper gives us a safe macro to do so. Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
* mtd: Fix erasing of devices >4GiBSascha Hauer2016-02-091-2/+2
| | | | | | | | | 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>
* fs: use linux/fs.h for file system related definitionsYegor Yefremov2016-02-011-4/+1
| | | | | Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Add device parameter for Linux root= optionSascha Hauer2015-06-181-0/+4
| | | | | | | | | | When registering a filesystem device add a device parameter suitable for the Linux root= option to boot from exactly this filesystem. Currently the fs layer sets this parameter to the root=PARTUUID= mechanism if a partuuid is available. Other filesystems like NFS and UBIFS which do not have a PARTUUID can overwrite this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/fs'Sascha Hauer2015-03-091-1/+1
|\
| * fs: rename inode member of struct filep to privSascha Hauer2015-03-091-1/+1
| | | | | | | | | | | | | | 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: make "offset" parameter of erase() and protect() 64 bit safeMarc Kleine-Budde2015-03-031-2/+2
|/ | | | | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: implement fstatSascha Hauer2014-10-081-0/+1
| | | | | | | fstat is useful to get information about an already opened file. Add it to barebox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Store the path in struct filepSascha Hauer2014-10-081-0/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: store pointer to fsdev instead of dev in struct filepSascha Hauer2014-10-081-2/+1
| | | | | | | | 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>
* move file helper functions to separate fileSascha Hauer2014-08-071-14/+0
| | | | | | | | | | We have our file helper functions in several places. Move them all to lib/libfile.c. With this we no longer have file helpers in fs/fs.c which contains the core fs functions and no functions in lib/libbb.c which are not from busybox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mount: support filesystem options passed via -oUwe Kleine-König2014-02-101-2/+4
| | | | | | | | | | | Similar to mount(8) the barebox command mount now supports passing a string to the file system driver via -o. This is used in the next commit to let the user specify port numbers for nfs mounts. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Add function to get cdev by mountpathSascha Hauer2013-11-051-0/+2
| | | | | | This is useful to know for the bootloader spec implementation. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: add cdev mount helpersSascha Hauer2013-09-301-0/+3
| | | | | | | Introduce helpers to iterate over cdevs and mount them to a known path. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mount: implement -v option to print available filesystemsSascha Hauer2013-09-291-0/+1
| | | | | | | It's useful to know which filesystems a barebox binary supports. Add a -v option to the mount command to find it out. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: remove unused field 'name' from struct fs_driver_dSascha Hauer2013-09-291-1/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: cleanup backingstore handlingSascha Hauer2013-09-291-0/+2
| | | | | | | | | | | All filesystem drivers which need a backingstore device do the same ignoring of '/dev/' in the backingstore followed by a cdev_open. Add a helper function for it and let the core handle the cdev. As a side effect this makes sure that fsdev->cdev is also set when a device is mounted without the leading '/dev/' which was previously ignored by the mount code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* read_file: Make it work on tftp servers which do not pass sizeSascha Hauer2013-06-201-0/+2
| | | | | | | | Some tftp servers (for example netkit-tftp) do not pass the filesize. Add a workaround for read_file which reads the file into a temporary file which then is copied to a buffer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: add pread and pwrite functionsAlexander Aring2013-02-201-0/+2
| | | | | | | | | | | | | | | Add pread and pwrite functions. Split read and write functions to save some space. The functions pread and pwrite saves and sets the file position to a given offset and restore them afterwards. This also makes the nandtest command use these function which is necessary to not break compilation for the nandtest command. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: fix return type of readAlexander Aring2013-02-181-1/+1
| | | | | Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add write_file functionSascha Hauer2013-01-191-0/+5
| | | | | | | write_file() will write a buffer to a file. The file is created if necessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rm: implement -rSascha Hauer2012-11-291-0/+2
| | | | | | To recursively remove files and directories. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/link'Sascha Hauer2012-09-051-0/+12
|\
| * fs: introduce get_mounted_path to get the path where a file is mountedJean-Christophe PLAGNIOL-VILLARD2012-09-051-0/+2
| | | | | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
| * fs: implement statJean-Christophe PLAGNIOL-VILLARD2012-09-051-4/+2
| | | | | | | | | | | | stat() stats the file pointed to by path and fills in buf. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
| * fs: add symlink supportJean-Christophe PLAGNIOL-VILLARD2012-09-051-0/+3
| | | | | | | | | | | | Limit it's support to existing file only Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
| * fs: rename stat to lstat as we implement lstatJean-Christophe PLAGNIOL-VILLARD2012-09-051-1/+5
| | | | | | | | | | | | | | For compatibility put a inline on lstat for stat until we have the symlink support. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
| * fs: add readlink supportJean-Christophe PLAGNIOL-VILLARD2012-09-051-0/+5
| | | | | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* | fs/mount: add autodetection type supportJean-Christophe PLAGNIOL-VILLARD2012-09-041-0/+5
|/ | | | | | if NULL is pass as type mount will try to autodetect the filesystem type Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* fs: fix standard zero, full devicesSascha Hauer2012-07-041-0/+1
| | | | | | | | | | | | | | | | 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>
* use loff_t for file offsetsSascha Hauer2012-06-301-6/+6
| | | | | | | This is a first step for 64bit file support: Make the file sizes/offsets 64bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add automount supportSascha Hauer2012-03-181-0/+4
| | | | | | | | | | | | | | This patch adds an automount command which makes it possible to execute a script when a certain directory is first accessed. It's the commands responsibility to make this directory available (bringing devices up and mounting it). This results in automount support which makes sure that from the shell every file can be accessed without having to care for device bringup. Bringing up devices may be expensive (USB, dhcp). The automount support makes it easy for the environment to bringup devices when they are actually needed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: drop struct mtab_entrySascha Hauer2012-03-171-10/+5
| | | | | | | | | | every struct fs_device_d contains a struct mtab_entry, so they have a 1:1 relationship. Instead of having to use container_of to get from a struct mtab_entry to a struct fs_device_d we can better embed the members of struct mtab_entry into struct fs_device_d directly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: get fs device using container_ofSascha Hauer2012-02-251-0/+1
| | | | | | This reduces the usage of dev->type_data. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: get fs driver using container_ofSascha Hauer2012-02-251-0/+2
| | | | | | This reduces the usage of dev->type_data. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: put fs devices on its own busSascha Hauer2012-02-171-0/+1
| | | | | | | | | | | By putting the fs devices/drivers on a bus on its own we can hook into the bus remove function to cleanup the fs device. This way we can unmount a device by simply unregistering the device which is useful for for example USB mass storage devices. These can now unregister the assoiated filesystems by unregistering their child devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>