9
0
Fork 0
Commit Graph

194 Commits

Author SHA1 Message Date
Sascha Hauer 38a1971e5b FAT: Fix error path
- forward the return value of chk_mounted to detect whether mount succeeded
- free resources on mount failure

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-03-18 15:03:31 +01:00
Sascha Hauer 3f637f7dc4 fs open: pass error from stat
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>
2012-03-18 15:03:31 +01:00
Sascha Hauer b5e5b06d8b Add automount support
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>
2012-03-18 15:03:26 +01:00
Sascha Hauer b55fbf7f5f fs: drop struct mtab_entry
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>
2012-03-17 18:16:03 +01:00
Sascha Hauer 4b4bfcc0bf fs: change get_fs_device_by_path prototype
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>
2012-03-17 18:16:03 +01:00
Sascha Hauer 3a92711511 fs: get fs device using container_of
This reduces the usage of dev->type_data.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-25 14:03:56 +01:00
Sascha Hauer 76c7f90a54 fs: get fs driver using container_of
This reduces the usage of dev->type_data.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-25 14:03:56 +01:00
Sascha Hauer abd21d1f67 Add suport for tftp as a filesystem
This adds tftp filesystem support. It currently duplicates
significant amounts of the tftp (command) support. This is ok
since we can eventually drop the original tftp command later.

tftp is not really suitable to be handled as a filesystem. It lacks
support for stat, reading directories and other things. Handling
it as a filesystem has one big advantage though: tftp is no special
case for boot scripts and/or commands anymore which makes them simpler.

This implementation has some improvements to the original tftp command.
It supports blocksize negotiation which speeds up transfers if the tftp
server supports it. Also we can determine the filesize to transfer if
the remote end supports it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-19 18:48:38 +01:00
Sascha Hauer 2546c5a514 Merge branch 'pu/device-cleanup' into next 2012-02-17 10:27:31 +01:00
Sascha Hauer 62d8b2f8c0 fs: allow to mount on subdirectories
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>
2012-02-17 10:27:15 +01:00
Sascha Hauer 9bf08d582a fs: put fs devices on its own bus
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>
2012-02-17 10:27:15 +01:00
Sascha Hauer 33b5ead7e6 fs: remove fs devices list
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>
2012-02-17 10:27:15 +01:00
Sascha Hauer b0c22c2f34 fs: remove only once used variable
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>
2012-02-17 10:27:15 +01:00
Sascha Hauer 336ad5ce68 fs: simplify get_mtab_entry_by_path
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-17 10:27:15 +01:00
Sascha Hauer fcec314b09 fs: remove unused function fsdev_get_mountpoint
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-17 10:27:15 +01:00
Sascha Hauer ec1d29e61c fs: Store mtab path in allocated string
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-17 10:27:15 +01:00
Sascha Hauer 2c2fb6a947 fs: make locally used function get_mtab_entry_by_path static
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-17 10:27:15 +01:00
Sascha Hauer 8a81eab846 fs: Store mtab entries in list
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>
2012-02-17 10:27:15 +01:00
Sascha Hauer c74a0d1d3b fat: revert fat caching mechanism
There seems to be a bug in this mechanism. It's easy to
get the cached fat out of sync with the device. Revert
it for now. This includes a huge write performance drop.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-15 08:21:39 +01:00
Jean-Christophe PLAGNIOL-VILLARD 440aec700a devfs-code: fix warning
/opt/work/barebox/fs/devfs-core.c: In function 'partition_ioctl':
/opt/work/barebox/fs/devfs-core.c:109:27: warning: unused variable 'reg'

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-01-16 11:41:52 +01:00
Alexander Aring 364c3aadfd ioctl: add support for ECCGETSTATS and MEMGETREGIONINFO
Support added for ioctl of ECCGETSTATS and MEMGETREGIONINFO.

Fix default handling in core.c to return -EINVAL, if request
was unknown.

Signed-off-by: Alexander Aring <a.aring@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-01-06 09:49:37 +01:00
Sascha Hauer d965649795 fat fs: Fix compile warning
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-01-05 10:23:04 +01:00
Sascha Hauer 4ecd0003ac cdev: pass flags to open function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-12-15 11:46:50 +01:00
Sascha Hauer 39e783d4e0 Merge branch 'pu/cramfs-fix' into next 2011-12-05 17:54:58 +01:00
Sascha Hauer 14273e7be2 ramfs: increase chunk size to 8192 bytes
dlmalloc seems to work more efficient with this chunk size.
Copying a bigger file (3MB) takes 271ms vs. 125ms on a i.MX27
board. Even bigger chunk sizes do not further improve performance.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-12-05 17:53:36 +01:00
Sascha Hauer 35869a211f fix cramfs support broken since zlib update
cramfs does not compile since we updated zlib to the kernel
version. Fix this by using the kernel version of uncompress.c

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-12-05 15:19:26 +01:00
Sascha Hauer e0f4fb2c98 Merge branch 'master' into next
Conflicts:
	drivers/ata/disk_drive.c

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-11-29 20:45:23 +01:00
Juergen Beisert 3ca9f1812f Create a unique cdev number for on demand devices
For disk like devices attached to MCI, ATA or USB it depends on the order they
will be recognized. So an unique number for all disk like devices is required.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-11-28 09:23:24 +01:00
Franck Jullien 186d926c23 fs/fat: Initialize local variable finfo
fat_stat in fs/fat.c declares finfo but doesn't initialize it.
When get_fileinfo is called, fno->lfname and fno->lfsize are
tested but haven't been zeroed...This can lead to a wrong
behavior.

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-11-17 16:59:29 +01:00
Franck Jullien 84b222987e mount: Fix the printing of device name
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>
2011-11-11 12:13:34 +01:00
Sascha Hauer 6756cd2cb2 fs: read: do not call read op when count is 0
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>
2011-11-09 11:23:16 +01:00
Sascha Hauer dac6e90115 fix bug introduced with fixing path_check_prereq()
This fixes a bug introduced with:

commit 74c36329c3
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>
2011-10-19 11:53:22 +02:00
Antony Pavlov a76e310abf fs: fix chdir()
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>
2011-10-18 12:12:43 +02:00
Antony Pavlov 74c36329c3 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>
2011-10-18 12:12:43 +02:00
Sascha Hauer db879ec1a9 Merge branch 'next' 2011-08-04 14:49:33 +02:00
Antony Pavlov cce6520927 fs/fat/ff.c: fix 'no previous prototype' warnings
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-08-03 17:55:42 +02:00
Jean-Christophe PLAGNIOL-VILLARD 12ed40bb17 fs: switch to resource
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2011-07-30 02:05:27 +08:00
Sascha Hauer 4128911f43 mem_read/write: use resources
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-07-19 00:12:49 +08:00
Sascha Hauer 17e91068b1 fs: add fat filesystem support
This code is based on:

http://elm-chan.org/fsw/ff/00index_e.html

FatFs Generic FAT File System Module

This patch offers a read/write implementation for barebox. The code
does not exaclty match barebox coding style, but works nicely and
should be ready to give it a try.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-04-12 09:54:56 +02:00
Sascha Hauer 77e8307b32 fs mount: fix error handling
If we register a device we have to unregister it later when
the driver did not accept the device. Also, do not forget to
free the backingstore string.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-04-11 12:36:26 +02:00
Sascha Hauer 092ec16fdf fs: use safe_strncpy instead of sprintf
This is safe against string overflows.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-04-11 12:36:08 +02:00
Sascha Hauer 30be97aff2 devfs: factor out core devfs functionality
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>
2011-04-11 12:36:07 +02:00
Sascha Hauer f1bb89fd9e fs: implement flush function
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>
2011-04-11 12:36:07 +02:00
Sascha Hauer 3efa8f7bed devfs: remove unused struct filep* argument from open/close
the cdev layer is under the file layer, so it should not use
struct filep*.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-04-11 12:36:07 +02:00
Sascha Hauer 5c44e3af24 fs: remove unused field 'type' from struct fs_driver_d
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-04-11 12:36:07 +02:00
Sascha Hauer 019e12210d fs: errno should be set correctly before the end of functions
Otherwise we end up with errno not being set correctly
if a filesystem driver uses the standard open/close/read/write
functions to access its backing store.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-04-04 15:02:40 +02:00
Sascha Hauer c28810e08f ramfs: increase chunk size to 4 kbyte
This greatly increases speed on ramfs.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-03-10 14:48:35 +01:00
Sascha Hauer a5734b08bd fs: fix multiple mount of the same fstype
We need to assign a new device id if we want to register
a fs with the same type of an already registered fstype.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-01-08 13:09:53 +01:00
Marek Belisko a894660cf1 fs: Fix bug found by sparse.
Patch fix following sparse warning:
fs/fs.c:757:28: warning: dubious: !x & y

Signed-off-by: Marek Belisko <marek.belisko@open-nandra.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-11-19 09:31:57 +01:00
Sascha Hauer 47ca335deb ramfs: sparse fixes
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-10-21 22:21:24 +02:00