diff --git a/libstorage/fs.c b/libstorage/fs.c index 6a7d842..3017998 100644 --- a/libstorage/fs.c +++ b/libstorage/fs.c @@ -22,145 +22,157 @@ void storage_fsHandler(void *data, msg_t *msg) storage_fs_t *fs; if (data == NULL) { - msg->o.io.err = -EINVAL; + msg->o.err = -EINVAL; return; } fs = (storage_fs_t *)data; if (fs->ops == NULL) { - msg->o.io.err = -EINVAL; + msg->o.err = -EINVAL; return; } switch (msg->type) { case mtOpen: if (fs->ops->open == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.io.err = fs->ops->open(fs->info, &msg->i.openclose.oid); + msg->o.err = fs->ops->open(fs->info, &msg->oid); break; case mtClose: if (fs->ops->close == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.io.err = fs->ops->close(fs->info, &msg->i.openclose.oid); + msg->o.err = fs->ops->close(fs->info, &msg->oid); break; case mtRead: if (fs->ops->read == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.io.err = fs->ops->read(fs->info, &msg->i.io.oid, msg->i.io.offs, msg->o.data, msg->o.size); + msg->o.err = fs->ops->read(fs->info, &msg->oid, msg->i.io.offs, msg->o.data, msg->o.size); break; case mtWrite: if (fs->ops->write == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.io.err = fs->ops->write(fs->info, &msg->i.io.oid, msg->i.io.offs, msg->i.data, msg->i.size); + msg->o.err = fs->ops->write(fs->info, &msg->oid, msg->i.io.offs, msg->i.data, msg->i.size); break; case mtTruncate: if (fs->ops->truncate == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.io.err = fs->ops->truncate(fs->info, &msg->i.io.oid, msg->i.io.len); + msg->o.err = fs->ops->truncate(fs->info, &msg->oid, msg->i.io.len); break; case mtDevCtl: if (fs->ops->devctl == NULL) { /* FIXME this error passing works by accident on ioctl(), * there's no dedicated error field for devctl. */ - msg->o.io.err = -ENOTTY; /* To return valid errno on ioctl() */ + msg->o.err = -ENOTTY; /* To return valid errno on ioctl() */ break; } - fs->ops->devctl(fs->info, &msg->i.io.oid, msg->i.raw, msg->o.raw); + fs->ops->devctl(fs->info, &msg->oid, msg->i.raw, msg->o.raw); break; case mtCreate: if (fs->ops->create == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.create.err = fs->ops->create(fs->info, &msg->i.create.dir, msg->i.data, &msg->o.create.oid, msg->i.create.mode, msg->i.create.type, &msg->i.create.dev); + msg->o.err = fs->ops->create(fs->info, &msg->oid, msg->i.data, &msg->o.create.oid, msg->i.create.mode, msg->i.create.type, &msg->i.create.dev); break; case mtDestroy: if (fs->ops->destroy == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.io.err = fs->ops->destroy(fs->info, &msg->i.destroy.oid); + msg->o.err = fs->ops->destroy(fs->info, &msg->oid); break; case mtSetAttr: if (fs->ops->setattr == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.attr.err = fs->ops->setattr(fs->info, &msg->i.attr.oid, msg->i.attr.type, msg->i.attr.val, msg->i.data, msg->i.size); + msg->o.err = fs->ops->setattr(fs->info, &msg->oid, msg->i.attr.type, msg->i.attr.val, msg->i.data, msg->i.size); break; case mtGetAttr: if (fs->ops->getattr == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.attr.err = fs->ops->getattr(fs->info, &msg->i.attr.oid, msg->i.attr.type, &msg->o.attr.val); + msg->o.err = fs->ops->getattr(fs->info, &msg->oid, msg->i.attr.type, &msg->o.attr.val); + break; + + case mtGetAttrAll: + if (fs->ops->getattrall == NULL) { + msg->o.err = -ENOSYS; + break; + } + if ((msg->o.size < sizeof(struct _attrAll)) || (msg->o.data == NULL)) { + msg->o.err = -EINVAL; + break; + } + msg->o.err = fs->ops->getattrall(fs->info, &msg->oid, (struct _attrAll *)msg->o.data); break; case mtLookup: if (fs->ops->lookup == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.lookup.err = fs->ops->lookup(fs->info, &msg->i.lookup.dir, msg->i.data, &msg->o.lookup.fil, &msg->o.lookup.dev, msg->o.data, msg->o.size); + msg->o.err = fs->ops->lookup(fs->info, &msg->oid, msg->i.data, &msg->o.lookup.fil, &msg->o.lookup.dev, msg->o.data, msg->o.size); break; case mtLink: if (fs->ops->link == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.io.err = fs->ops->link(fs->info, &msg->i.ln.dir, msg->i.data, &msg->i.ln.oid); + msg->o.err = fs->ops->link(fs->info, &msg->oid, msg->i.data, &msg->i.ln.oid); break; case mtUnlink: if (fs->ops->unlink == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.io.err = fs->ops->unlink(fs->info, &msg->i.ln.dir, msg->i.data); + msg->o.err = fs->ops->unlink(fs->info, &msg->oid, msg->i.data); break; case mtReaddir: if (fs->ops->readdir == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.io.err = fs->ops->readdir(fs->info, &msg->i.readdir.dir, msg->i.readdir.offs, msg->o.data, msg->o.size); + msg->o.err = fs->ops->readdir(fs->info, &msg->oid, msg->i.readdir.offs, msg->o.data, msg->o.size); break; case mtStat: if (fs->ops->statfs == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - msg->o.io.err = fs->ops->statfs(fs->info, msg->o.data, msg->o.size); + msg->o.err = fs->ops->statfs(fs->info, msg->o.data, msg->o.size); break; case mtSync: if (fs->ops->sync == NULL) { - msg->o.io.err = -ENOSYS; + msg->o.err = -ENOSYS; break; } - fs->ops->sync(fs->info, &msg->i.io.oid); + fs->ops->sync(fs->info, &msg->oid); break; default: diff --git a/libstorage/include/storage/fs.h b/libstorage/include/storage/fs.h index 478d7ee..d3b4fd6 100644 --- a/libstorage/include/storage/fs.h +++ b/libstorage/include/storage/fs.h @@ -29,10 +29,11 @@ typedef struct { ssize_t (*read)(void *info, oid_t *oid, off_t offs, void *data, size_t len); ssize_t (*write)(void *info, oid_t *oid, off_t offs, const void *data, size_t len); - int (*setattr)(void *info, oid_t *oid, int type, long long attr, void *data, size_t len); + int (*setattr)(void *info, oid_t *oid, int type, long long attr, const void *data, size_t len); int (*getattr)(void *info, oid_t *oid, int type, long long *attr); + int (*getattrall)(void *info, oid_t *oid, struct _attrAll *attrs); int (*truncate)(void *info, oid_t *oid, size_t size); - void (*devctl)(void *info, oid_t *oid, const void *in, void *out); + int (*devctl)(void *info, oid_t *oid, const void *in, void *out); int (*create)(void *info, oid_t *oid, const char *name, oid_t *dev, unsigned mode, int type, oid_t *res); int (*destroy)(void *info, oid_t *oid);