]> xenbits.xensource.com Git - people/aperard/mini-os.git/commitdiff
add struct file_ops for FTYPE_FILE
authorJuergen Gross <jgross@suse.com>
Sun, 16 Jan 2022 08:33:27 +0000 (09:33 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 18 Jan 2022 18:26:43 +0000 (18:26 +0000)
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

index 538d6e7b19943038785744c9c8680246a2c8a987..7f3dc4e4a7694adae23b5235b236b2b9606a19a9 100644 (file)
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -99,6 +99,11 @@ static const struct file_ops file_ops_none = {
     .name = "none",
 };
 
+static const struct file_ops file_file_ops = {
+    .name = "file",
+    .lseek = lseek_default,
+};
+
 #ifdef HAVE_LWIP
 static int socket_read(struct file *file, void *buf, size_t nbytes)
 {
@@ -157,6 +162,7 @@ static const 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
@@ -415,16 +421,9 @@ off_t lseek(int fd, off_t offset, int whence)
     if ( ops->lseek )
         return ops->lseek(file, offset, whence);
 
-    switch(file->type) {
-       case FTYPE_FILE:
-          break;
-       default:
-          /* Not implemented for this filetype */
-          errno = ESPIPE;
-          return (off_t) -1;
-    }
-
-    return lseek_default(file, offset, whence);
+    /* Not implemented for this filetype */
+    errno = ESPIPE;
+    return (off_t) -1;
 }
 
 int fsync(int fd) {