9
0
Fork 0
Commit Graph

80 Commits

Author SHA1 Message Date
Sascha Hauer 3e503822c7 use loff_t for file offsets
This is a first step for 64bit file support: Make the file sizes/offsets
64bit.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 16:53:24 +02:00
Johannes Stezenbach 6815e0d054 fs: limit flash erase and protect to the partiton boundary
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>
2012-06-07 19:31:33 +02:00
Sascha Hauer 831be2ecee lseek: return -1 instead of -errno
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>
2012-05-18 11:19:04 +02:00
Sascha Hauer 9963bb4d15 fs readdir: check for NULL pointer again
This got lost in:

commit 6188685091
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>
2012-05-14 21:50:59 +02:00
Sascha Hauer 6188685091 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>
2012-05-14 08:35:54 +02:00
Sascha Hauer 09334a95b4 automount: remove existing automountpoint
Before creating a new mountpoint on an already existing mountpoint
we have to remove it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-04-15 16:50:58 +02:00
Sascha Hauer 51c31ae1c5 automount: Pass automount pass as environment variable
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>
2012-04-15 15:41:40 +02: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 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
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
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 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 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 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 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
Baruch Siach edf1301d82 fs: add basic sanity check before accessing the files array
This patch adds some basic file descriptor sanity checks to the file access
routines. Check whether the given file descriptor is in the files array range,
and whether the file entry is valid.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-07-28 08:21:46 +02:00
Sascha Hauer 2baeaf38f3 fs: replace broken dev_protect with protect_file function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-10-02 15:23:22 +02:00
Sascha Hauer 915aa03c77 fs: write: fix writing on devices
We can't truncate device files. Make sure that if we want to
write beyond the device that the bytes that still fit into the
device get written.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-07-30 16:10:20 +02:00
Sascha Hauer 02ba8a0542 get rid of device ids
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-07-21 16:41:47 +02:00
Sascha Hauer 6459b135d9 Get rid of DEVICE_TYPE_FS usage
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-07-21 16:41:46 +02:00
Sascha Hauer a2b7cd183b introduce cdev
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-07-21 16:41:44 +02:00
Sascha Hauer 8a45275a01 fs: fix compiler warning
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2008-08-26 11:40:51 +02:00
Sascha Hauer e133ccdda8 implement memmap for mem driver
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2008-08-14 10:25:56 +02:00
Sascha Hauer f295acb556 lseek: return -1 for errors and check for that return value
We cannot check for < 0 in lseek, otherwise we get problems with files > 0x7fffffff

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2008-08-01 08:59:27 +02:00
Sascha Hauer b403f8d6f3 [fs]: set errno correctly for ioctl() 2008-06-25 10:23:15 +02:00
Sascha Hauer ee6d36a540 - introduce ioctl call
- pass open/close/lseek through to drivers
2008-06-06 09:30:48 +02:00
Sascha Hauer e77ed305e6 add missing null pointer check in unlink() 2008-03-01 21:05:23 +01:00
Carsten Schlote c1bba7e226 [general] Fixed crash in fs.h, when called with fsdrv.create == NULL
When a nor0 devices has no partitions assigned, then a call to
open() to create a file will jump with a NULL fct ptr.

Much more cheching code is missing and pointers to function are
jumped without any NULL ptr check. This must be fixed as well later.

Signed-off-by: Carsten Schlote <c.schlote@konzeptpark.de>
2008-02-19 09:28:17 +01:00
Marc Kleine-Budde cefc190b1b [sparse] declare functions static, use NULL as NULL pointer
this fixes:
fs/fs.c:210:6: warning: symbol 'files' was not declared. Should it be static?
fs/fs.c:212:6: warning: symbol 'get_file' was not declared. Should it be static?
fs/fs.c:227:6: warning: symbol 'put_file' was not declared. Should it be static?
fs/fs.c:248:5: warning: symbol 'dir_is_empty' was not declared. Should it be static?
fs/fs.c:613:41: warning: Using plain integer as NULL pointer

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2007-11-29 10:22:47 +01:00
sascha 3b6d6a45e7 - Implement tree structure for devices
- Use device tree structure to implement partitions
- Let devinfo print a nice tree
- Introduce 'fixed' partitions which are not removable
- Fix mount: It was not possible to mount on a relative path.
2007-10-19 08:45:57 +02:00