Skip to content

Commit

Permalink
!libstorage: adapt to msg api change
Browse files Browse the repository at this point in the history
JIRA: RTOS-792
  • Loading branch information
lukileczo authored and agkaminski committed Mar 21, 2024
1 parent e660606 commit 0a59a26
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 36 deletions.
80 changes: 46 additions & 34 deletions libstorage/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check failure on line 25 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 25 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct <anonymous>' has no member named 'err'

Check failure on line 25 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct <anonymous>' has no member named 'err'
return;
}

fs = (storage_fs_t *)data;
if (fs->ops == NULL) {
msg->o.io.err = -EINVAL;
msg->o.err = -EINVAL;

Check failure on line 31 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 31 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct <anonymous>' has no member named 'err'

Check failure on line 31 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct <anonymous>' has no member named 'err'
return;
}

switch (msg->type) {
case mtOpen:
if (fs->ops->open == NULL) {
msg->o.io.err = -ENOSYS;
msg->o.err = -ENOSYS;

Check failure on line 38 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 38 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct <anonymous>' has no member named 'err'

Check failure on line 38 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct <anonymous>' has no member named 'err'
break;
}
msg->o.io.err = fs->ops->open(fs->info, &msg->i.openclose.oid);
msg->o.err = fs->ops->open(fs->info, &msg->oid);

Check failure on line 41 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 41 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'msg_t' {aka 'struct _msg_t'} has no member named 'oid'; did you mean 'pid'?

Check failure on line 41 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct <anonymous>' has no member named 'err'

Check failure on line 41 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'msg_t' {aka 'struct _msg_t'} has no member named 'oid'; did you mean 'pid'?

Check failure on line 41 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct <anonymous>' has no member named 'err'

Check failure on line 41 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'msg_t' {aka 'struct _msg_t'} has no member named 'oid'; did you mean 'pid'?
break;

case mtClose:
if (fs->ops->close == NULL) {
msg->o.io.err = -ENOSYS;
msg->o.err = -ENOSYS;

Check failure on line 46 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 46 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct <anonymous>' has no member named 'err'

Check failure on line 46 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct <anonymous>' has no member named 'err'
break;
}
msg->o.io.err = fs->ops->close(fs->info, &msg->i.openclose.oid);
msg->o.err = fs->ops->close(fs->info, &msg->oid);

Check failure on line 49 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 49 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'msg_t' {aka 'struct _msg_t'} has no member named 'oid'; did you mean 'pid'?

Check failure on line 49 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct <anonymous>' has no member named 'err'

Check failure on line 49 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'msg_t' {aka 'struct _msg_t'} has no member named 'oid'; did you mean 'pid'?

Check failure on line 49 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct <anonymous>' has no member named 'err'

Check failure on line 49 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'msg_t' {aka 'struct _msg_t'} has no member named 'oid'; did you mean 'pid'?
break;

case mtRead:
if (fs->ops->read == NULL) {
msg->o.io.err = -ENOSYS;
msg->o.err = -ENOSYS;

Check failure on line 54 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 54 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct <anonymous>' has no member named 'err'

Check failure on line 54 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct <anonymous>' has no member named 'err'
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);

Check failure on line 57 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 57 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct <anonymous>' has no member named 'err'

Check failure on line 57 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct <anonymous>' has no member named 'err'
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);

Check warning on line 127 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

passing argument 3 of 'fs->ops->getattrall' from incompatible pointer type [-Wincompatible-pointer-types]

Check warning on line 127 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

passing argument 3 of 'fs->ops->getattrall' from incompatible pointer type [-Wincompatible-pointer-types]

Check warning on line 127 in libstorage/fs.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

passing argument 3 of 'fs->ops->getattrall' from incompatible pointer type [-Wincompatible-pointer-types]
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:
Expand Down
5 changes: 3 additions & 2 deletions libstorage/include/storage/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Check warning on line 34 in libstorage/include/storage/fs.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 34 in libstorage/include/storage/fs.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 34 in libstorage/include/storage/fs.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 34 in libstorage/include/storage/fs.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-qemu)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 34 in libstorage/include/storage/fs.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration

Check warning on line 34 in libstorage/include/storage/fs.h

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a9-zynq7000-zedboard)

'struct _attrAll' declared inside parameter list will not be visible outside of this definition or declaration
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);
Expand Down

0 comments on commit 0a59a26

Please sign in to comment.