lib: fdtable: Add callback for close() calls
Do not route close() calls via ioctl() as that is error prone and quite pointless. Instead create a callback for close() in fdtable and use it directly. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
4f34d90c8c
commit
2ed6b6a8ed
12 changed files with 108 additions and 64 deletions
|
@ -123,17 +123,23 @@ int open(const char *name, int flags, ...)
|
|||
return fd;
|
||||
}
|
||||
|
||||
static int fs_close_vmeth(void *obj)
|
||||
{
|
||||
struct posix_fs_desc *ptr = obj;
|
||||
int rc;
|
||||
|
||||
rc = fs_close(&ptr->file);
|
||||
posix_fs_free_obj(ptr);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int fs_ioctl_vmeth(void *obj, unsigned int request, va_list args)
|
||||
{
|
||||
int rc = 0;
|
||||
struct posix_fs_desc *ptr = obj;
|
||||
|
||||
switch (request) {
|
||||
case ZFD_IOCTL_CLOSE:
|
||||
rc = fs_close(&ptr->file);
|
||||
posix_fs_free_obj(ptr);
|
||||
break;
|
||||
|
||||
case ZFD_IOCTL_LSEEK: {
|
||||
off_t offset;
|
||||
int whence;
|
||||
|
@ -202,6 +208,7 @@ static ssize_t fs_read_vmeth(void *obj, void *buffer, size_t count)
|
|||
static struct fd_op_vtable fs_fd_op_vtable = {
|
||||
.read = fs_read_vmeth,
|
||||
.write = fs_write_vmeth,
|
||||
.close = fs_close_vmeth,
|
||||
.ioctl = fs_ioctl_vmeth,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue