9
0
Fork 0
Commit Graph

350 Commits

Author SHA1 Message Date
Vicente 64254636af omap4: add filesystem support over usb boot
Signed-off-by: Vicente <vicencb@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-11-16 15:32:31 +01:00
Sascha Hauer a2f3fde144 Merge branch 'for-next/fs' 2012-11-16 14:00:45 +01:00
Sascha Hauer 975d6a0130 fs tftp: Fix possible fifo overflow
In tftp_read we send a request for a new packet without checking if we
have enough space in the FIFO. This can lead to a FIFO overflow and a
corrupt file. Add a check for it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2012-10-24 09:57:51 +02:00
Sascha Hauer d2606de353 fs tftp: Only request a block once
tftp_send is called often. Each time, when in STATE_RDATA, a packet
is requested from the tftp server, even if we requested the same packet
already.
Stop this by tracking which packet we requested.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-24 09:57:44 +02:00
Alexander Aring 346b16ba0a devfs-core: add writesize in mtd partition ioctl
Add writesize in mtd partition MEMGETINFO ioctl.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-23 08:25:31 +02:00
Vicente 7c16deba8c fs: improve robustness
Signed-off-by: Vicente <vicencb@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-08 21:57:13 +02:00
Sascha Hauer d1e65d2a7b Merge branch 'for-next/remove-fsf-address'
Conflicts:
	drivers/net/miidev.c
	include/miidev.h
2012-10-03 21:12:48 +02:00
Sascha Hauer 3b02a1ac3a Merge branch 'for-next/fat-detection' 2012-10-03 21:10:37 +02:00
Sascha Hauer d4541ee94f Merge branch 'for-next/driver' 2012-10-03 21:09:34 +02:00
Jean-Christophe PLAGNIOL-VILLARD 72b0a6503f driver: register bus
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-23 21:15:13 +02:00
Franck Jullien 466e505fd9 fs/fat: Handle MBR on the first sector
Use filetype to detect FAT boot sector.
Add support for disk with MBR on the first sector.

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-20 08:58:00 +02:00
Sascha Hauer 77322aa896 Treewide: remove address of the Free Software Foundation
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>
2012-09-17 10:57:41 +02:00
Alexander Aring 05a68cca1f fs: fs.c fix cast
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>
2012-09-11 09:19:47 +02:00
Jean-Christophe PLAGNIOL-VILLARD 361d5bd773 fs/nfs: fix read when size < 1024
Currently we always request 1024.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-07 10:27:15 +02:00
Sascha Hauer e5a927883e Merge branch 'for-next/link' 2012-09-05 12:59:29 +02:00
Jean-Christophe PLAGNIOL-VILLARD 0e22047a99 nfs: add readlink support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-09-05 03:22:14 +08:00
Jean-Christophe PLAGNIOL-VILLARD ad6c28ac41 ramfs: add symlink and readlink support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-09-05 03:22:14 +08:00
Jean-Christophe PLAGNIOL-VILLARD 1483f45879 fs: introduce get_mounted_path to get the path where a file is mounted
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-09-05 03:22:14 +08:00
Jean-Christophe PLAGNIOL-VILLARD c3defd0504 fs: open: add symlink support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-09-05 03:22:13 +08:00
Jean-Christophe PLAGNIOL-VILLARD 2d7ac4aa33 fs: implement stat
stat() stats the file pointed to by path and fills in buf.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-09-05 03:22:13 +08:00
Jean-Christophe PLAGNIOL-VILLARD 65d4f485eb fs: add symlink support
Limit it's support to existing file only

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-09-05 03:22:13 +08:00
Jean-Christophe PLAGNIOL-VILLARD 99684498ec fs: rename stat to lstat as we implement lstat
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>
2012-09-05 03:22:13 +08:00
Jean-Christophe PLAGNIOL-VILLARD f4d850eb76 fs: fix rmdir with symlink
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-09-05 03:22:13 +08:00
Jean-Christophe PLAGNIOL-VILLARD 2f17f1a22f fs: add readlink support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-09-05 03:22:13 +08:00
Jean-Christophe PLAGNIOL-VILLARD 173fa8fe4c fs/fat: add filetype
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-09-04 09:08:39 +02:00
Jean-Christophe PLAGNIOL-VILLARD a1b1aec6af fs/mount: add autodetection type support
if NULL is pass as type mount will try to autodetect the filesystem type

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-09-04 09:08:39 +02:00
Sascha Hauer 11632d1eb3 fs nfs: depend on net
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-07-25 09:27:27 +02:00
Sascha Hauer 8d064097eb fs: fix standard zero, full devices
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>
2012-07-04 08:38:22 +02:00
Sascha Hauer 1510c57e93 Merge branch 'for-next/resource-size'
Conflicts:
	drivers/base/resource.c
	fs/fs.c
2012-07-02 11:05:57 +02:00
Sascha Hauer c9fc3209ac Merge branch 'for-next/fs' 2012-07-02 11:00:41 +02:00
Sascha Hauer f22d4e2778 Merge branch 'for-next/sparse' 2012-07-02 10:59:37 +02:00
Sascha Hauer 6e4b15537b Merge branch 'for-next/misc' 2012-07-02 10:59:30 +02:00
Sascha Hauer 5f03074ea9 resource: store 'end' instead of 'size' in struct resource
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>
2012-07-01 08:18:53 +02:00
Sascha Hauer 0c1a8aa0c2 fs FAT: fix warning: Using plain integer as NULL pointer
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 22:34:55 +02:00
Sascha Hauer f3a6511ae8 fs: Fix file create bug when parent is not a directory
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>
2012-06-30 19:53:06 +02:00
Sascha Hauer cfcfc66d54 partitions: Make 64bit capable
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 16:53:25 +02:00
Sascha Hauer be573120fe make cdev 64bit capable
Next step to 64bit support: Make cdev size a 64bit type.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 16:53:24 +02:00
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
Sascha Hauer e71c343668 mtd: fix arguments to bad block ioctls
In the Kernel the mtd ioctls expect a pointer to the offset, whereas
barebox interprets the pointer itself as an offset. Since we want
to add 64bit support for file sizes a pointer may not be sufficient,
so align with the kernel and convert it to a pointer to the offset.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 16:53:16 +02:00
Jan Luebbe a4fde70067 fs/devfs.c: disallow write and erase if a partition is read-only
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 12:47:04 +02:00
Sascha Hauer ecf38bff9b fs tftp: Fix short file transfers
With files smaller than the tftp block size the whole transfer is done
in tftp_do_open already. In this case we are in STATE_DONE, but there
is no error. Set priv->err to 0 and check for it to be able to transfer
small files.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-24 13:29:52 +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
Johannes Stezenbach 79f9683b8e devfs: don't erase past the end of the partition
"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>
2012-06-07 19:31:33 +02:00
Sascha Hauer 497d1c49f4 Merge branch 'next' 2012-06-06 14:11:57 +02:00
Sascha Hauer e48c51bda8 fs tftp: depend on NET, not on NET_TFTP
The tftp filesystem support is by no means dependent on the old tftp
support, it depends on NET though.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-05-31 20:23:52 +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
Eric Bénard dadcf5bd8f fs/tftp: depend on NET_TFTP
else the option remains selected when network gets disabled

Signed-off-by: Eric Bénard <eric@eukrea.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-05-17 19:53:54 +02:00
Jan Weitzel 011801d22c ramfs: rember last accessed chunk
Writing big files takes longer and longer because of the chunk list
By storing a pointer of the recent used chunk in the inode, access times are
improved.
Testet on with tftp 10M:
OMAP4 chunk size 4096: 12244ms 8192: 4239ms
	patched        2647ms        2785ms
i.MX35 chunk size 8192: 7225ms
	patched		2691ms

No impact on much smaller files seen

Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-05-16 13:20:09 +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 9ede56ad24 fs: Add NFS support
This patch adds readonly NFS support. Currently no links are supported.
This is based on the previous U-Boot/NetBSD based code and some Kernel
bits.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-05-14 08:36:03 +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
Jean-Christophe PLAGNIOL-VILLARD 7e3a16ef14 complete: add delpart complete support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-04-30 20:37:40 +08:00
Sascha Hauer 86b9eb2105 Merge branch 'work/dns' into next 2012-04-16 11:34:41 +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 980ac3e7b1 fs tftp: use resolv to resolv ip address
instead of assuming the backingstore is a ip address, use resolv()
to make it possible to pass in a hostname.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-04-15 16:26:07 +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 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
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 9ae9ef472e devfs: only check for ioctl function when needed
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-07-05 15:07:13 +02:00
Sascha Hauer acc46ca4f0 add partition mtd support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-07-05 13:00:02 +02:00
Peter Korsgaard d2f785374f cramfs: probe(): fix cdev lookup
Strip /dev/ part of backing store before passing cdev_by_name, as
cramfs_probe() will otherwise always fail.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-12-16 08:38:42 +01:00
Sascha Hauer a3ffa97f40 rename U-Boot-v2 project to barebox
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>
2009-12-15 10:18:30 +01: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 2e976df267 devfs: fix return value for lseek in partitions
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-09-25 13:34:01 +02:00
Sascha Hauer f46010a1ab devfs: add open counter
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>
2009-09-11 09:13:33 +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 b42f481fa4 reactivate cramfs
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-07-21 16:41:47 +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 ec318139f6 make sure ramfs/devfs are initialised when needed
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-07-21 16:41:46 +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 8fe9c1fa46 devfs: add missing remove function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-07-21 16:41:45 +02:00
Sascha Hauer 4adfb9cf54 ramfs: add missing remove function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-07-21 16:41:45 +02:00
Sascha Hauer a2b7cd183b introduce cdev
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-07-21 16:41:44 +02:00
fredo c3dbf6e1d6 remove warning
Signed-off-by: Frederic RODO <fred.rodo@gmail.com>
2008-12-18 14:20:08 +01: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
Menon, Nishanth b9655280e2 This is Kconfig cleanup patch (not all configurations will use CFI, SPI, RAMFS and DEVFS).
* Enable CFI and SPI drivers menuconfig option to be able to disable them in menuconfig.
* Introduce capability to disable ramfs and devfs.
2008-05-12 15:59: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
sascha 6b8e56295f use S_ISDIR macro in open() 2007-10-16 16:41:05 +02:00
Sascha Hauer eadf71abc7 Use Linux kernel list for drivers and devices instead of handmade
list.
2007-10-11 20:20:36 +02:00
Sascha Hauer 2443c7a6f1 export symbols 2007-10-07 14:27:24 +02:00
Sascha Hauer faf5efa138 change files and dirs to rwxrwxrwx 2007-10-04 13:15:09 +02:00
Sascha Hauer 0b19fcf491 export functions 2007-10-04 12:30:32 +02:00
Sascha Hauer e5e965b7f4 change files and directories to 0777 2007-10-03 19:57:46 +02:00
Sascha Hauer 0fb965de2c remove debug printf, replace with debug 2007-10-03 19:37:11 +02:00
Sascha Hauer b3dc734018 declare lots of functions static 2007-09-28 10:07:26 +02:00
Sascha Hauer 79ed00ba92 pass file size from read_file 2007-09-27 16:33:35 +02:00
Sascha Hauer 2d02f7c0f0 fix bug in ramfs when creating files whose parents do not exist 2007-09-27 11:58:22 +02:00
Sascha Hauer 6ed4c53c21 handle NULL Pointers in readdir/closedir properly 2007-09-25 14:36:55 +02:00
Sascha Hauer f132b2e073 - change function declarations for better standard conformity:
int open(const char *pathname, int flags);
-> int open(const char *pathname, int flags, ...);
   int mkdir(const char *pathname);
-> int mkdir(const char *pathname, mode_t mode);
2007-09-24 17:03:20 +02:00
Sascha Hauer 4d17340dc1 remove unused includes 2007-09-21 21:30:25 +02:00
Sascha Hauer 9a365ade16 remove uncompilable filesystems 2007-09-21 14:02:08 +02:00
Sascha Hauer 056a695c15 implement flash protection 2007-07-16 10:29:28 +02:00
Sascha Hauer 665291e693 implement memmap().
With this function we can get a pointer to directly memory mapped
devices like nor flash or RAM. Useful for bootm where we save one
memcopy when the image is mappable
2007-07-15 13:50:04 +02:00
Sascha Hauer 11534fdfa2 implement truncate for devfs 2007-07-05 21:46:42 +02:00