Skip to content

Commit

Permalink
libstorage: Fix ioctl() handling on fs
Browse files Browse the repository at this point in the history
- return devctl error only via output argument,
- return -ENOTTY when no devctl handler is provided to return valid errno from ioctl()

JIRA: RTOS-525
  • Loading branch information
agkaminski committed Jul 20, 2023
1 parent 501a319 commit b23deda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions libstorage/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ void storage_fsHandler(void *data, msg_t *msg)

case mtDevCtl:
if (fs->ops->devctl == NULL) {
msg->o.io.err = -ENOSYS;
/* 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() */
break;
}
(void)fs->ops->devctl(fs->info, &msg->i.io.oid, msg->i.raw, msg->o.raw);
fs->ops->devctl(fs->info, &msg->i.io.oid, msg->i.raw, msg->o.raw);
break;

case mtCreate:
Expand Down
2 changes: 1 addition & 1 deletion libstorage/include/storage/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef struct {
int (*setattr)(void *info, oid_t *oid, int type, long long attr, void *data, size_t len);
int (*getattr)(void *info, oid_t *oid, int type, long long *attr);
int (*truncate)(void *info, oid_t *oid, size_t size);
int (*devctl)(void *info, oid_t *oid, const void *in, void *out);
void (*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 b23deda

Please sign in to comment.