ia64/xen-unstable

changeset 17231:1eae3adc5bf7

Stubdom: add support for file creation.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 18 11:26:21 2008 +0000 (2008-03-18)
parents 1efc81ab19cd
children 312053c2da89
files extras/mini-os/include/fcntl.h extras/mini-os/lib/sys.c
line diff
     1.1 --- a/extras/mini-os/include/fcntl.h	Tue Mar 18 11:15:20 2008 +0000
     1.2 +++ b/extras/mini-os/include/fcntl.h	Tue Mar 18 11:26:21 2008 +0000
     1.3 @@ -1,6 +1,10 @@
     1.4  #ifndef _I386_FCNTL_H
     1.5  #define _I386_FCNTL_H
     1.6  
     1.7 +#ifdef HAVE_LIBC
     1.8 +#include_next <fcntl.h>
     1.9 +#else
    1.10 +
    1.11  /* open/fcntl - O_SYNC is only implemented on blocks devices and on files
    1.12     located on an ext2 file system */
    1.13  #define O_ACCMODE	   0003
    1.14 @@ -90,3 +94,5 @@ struct flock64 {
    1.15  int open(const char *path, int flags, ...);
    1.16  int fcntl(int fd, int cmd, ...);
    1.17  #endif
    1.18 +
    1.19 +#endif
     2.1 --- a/extras/mini-os/lib/sys.c	Tue Mar 18 11:15:20 2008 +0000
     2.2 +++ b/extras/mini-os/lib/sys.c	Tue Mar 18 11:26:21 2008 +0000
     2.3 @@ -171,8 +171,26 @@ int open(const char *pathname, int flags
     2.4          printk("open(%s) -> %d\n", pathname, fd);
     2.5          return fd;
     2.6      }
     2.7 -    printk("open(%s)", pathname);
     2.8 -    fs_fd = fs_open(fs_import, (void *) pathname);
     2.9 +    printk("open(%s, %x)", pathname, flags);
    2.10 +    switch (flags & ~O_ACCMODE) {
    2.11 +        case 0:
    2.12 +            fs_fd = fs_open(fs_import, (void *) pathname);
    2.13 +            break;
    2.14 +        case O_CREAT|O_TRUNC:
    2.15 +        {
    2.16 +            va_list ap;
    2.17 +            mode_t mode;
    2.18 +            va_start(ap, flags);
    2.19 +            mode = va_arg(ap, mode_t);
    2.20 +            va_end(ap);
    2.21 +            fs_fd = fs_create(fs_import, (void *) pathname, 0, mode);
    2.22 +            break;
    2.23 +        }
    2.24 +        default:
    2.25 +            printk(" unsupported flags\n");
    2.26 +            stack_walk();
    2.27 +            do_exit();
    2.28 +    }
    2.29      if (fs_fd < 0) {
    2.30  	errno = EIO;
    2.31  	return -1;