Message ID | 20220111151215.22955-12-jgross@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mini-os: remove device specific struct file members | expand |
Juergen Gross, le mar. 11 janv. 2022 16:12:14 +0100, a ecrit: > FTYPE_FILE is the last relevant file type without a struct file_ops. > Add it. > > Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> > --- > lib/sys.c | 19 +++++++++---------- > 1 file changed, 9 insertions(+), 10 deletions(-) > > diff --git a/lib/sys.c b/lib/sys.c > index 12deaed..0f42e97 100644 > --- a/lib/sys.c > +++ b/lib/sys.c > @@ -99,6 +99,11 @@ static struct file_ops file_ops_none = { > .name = "none", > }; > > +static struct file_ops file_file_ops = { > + .name = "file", > + .lseek = lseek_default, > +}; > + > #ifdef HAVE_LWIP > static int socket_read(int fd, void *buf, size_t nbytes) > { > @@ -160,6 +165,7 @@ static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = { > #ifdef CONFIG_CONSFRONT > [FTYPE_CONSOLE] = &console_ops, > #endif > + [FTYPE_FILE] = &file_file_ops, > #ifdef HAVE_LWIP > [FTYPE_SOCKET] = &socket_ops, > #endif > @@ -397,16 +403,9 @@ off_t lseek(int fd, off_t offset, int whence) > if ( ops->lseek ) > return ops->lseek(fd, offset, whence); > > - switch(files[fd].type) { > - case FTYPE_FILE: > - break; > - default: > - /* Not implemented for this filetype */ > - errno = ESPIPE; > - return (off_t) -1; > - } > - > - return lseek_default(fd, offset, whence); > + /* Not implemented for this filetype */ > + errno = ESPIPE; > + return (off_t) -1; > } > > int fsync(int fd) { > -- > 2.26.2 >
diff --git a/lib/sys.c b/lib/sys.c index 12deaed..0f42e97 100644 --- a/lib/sys.c +++ b/lib/sys.c @@ -99,6 +99,11 @@ static struct file_ops file_ops_none = { .name = "none", }; +static struct file_ops file_file_ops = { + .name = "file", + .lseek = lseek_default, +}; + #ifdef HAVE_LWIP static int socket_read(int fd, void *buf, size_t nbytes) { @@ -160,6 +165,7 @@ static struct file_ops *file_ops[FTYPE_N + FTYPE_SPARE] = { #ifdef CONFIG_CONSFRONT [FTYPE_CONSOLE] = &console_ops, #endif + [FTYPE_FILE] = &file_file_ops, #ifdef HAVE_LWIP [FTYPE_SOCKET] = &socket_ops, #endif @@ -397,16 +403,9 @@ off_t lseek(int fd, off_t offset, int whence) if ( ops->lseek ) return ops->lseek(fd, offset, whence); - switch(files[fd].type) { - case FTYPE_FILE: - break; - default: - /* Not implemented for this filetype */ - errno = ESPIPE; - return (off_t) -1; - } - - return lseek_default(fd, offset, whence); + /* Not implemented for this filetype */ + errno = ESPIPE; + return (off_t) -1; } int fsync(int fd) {
FTYPE_FILE is the last relevant file type without a struct file_ops. Add it. Signed-off-by: Juergen Gross <jgross@suse.com> --- lib/sys.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)