All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@eu.citrix.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] stubdom: support file creation
Date: Tue, 11 Mar 2008 17:36:52 +0000	[thread overview]
Message-ID: <20080311173652.GD5831@implementation.uk.xensource.com> (raw)

Stubdom: add support for file creation.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>

diff -r 73ec21ad5dc7 extras/mini-os/include/fcntl.h
--- a/extras/mini-os/include/fcntl.h	Tue Mar 11 16:01:04 2008 +0000
+++ b/extras/mini-os/include/fcntl.h	Tue Mar 11 17:35:14 2008 +0000
@@ -1,5 +1,9 @@
 #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 */
@@ -90,3 +94,5 @@ int open(const char *path, int flags, ..
 int open(const char *path, int flags, ...);
 int fcntl(int fd, int cmd, ...);
 #endif
+
+#endif
diff -r 73ec21ad5dc7 extras/mini-os/lib/sys.c
--- a/extras/mini-os/lib/sys.c	Tue Mar 11 16:01:04 2008 +0000
+++ b/extras/mini-os/lib/sys.c	Tue Mar 11 17:35:14 2008 +0000
@@ -172,8 +172,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;

                 reply	other threads:[~2008-03-11 17:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080311173652.GD5831@implementation.uk.xensource.com \
    --to=samuel.thibault@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.