summaryrefslogtreecommitdiffstats
path: root/fs/fs.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Add write_file functionSascha Hauer2013-01-191-0/+19
| | | | | | | write_file() will write a buffer to a file. The file is created if necessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers/base: fix corrupt device treeSascha Hauer2012-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_add_child is a very unsafe function. If called multiple times it allows setting the same device to different parents thus corrupting the siblings list. This happens regularly since: | commit c2e568d19c5c34a05a1002d25280bf113b72b752 | Author: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | Date: Sat Nov 3 16:11:05 2012 +0100 | | bus: add bus device | | automatically add it as parent of any bus device if none already specified | | we have now a nice output per bus If for example a FATfs is mounted this nice output per bus often ends with: > `---- fat0 > `---- 0 > `---- 0x86f0000087020031-0x86f000410df27124: /dev/<NULL> > `---- sram00 > `---- 0x00000000-0xffffffffffffffff: /dev/<NULL> > `---- 0x00000000-0xffffffffffffffff: /dev/<NULL> > unable to handle NULL pointer dereference at address 0x0000000c > pc : [<87f08a20>] lr : [<87f08a04>] > sp : 86eff8c0 ip : 87f3fbde fp : ffffffff > r10: ffffffff r9 : 00000000 r8 : 00000003 > r7 : 86f075b8 r6 : 00000002 r5 : ffffffec r4 : 86f07544 > r3 : 00000000 r2 : 43f900b4 r1 : 00000020 r0 : 00000005 > Flags: Nzcv IRQs off FIQs off Mode SVC_32 > [<87f08a20>] (do_devinfo_subtree+0x90/0x130) from [<87f08a90>] (do_devinfo_subtree+0x100/0x130) > > [<87f3e070>] (unwind_backtrace+0x0/0x90) from [<87f28514>] (panic+0x28/0x3c) > [<87f28514>] (panic+0x28/0x3c) from [<87f3e4b8>] (do_exception+0x10/0x14) > [<87f3e4b8>] (do_exception+0x10/0x14) from [<87f3e544>] (do_data_abort+0x2c/0x38) > [<87f3e544>] (do_data_abort+0x2c/0x38) from [<87f3e268>] (data_abort+0x48/0x60) This patch fixes this by adding a device to its parents children list in register_device so that dev_add_child is no longer needed. This function is removed from the tree. Now callers of register_device have to clearly set the parent *before* registering a device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Jan Lübbe <jlu@pengutronix.de>
* fs: move dev_add_child before device_registerSascha Hauer2012-12-121-5/+5
| | | | | | Biology tells us that the parent is known before the child is born. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: improve robustnessVicente2012-10-081-9/+18
| | | | | Signed-off-by: Vicente <vicencb@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/remove-fsf-address'Sascha Hauer2012-10-031-3/+0
|\ | | | | | | | | | | Conflicts: drivers/net/miidev.c include/miidev.h
| * 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>
* | Merge branch 'for-next/driver'Sascha Hauer2012-10-031-0/+6
|\ \ | |/ |/|
| * driver: register busJean-Christophe PLAGNIOL-VILLARD2012-09-231-0/+6
| | | | | | | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: fs.c fix castAlexander Aring2012-09-111-2/+6
|/ | | | | | | Fix casting on min argument, to avoid warnings on 64bit build. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/link'Sascha Hauer2012-09-051-7/+222
|\
| * fs: introduce get_mounted_path to get the path where a file is mountedJean-Christophe PLAGNIOL-VILLARD2012-09-051-0/+9
| | | | | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
| * fs: open: add symlink supportJean-Christophe PLAGNIOL-VILLARD2012-09-051-4/+11
| | | | | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
| * fs: implement statJean-Christophe PLAGNIOL-VILLARD2012-09-051-0/+105
| | | | | | | | | | | | 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/+51
| | | | | | | | | | | | 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-5/+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: fix rmdir with symlinkJean-Christophe PLAGNIOL-VILLARD2012-09-051-0/+6
| | | | | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
| * fs: add readlink supportJean-Christophe PLAGNIOL-VILLARD2012-09-051-0/+37
| | | | | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* | fs/mount: add autodetection type supportJean-Christophe PLAGNIOL-VILLARD2012-09-041-1/+29
|/ | | | | | 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-4/+4
| | | | | | | | | | | | | | | | 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-2/+2
|\ | | | | | | | | | | Conflicts: drivers/base/resource.c fs/fs.c
| * resource: store 'end' instead of 'size' in struct resourceSascha Hauer2012-07-011-2/+2
| | | | | | | | | | | | | | | | | | | | 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/fs'Sascha Hauer2012-07-021-0/+30
|\ \
| * | fs: Fix file create bug when parent is not a directorySascha Hauer2012-06-301-0/+30
| |/ | | | | | | | | | | | | When creating a file or a directory we have to check if the parent is actually a directory. Otherwise trying it results in a crash. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | make cdev 64bit capableSascha Hauer2012-06-301-1/+1
| | | | | | | | | | | | 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-5/+5
|/ | | | | | | This is a first step for 64bit file support: Make the file sizes/offsets 64bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: limit flash erase and protect to the partiton boundaryJohannes Stezenbach2012-06-071-10/+8
| | | | | | | | | | | | | Passing a too large size or offset to erase could affect flash outside the partition boundary. Addresses for SPI flash wrap around, thus giving a count + offset going past the end of the flash would wrap around and erase flash at offset 0. Add the same check for protect. Signed-off-by: Johannes Stezenbach <js@sig21.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lseek: return -1 instead of -errnoSascha Hauer2012-05-181-2/+2
| | | | | | | | | | The patch making errno a positive value has another bug: lseek was switched to return -errno instead of -1. This does not work since we can lseek we can address the whole 4G address space, have of which has a negative offset when interpreted as a signed integer. Let lseek return -1 on failure again instead. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs readdir: check for NULL pointer againSascha Hauer2012-05-141-0/+3
| | | | | | | | | | | | | | | | | This got lost in: commit 6188685091c58c9772b990cf0ca6ac522f97a9d0 Author: Sascha Hauer <s.hauer@pengutronix.de> Date: Sun May 13 12:43:58 2012 +0200 Make errno a positive value Normally errno contains a positive error value. A certain unnamed developer mixed this up while implementing U-Boot-v2. Also, normally errno is never set to zero by any library function. This patch fixes this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Make errno a positive valueSascha Hauer2012-05-141-132/+218
| | | | | | | | | Normally errno contains a positive error value. A certain unnamed developer mixed this up while implementing U-Boot-v2. Also, normally errno is never set to zero by any library function. This patch fixes this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* automount: remove existing automountpointSascha Hauer2012-04-151-0/+2
| | | | | | | Before creating a new mountpoint on an already existing mountpoint we have to remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* automount: Pass automount pass as environment variableSascha Hauer2012-04-151-4/+9
| | | | | | | | This makes it possible to pass a command sequence to the automount command instead of only a script (a command sequence would get confused by the additional argument) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs open: pass error from statSascha Hauer2012-03-181-6/+6
| | | | | | | | We used to simply answer with -ENOENT in open() when the initial call to stat() failed. Instead, forward the error from stat(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add automount supportSascha Hauer2012-03-181-0/+119
| | | | | | | | | | | | | | 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-45/+43
| | | | | | | | | | 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: change get_fs_device_by_path prototypeSascha Hauer2012-03-171-34/+31
| | | | | | | | | | get_fs_device_by_path returns a struct device_d instead of what the name suggests a struct fs_device_d. Also it returns the rootpath of the corresponding fs_device. This patch changes the name of this function to get_fs_device_and_root_path to better reflect what the function does and changes the return type to struct fs_device_d. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: get fs device using container_ofSascha Hauer2012-02-251-3/+2
| | | | | | 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-17/+16
| | | | | | This reduces the usage of dev->type_data. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: allow to mount on subdirectoriesSascha Hauer2012-02-171-6/+7
| | | | | | | | | Since get_mtab_entry_by_path() is a bit more flexible now we no longer have to force the user to mount on the root directory only. Instead, we can allow to mount on subdirectories aswell. Nested mounts are still not possible though. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: put fs devices on its own busSascha Hauer2012-02-171-46/+76
| | | | | | | | | | | 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>
* fs: remove fs devices listSascha Hauer2012-02-171-22/+1
| | | | | | | | | | We store the fs devices in a list only because we want to check if the fs driver needs a backingstore or not. The driver will bail out anyway if it needs a backingstore and doesn't find one. So we can remove this check and thus remove the list of fs devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: remove only once used variableSascha Hauer2012-02-171-4/+2
| | | | | | | dev is used only once, so make the code a tiny bit simpler by not using an extra variable but dereference it when needed directly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: simplify get_mtab_entry_by_pathSascha Hauer2012-02-171-17/+6
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: remove unused function fsdev_get_mountpointSascha Hauer2012-02-171-5/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Store mtab path in allocated stringSascha Hauer2012-02-171-2/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: make locally used function get_mtab_entry_by_path staticSascha Hauer2012-02-171-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Store mtab entries in listSascha Hauer2012-02-171-45/+33
| | | | | | | To make the code a bit easier to read. Also, do not allow to umount / when something else is mounted. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mount: Fix the printing of device nameFranck Jullien2011-11-111-0/+7
| | | | | | | | | | | | | | | Mount without argument always print a "none" as device name mounted because entry->parent_device is always NULL. The problem is the mount function in fs/fs.c. parent_device is initialized to NULL and never updated. With this patch, parent_device is set with the mounted device name. Moreover, the mount function has been modified to print the device name plus device id using the dev_name function. Signed-off-by: Franck Jullien <franck.jullien@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: read: do not call read op when count is 0Sascha Hauer2011-11-091-0/+4
| | | | | | | Some ops do not handle read with count = 0 correctly. They do not have to if this is catched in the upper layer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fix bug introduced with fixing path_check_prereq()Sascha Hauer2011-10-191-2/+6
| | | | | | | | | | | | | | | | | | | | | | This fixes a bug introduced with: commit 74c36329c3531acf59d76a09cd0c4cf11ce6b6a0 Author: Antony Pavlov <antonynpavlov@gmail.com> Date: Tue Oct 18 13:48:44 2011 +0400 fs: fix path_check_prereq() This patch makes impossible the situations than path_check_prereq() can make 'return 0' without changing errno. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> path_check_prereq is supposed to return 0 when a file does not exist and S_UB_DOES_NOT_EXIST is given. stat() changes errno, so we have to set errno back to 0 before returning. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: fix chdir()Antony Pavlov2011-10-181-1/+2
| | | | | | | | chdir() allocates memory using mormalise_path(). But if path_check_prereq() returns error than memory isn't freed. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>