9
0
Fork 0
Commit Graph

58 Commits

Author SHA1 Message Date
Uwe Kleine-König f97f4b6571 mount: support filesystem options passed via -o
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>
2014-02-10 09:02:21 +01:00
Sascha Hauer b7a66554dc fs: Add function to get cdev by mountpath
This is useful to know for the bootloader spec implementation.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-11-05 08:37:55 +01:00
Sascha Hauer cd16227383 fs: add cdev mount helpers
Introduce helpers to iterate over cdevs and mount them to a known
path.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-09-30 16:03:02 +02:00
Sascha Hauer 7a1c5027f9 mount: implement -v option to print available filesystems
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>
2013-09-29 12:11:14 +02:00
Sascha Hauer d915fcbc6d fs: remove unused field 'name' from struct fs_driver_d
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-09-29 12:11:14 +02:00
Sascha Hauer ecb3aaa23b fs: cleanup backingstore handling
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>
2013-09-29 12:11:14 +02:00
Sascha Hauer 2d2ec6619b read_file: Make it work on tftp servers which do not pass size
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>
2013-06-20 08:42:46 +02:00
Alexander Aring 9d8a20592f fs: add pread and pwrite functions
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>
2013-02-20 08:22:42 +01:00
Alexander Aring e48b144071 fs: fix return type of read
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-18 11:09:46 +01:00
Sascha Hauer a886dac94e Add write_file function
write_file() will write a buffer to a file. The file is created
if necessary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-19 11:48:17 +01:00
Sascha Hauer 5a9d53c47e rm: implement -r
To recursively remove files and directories.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-11-29 20:21:29 +01:00
Sascha Hauer e5a927883e Merge branch 'for-next/link' 2012-09-05 12:59:29 +02: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 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 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 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 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 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 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 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 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 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 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 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 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 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 ee6d36a540 - introduce ioctl call
- pass open/close/lseek through to drivers
2008-06-06 09:30:48 +02:00
Sascha Hauer ce172e152e add ls -c and -l 2008-03-11 21:41:56 +01:00
Sascha Hauer a1a747af7f fix typo 2008-03-01 21:06:14 +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 Hauer 79ed00ba92 pass file size from read_file 2007-09-27 16:33:35 +02:00
Sascha Hauer 46d5705395 implement mkdir -p 2007-09-27 11:59:18 +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 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 a46f705cd9 svn_rev_634
add comments
2007-07-05 18:02:12 +02:00
Sascha Hauer e2f1a28306 svn_rev_605
make read_file global
2007-07-05 18:02:09 +02:00
Sascha Hauer 5a6358dcd0 svn_rev_453
add erase function
2007-07-05 18:01:55 +02:00
Sascha Hauer e694adc6a4 svn_rev_420
- do more POSIX:
  - use DIR instead of struct dirent
  - use (struct dirent)->d_name instead of (struct dirent)->name
- switch to a new layout for U_BOOT_CMD:
  - use C99 initializers to be able to add more fields to the
    command struct
  - add aliases for commands (needed mainly for help -> ? and test -> [
  - This is not done for all commands yet, but the compiler will tell you ;)
2007-07-05 18:01:52 +02:00
Sascha Hauer 014678f7a0 svn_rev_406
let normalise path allocate the string instead of changing the original one
2007-07-05 18:01:51 +02:00
Sascha Hauer ca69a14849 svn_rev_368
let mount take the device as string
2007-07-05 18:01:47 +02:00