summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-07-05 18:01:55 +0200
committerSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-07-05 18:01:55 +0200
commit44635dd22e0283614c21e4444cf93bea2e5695b4 (patch)
tree2b6e3e61f94dfe368a25dac77af8865e50144954 /fs
parenta042aaae0abd055cae8d4153702af7b9c59cbacc (diff)
downloadbarebox-44635dd22e0283614c21e4444cf93bea2e5695b4.tar.gz
barebox-44635dd22e0283614c21e4444cf93bea2e5695b4.tar.xz
svn_rev_452
add erase function
Diffstat (limited to 'fs')
-rw-r--r--fs/fs.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/fs/fs.c b/fs/fs.c
index 1d56c863f6..6165141426 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -47,7 +47,7 @@ static int init_cwd(void)
return 0;
}
-core_initcall(init_cwd);
+postcore_initcall(init_cwd);
/*
* - Remove all multiple slashes
@@ -448,6 +448,23 @@ out:
return errno;
}
+int erase(int fd, size_t count, unsigned long offset)
+{
+ struct device_d *dev;
+ struct fs_driver_d *fsdrv;
+ FILE *f = &files[fd];
+
+ dev = f->dev;
+
+ fsdrv = (struct fs_driver_d *)dev->driver->type_data;
+
+ if (f->pos + count > f->size)
+ count = f->size - f->pos;
+ errno = fsdrv->erase(dev, f, count, offset);
+
+ return errno;
+}
+
int close(int fd)
{
struct device_d *dev;