summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2011-07-29 15:15:38 +0800
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2011-07-30 02:05:27 +0800
commit12ed40bb177d3c41362c0f96f082f67758c4acad (patch)
tree444014f305a0b0739ac39290e3a24035249e6325 /fs
parent805a4a0c7d51ba20ac29bc28b72b8bf9b9c0e80b (diff)
downloadbarebox-12ed40bb177d3c41362c0f96f082f67758c4acad.tar.gz
barebox-12ed40bb177d3c41362c0f96f082f67758c4acad.tar.xz
fs: switch to resource
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/devfs.c4
-rw-r--r--fs/fs.c8
2 files changed, 7 insertions, 5 deletions
diff --git a/fs/devfs.c b/fs/devfs.c
index 07ca16c553..66f7ca4162 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -161,7 +161,9 @@ static int devfs_ioctl(struct device_d *_dev, FILE *f, int request, void *buf)
static int devfs_truncate(struct device_d *dev, FILE *f, ulong size)
{
- if (size > f->dev->size)
+ if (f->dev->num_resources < 1)
+ return -ENOSPC;
+ if (size > f->dev->resource[0].size)
return -ENOSPC;
return 0;
}
diff --git a/fs/fs.c b/fs/fs.c
index bcc6ff439e..7d65ec819b 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1043,11 +1043,11 @@ ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong
ulong size;
struct device_d *dev;
- if (!cdev->dev)
+ if (!cdev->dev || cdev->dev->num_resources < 1)
return -1;
dev = cdev->dev;
- size = min((ulong)count, dev->size - offset);
+ size = min((ulong)count, dev->resource[0].size - offset);
memcpy_sz(buf, dev_get_mem_region(dev, 0) + offset, size, flags & O_RWSIZE_MASK);
return size;
}
@@ -1058,11 +1058,11 @@ ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, ulong offset
ulong size;
struct device_d *dev;
- if (!cdev->dev)
+ if (!cdev->dev || cdev->dev->num_resources < 1)
return -1;
dev = cdev->dev;
- size = min((ulong)count, dev->size - offset);
+ size = min((ulong)count, dev->resource[0].size - offset);
memcpy_sz(dev_get_mem_region(dev, 0) + offset, buf, size, flags & O_RWSIZE_MASK);
return size;
}