summaryrefslogtreecommitdiffstats
path: root/fs/nfs.c
Commit message (Collapse)AuthorAgeFilesLines
* nfs: check return value of various rpc callsUwe Kleine-König2020-11-091-11/+113
| | | | | | | | | | | | | | | Check more carefully for failing requests. This improves the error message when trying to mount a non-exported nfs directory from: nfs_mount_req: file handle too big: 44831 to ERROR: NFS: Mounting failed: Permission denied . This also fixes an out-of-bounds access as the filehandle size (44831 above) is read from just after the network packet in the error case. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Add destroy_inode callbacks to filesystemsSascha Hauer2020-07-051-0/+8
| | | | | | | | | | | Several filesystems rely on the default function which frees the struct inode * rather than the filesystem specific inode which the inode is embedded in. This works because the inode is the first element in the filesystem specific inode. Let's not depend on this behaviour and for clarity add the destroy_inode callbacks to all filesystems. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove references to CREDITSUwe Kleine-König2020-04-271-3/+0
| | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: Do not allow to abortSascha Hauer2020-03-301-3/+0
| | | | | | | | | | | | | | When ctrl-c is pressed then ctrlc() will return true until ctrlc_handled() is called. This means that once ctrl-c is pressed every NFS operation will fail until the upper layer calls ctrlc_handled(). When for example we are doing a 'ls -l' on an NFS directory then after a ctrl-c press not the 'ls -l' aborts, but instead the retrieving of the directory entries which is not what we want. Simply do not call ctrlc() in the fs layer. the NFS timeout is 2 seconds which we have to wait until we have a chance to abort. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: nfs: don't maintain nfs dentries in dcacheSascha Hauer2020-03-301-0/+1
| | | | | | | nfs dentries may change underneath barebox, so do not maintain them in the dcache. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: queue received packetsSascha Hauer2020-03-301-23/+29
| | | | | | | | | It may happen that we receive more than one RPC packet before we come along to check the result. Instead of handling just a single received packet and possibly overwriting the last one queue the received RPC packets. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: Fix polling for packetsSascha Hauer2020-03-301-2/+5
| | | | | | | | | It can happen that the first packet we receive is not the desired one. In this case we have to poll for further packets. set nfs_state back to STATE_START before polling for more packets, otherwise we check the same packet again and again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: Fix rpc_check_reply() return value for stale packetsSascha Hauer2020-03-301-7/+2
| | | | | | | | | | | When we receive a packet with the previous rpc_id then we have the comment "stale packet, wait a bit longer", but that's not what the code does. rpc_check_reply() returns 0 in this case and the caller then interprets the packet as valid. Always return -EAGAIN for invalid rpc_ids. This lets the caller ignore the packets as intented. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: remove unnecessary checkSascha Hauer2020-03-301-3/+0
| | | | | | In rpc_check_reply() pkt is never NULL, drop the unnecessary patch. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: Add missing freeSascha Hauer2020-03-301-0/+1
| | | | | | Add forgotten packet free in error path. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: Add function to free packetsSascha Hauer2020-03-301-11/+16
| | | | | | | | Add to function to free packets rather than freeing them directly. We will introduce received packet qeueuing with one of the next patches, this patch is meant to make it better readable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: nfs: Fix possible buffer overflowSascha Hauer2019-09-021-0/+4
| | | | | | | | nfs_readlink_req() interprets a 32bit value directly received from the network as length argument to memcpy() without any boundary checking. Clamp the copy size at the end of the incoming packet. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: nfs: ensure rpc_req message is sendMarco Felsch2019-04-291-0/+11
| | | | | | | | | | | | | | Currently we send a rpc message without checking if the send was succesful and poll for a answer from the server. If the server didn't answer within the NFS_TIMEOUT window we send the package again. In case the package send wasn't successful we always run in that timeout. This gets even worse if the package send fails more than one time. Check if the package send was successful and resend the package if it wasn't to fix this behaviour. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/nfs'Sascha Hauer2019-02-131-58/+86
|\
| * fs/nfs: stop using a global variable for nfs packet payloadUwe Kleine-König2019-01-221-58/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | The lifetime of the data provided by a global variable is hard to track. So move the data pointer into the nfs_priv structure and let rpc_req return the data to its callers which in turn are responsible to free it. The callers are changed to use a local variable accordingly. This makes it plausible that the previous commit catched all usages of the global data. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs/nfs: copy data from rpc replies to local storageUwe Kleine-König2019-01-221-5/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The nfs code uses data provided to the packet handler after net_poll() returned. But the life time of this data already ended when net_poll() returns. Most of the time it is possible to get away here but on i.MX28 the data is overwritten since commit 82ec28929cc9 ("net: fec_imx: Do not use DMA coherent memory for Rx buffers"). So the data from the packet is copied to a malloced buffer that needs free()ing when the data is not used any more. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fs/nfs: don't try to set nfs error code from mount rpc callUwe Kleine-König2019-01-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A packet from a mount rpc call doesn't have an NFS error field, so don't try to access this. In the case of the MOUNT_UMOUNT procedure the reply package is short such that accessing the u32 after the rpc_reply structure is already after the end of the packet. Apart from the access to out-of-packet data there is no harm because the wrongly read value is unused. But make this more explicit by only using nfserr if the call was an NFS request. Fixes: 9ede56ad2476 ("fs: Add NFS support") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: let truncate take a loff_t argumentSascha Hauer2019-02-061-1/+1
| | | | | | | | | | | | | | loff_t is the correct type for file sizes. Use it to allow to truncate to sizes bigger than 32bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: devfs: Change .lseek callbacks to return 'int'Andrey Smirnov2019-02-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | Returning requested offset from .lseek() callback doesn't really give us any new information while bringing unnecessary complications. Change all .lseek() types (both in struct struct cdev_operations and in struct fs_driver_d) to return 'int' and adjust the rest of the codebase accordingly. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fs: Update FILE position in lseek()Andrey Smirnov2019-01-291-2/+1
|/ | | | | | | | | | Instead on relying on driver callbacks to update 'pos' in FILE, do it as a part of lseek() code. This allows us to drop a bit of repeating code as well as making lseek() implementation consistent with write() and read(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dns: return error codesSascha Hauer2018-11-291-1/+5
| | | | | | | | | | | | | | The resolv() function used to return the IP address. When net_udp_new() fails we return an error code though which the callers of resolv() take as an IP address. This is wrong of course and we could return 0 in this case. Instead we return an error code and pass the resolved IP as a pointer which allows us to return proper error codes. This patch also adds error messages and error returns to the various callers of resolv() which used to just continue with a zero IP and let the user figure out what went wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: nfs: Switch to dentry cache implementationSascha Hauer2018-07-131-308/+234
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* move parseopt to lib/Antony Pavlov2018-01-171-2/+1
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: nfs: pick up network interface bootargs parameterEnrico Jorns2016-09-221-0/+8
| | | | | | | | | | | | This adds the linux.bootarg device parameter from the network device of the current nfs connection and adds it to the nfs bootargs line. This allows booting from nfs without manually setting a ip=dhcp or ip=<ipaddr> option. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* convert users to %pI4Sascha Hauer2016-09-221-3/+1
| | | | | | | Convert users of ip_to_string() and print_IPaddr() to %pI4 and remove the now unused functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* string: Fix (v)asprintf prototypesSascha Hauer2016-04-151-5/+4
| | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: forward filesystem options to the kernel command lineJuergen Borleis2016-02-081-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | Using NFS in conjunction with boot spec and the feature to let Barebox auto generate a kernel command line must keep the options the NFS filesystem was mounted in Barebox. This patch extends the kernel command line parameter on demand if something different than the defaults are used. The command: barebox:/ boot nfs://myhost//root expands to the kernel command line: nfsroot=myhost:/root,v3,tcp while the command: barebox:/ boot nfs://myhost:2049//root expands now to the kernel command line: nfsroot=myhost:/root,v3,tcp,mountport=2049,port=2049 Signed-off-by: Juergen Borleis <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs/nfs.c: use SUNRPC_PORT remote port by defaultAntony Pavlov2015-07-201-1/+1
| | | | | | | pico_socket_connect() needs remote_port != 0. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs/nfs.c: use uint16_t for port numbersAntony Pavlov2015-07-201-2/+2
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: nfs: Implement Linux rootargSascha Hauer2015-06-181-0/+24
| | | | | | | Add the root= parameter for NFS filesystems. We currently hardcode v3 and tcp which probably needs to become configurable at some point. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: rename inode member of struct filep to privSascha Hauer2015-03-091-4/+4
| | | | | | | Because that's what it is. 'inode' will become confusing once we support real inodes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* sizes.h: move include/sizes.h to include/linux/sizes.hMasahiro Yamada2015-01-081-1/+1
| | | | | | | | | | | | | | This file originates in Linux. Linux has it under include/linux/ directory since commit dccd2304cc90. Let's move it to the same place as well in barebox. This commit was generated by the following commands: find -name '*.[chS]' | xargs sed -i -e 's:<sizes.h>:<linux/sizes.h>:' git mv include/sizes.h include/linux/ Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: parse nfsport and mount port from file system optionsUwe Kleine-König2014-02-101-11/+21
| | | | | | | | | | | | | This allows to use unfs3 on the server side which doesn't integrate into portmap/rpcbind which results in the port not being impossible to lookup via rpc calls to the portmap program. Use it like: mount -t nfs -o port=2703,mountport=2703 192.168.77.157:/root /mnt/nfs Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: switch to nfs3Uwe Kleine-König2014-02-101-269/+625
| | | | | | | This was tested against nfs-kernel-server and unfs3. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: drop an unneeded variable from nfs_do_open()Uwe Kleine-König2014-02-101-10/+8
| | | | | | | | While at it also fix the type of flen holding a string length (int -> size_t). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: simplify rpc_lookup_reqUwe Kleine-König2014-02-101-18/+6
| | | | | | | | Instead of letting rpc_lookup_req set mount_port and nfs_port, let it return the port found and let the caller use that information. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: shorten and simplify rpc_add_credentials a bitUwe Kleine-König2014-02-101-21/+5
| | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: skip over stale rpc packetsUwe Kleine-König2014-02-101-1/+6
| | | | | | | | | | When a former transaction was aborted by hitting Ctrl-C the old reply might still hang in the ethernet controller making all further transactions fail. So just skip over old replies. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: fix mount prog version in portmap lookupUwe Kleine-König2014-02-101-1/+1
| | | | | | | | We're speaking rpc mount version 2 (i.e. the same version as the implemented nfs protocol), so also specify that in the lookup. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* 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>
* fs/nfs: fix read when size < 1024Jean-Christophe PLAGNIOL-VILLARD2012-09-071-1/+5
| | | | | | | Currently we always request 1024. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nfs: add readlink supportJean-Christophe PLAGNIOL-VILLARD2012-09-051-28/+58
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* use loff_t for file offsetsSascha Hauer2012-06-301-1/+1
| | | | | | | 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: Add NFS supportSascha Hauer2012-05-141-0/+1054
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>