#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
int open(const char *path, int flags, ...);
int fcntl(int fd, int cmd, ...);
#endif
+
+#endif
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;