]> xenbits.xensource.com Git - xen.git/commitdiff
Stubdom: add support for file creation.
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 18 Mar 2008 11:26:21 +0000 (11:26 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 18 Mar 2008 11:26:21 +0000 (11:26 +0000)
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
extras/mini-os/include/fcntl.h
extras/mini-os/lib/sys.c

index 34a6484d35758ee25bfa1b8ee7131de4d64f632c..0615790e5329e7844e538f6656dd6c0277941836 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef _I386_FCNTL_H
 #define _I386_FCNTL_H
 
+#ifdef HAVE_LIBC
+#include_next <fcntl.h>
+#else
+
 /* open/fcntl - O_SYNC is only implemented on blocks devices and on files
    located on an ext2 file system */
 #define O_ACCMODE         0003
@@ -90,3 +94,5 @@ struct flock64 {
 int open(const char *path, int flags, ...);
 int fcntl(int fd, int cmd, ...);
 #endif
+
+#endif
index 13096d1eca72c169b1b2c8e9cd44db3942c033ea..3e325b10a1a412ae838768951e5998dcf3983e49 100644 (file)
@@ -171,8 +171,26 @@ int open(const char *pathname, int flags, ...)
         printk("open(%s) -> %d\n", pathname, fd);
         return fd;
     }
-    printk("open(%s)", pathname);
-    fs_fd = fs_open(fs_import, (void *) pathname);
+    printk("open(%s, %x)", pathname, flags);
+    switch (flags & ~O_ACCMODE) {
+        case 0:
+            fs_fd = fs_open(fs_import, (void *) pathname);
+            break;
+        case O_CREAT|O_TRUNC:
+        {
+            va_list ap;
+            mode_t mode;
+            va_start(ap, flags);
+            mode = va_arg(ap, mode_t);
+            va_end(ap);
+            fs_fd = fs_create(fs_import, (void *) pathname, 0, mode);
+            break;
+        }
+        default:
+            printk(" unsupported flags\n");
+            stack_walk();
+            do_exit();
+    }
     if (fs_fd < 0) {
        errno = EIO;
        return -1;