summaryrefslogtreecommitdiffstats
path: root/sdcard
diff options
context:
space:
mode:
authorPaul Eastham <eastham@google.com>2010-09-21 17:14:31 -0700
committerPaul Eastham <eastham@google.com>2010-09-24 08:13:49 -0700
commitf43219e0b1022b257499289ceb951f6a1a44bf9c (patch)
tree0b89575de92b1f48796803cf7f1b82429cfbb774 /sdcard
parentd7482b2f4cdd6a35f8707d94536801a958120b6b (diff)
downloadsystem_core-f43219e0b1022b257499289ceb951f6a1a44bf9c.tar.gz
system_core-f43219e0b1022b257499289ceb951f6a1a44bf9c.tar.bz2
system_core-f43219e0b1022b257499289ceb951f6a1a44bf9c.zip
Partially implement SETATTR for sdcard/FUSE
Handle truncate cases within SETATTR so that truncate() and ftruncate() call will work. Change-Id: I5a9862dcaa6ca7b5e9115cb5d3bfed88787fa7ac Signed-off-by: Paul Eastham <eastham@google.com>
Diffstat (limited to 'sdcard')
-rw-r--r--sdcard/sdcard.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index 27cbde255..8bb0c82cb 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -114,6 +114,12 @@ struct fuse {
#define PATH_BUFFER_SIZE 1024
+/*
+ * Get the real-life absolute path to a node.
+ * node: start at this node
+ * buf: storage for returned string
+ * name: append this string to path if set
+ */
char *node_get_path(struct node *node, char *buf, const char *name)
{
char *out = buf + PATH_BUFFER_SIZE - 1;
@@ -439,15 +445,27 @@ void handle_fuse_request(struct fuse *fuse, struct fuse_in_header *hdr, void *da
case FUSE_SETATTR: { /* setattr_in -> attr_out */
struct fuse_setattr_in *req = data;
struct fuse_attr_out out;
+ char *path, buffer[PATH_BUFFER_SIZE];
+ int res = 0;
+
TRACE("SETATTR fh=%llx id=%llx valid=%x\n",
req->fh, hdr->nodeid, req->valid);
- /* XXX */
+ /* XXX: incomplete implementation -- truncate only. chmod/chown
+ * should NEVER be implemented. */
+
+ path = node_get_path(node, buffer, 0);
+ if (req->valid & FATTR_SIZE)
+ res = truncate(path, req->size);
memset(&out, 0, sizeof(out));
node_get_attr(node, &out.attr);
out.attr_valid = 10;
- fuse_reply(fuse, hdr->unique, &out, sizeof(out));
+
+ if (res)
+ fuse_status(fuse, hdr->unique, -errno);
+ else
+ fuse_reply(fuse, hdr->unique, &out, sizeof(out));
return;
}
// case FUSE_READLINK: