diff options
author | Vicente <vicencb@gmail.com> | 2012-10-08 00:01:22 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-10-08 21:57:13 +0200 |
commit | 7c16deba8cbb3626bec19ea9f135d6571bf98d11 (patch) | |
tree | c5008b89f87809d1510d4fd08460fc4e642c3aa0 /fs | |
parent | bad4d7cd754579cfe20cba4c721b2c1269bfa2d8 (diff) | |
download | barebox-7c16deba8cbb3626bec19ea9f135d6571bf98d11.tar.gz barebox-7c16deba8cbb3626bec19ea9f135d6571bf98d11.tar.xz |
fs: improve robustness
Signed-off-by: Vicente <vicencb@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fs.c | 27 |
1 files changed, 18 insertions, 9 deletions
@@ -715,12 +715,13 @@ int ioctl(int fd, int request, void *buf) { struct device_d *dev; struct fs_driver_d *fsdrv; - FILE *f = &files[fd]; + FILE *f; int ret; if (check_fd(fd)) return -errno; + f = &files[fd]; dev = f->dev; fsdrv = dev_to_fs_driver(dev); @@ -738,12 +739,13 @@ int read(int fd, void *buf, size_t count) { struct device_d *dev; struct fs_driver_d *fsdrv; - FILE *f = &files[fd]; + FILE *f; int ret; if (check_fd(fd)) return -errno; + f = &files[fd]; dev = f->dev; fsdrv = dev_to_fs_driver(dev); @@ -768,12 +770,13 @@ ssize_t write(int fd, const void *buf, size_t count) { struct device_d *dev; struct fs_driver_d *fsdrv; - FILE *f = &files[fd]; + FILE *f; int ret; if (check_fd(fd)) return -errno; + f = &files[fd]; dev = f->dev; fsdrv = dev_to_fs_driver(dev); @@ -803,12 +806,13 @@ int flush(int fd) { struct device_d *dev; struct fs_driver_d *fsdrv; - FILE *f = &files[fd]; + FILE *f; int ret; if (check_fd(fd)) return -errno; + f = &files[fd]; dev = f->dev; fsdrv = dev_to_fs_driver(dev); @@ -827,13 +831,14 @@ loff_t lseek(int fildes, loff_t offset, int whence) { struct device_d *dev; struct fs_driver_d *fsdrv; - FILE *f = &files[fildes]; + FILE *f; loff_t pos; int ret; if (check_fd(fildes)) return -1; + f = &files[fildes]; dev = f->dev; fsdrv = dev_to_fs_driver(dev); if (!fsdrv->lseek) { @@ -877,11 +882,12 @@ int erase(int fd, size_t count, unsigned long offset) { struct device_d *dev; struct fs_driver_d *fsdrv; - FILE *f = &files[fd]; + FILE *f; int ret; if (check_fd(fd)) return -errno; + f = &files[fd]; if (offset >= f->size) return 0; if (count > f->size - offset) @@ -905,11 +911,12 @@ int protect(int fd, size_t count, unsigned long offset, int prot) { struct device_d *dev; struct fs_driver_d *fsdrv; - FILE *f = &files[fd]; + FILE *f; int ret; if (check_fd(fd)) return -errno; + f = &files[fd]; if (offset >= f->size) return 0; if (count > f->size - offset) @@ -948,13 +955,14 @@ void *memmap(int fd, int flags) { struct device_d *dev; struct fs_driver_d *fsdrv; - FILE *f = &files[fd]; + FILE *f; void *retp = (void *)-1; int ret; if (check_fd(fd)) return retp; + f = &files[fd]; dev = f->dev; fsdrv = dev_to_fs_driver(dev); @@ -975,12 +983,13 @@ int close(int fd) { struct device_d *dev; struct fs_driver_d *fsdrv; - FILE *f = &files[fd]; + FILE *f; int ret; if (check_fd(fd)) return -errno; + f = &files[fd]; dev = f->dev; fsdrv = dev_to_fs_driver(dev); |