Commit d529a1e3 authored by Jonas Termansen's avatar Jonas Termansen

Add factory inode support.

parent 1240a442
......@@ -214,6 +214,8 @@ public:
size_t size, off_t start);
virtual Ref<Inode> open(ioctx_t* ctx, const char* filename, int flags,
mode_t mode);
virtual Ref<Inode> factory(ioctx_t* ctx, const char* filename, int flags,
mode_t mode);
virtual int mkdir(ioctx_t* ctx, const char* filename, mode_t mode);
virtual int link(ioctx_t* ctx, const char* filename, Ref<Inode> node);
virtual int link_raw(ioctx_t* ctx, const char* filename, Ref<Inode> node);
......@@ -1065,6 +1067,12 @@ Ref<Inode> Unode::open(ioctx_t* ctx, const char* filename, int flags,
return ret;
}
Ref<Inode> Unode::factory(ioctx_t* /*ctx*/, const char* /*filename*/,
int /*flags*/, mode_t /*mode*/)
{
return errno = EBADF, Ref<Inode>(NULL);
}
int Unode::mkdir(ioctx_t* ctx, const char* filename, mode_t mode)
{
Channel* channel = server->Connect(ctx);
......
/*
* Copyright (c) 2012, 2013, 2014 Jonas 'Sortie' Termansen.
* Copyright (c) 2012, 2013, 2014, 2016 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
......@@ -44,6 +44,9 @@ extern "C" {
#define O_SYMLINK_NOFOLLOW (1<<13)
#define O_NOCTTY (1<<14)
#define O_TTY_INIT (1<<15)
#ifdef __is_sortix_kernel
#define O_IS_STAT (1<<30)
#endif
#define O_ACCMODE (O_READ | O_WRITE | O_EXEC | O_SEARCH)
......
......@@ -73,6 +73,8 @@ public:
size_t size, off_t start) = 0;
virtual Ref<Inode> open(ioctx_t* ctx, const char* filename, int flags,
mode_t mode) = 0;
virtual Ref<Inode> factory(ioctx_t* ctx, const char* filename, int flags,
mode_t mode) = 0;
virtual int mkdir(ioctx_t* ctx, const char* filename, mode_t mode) = 0;
virtual int link(ioctx_t* ctx, const char* filename, Ref<Inode> node) = 0;
virtual int link_raw(ioctx_t* ctx, const char* filename, Ref<Inode> node) = 0;
......@@ -166,6 +168,8 @@ public:
size_t size, off_t start);
virtual Ref<Inode> open(ioctx_t* ctx, const char* filename, int flags,
mode_t mode);
virtual Ref<Inode> factory(ioctx_t* ctx, const char* filename, int flags,
mode_t mode);
virtual int mkdir(ioctx_t* ctx, const char* filename, mode_t mode);
virtual int link(ioctx_t* ctx, const char* filename, Ref<Inode> node);
virtual int link_raw(ioctx_t* ctx, const char* filename, Ref<Inode> node);
......
......@@ -84,6 +84,11 @@ struct stat
#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
#ifdef __is_sortix_kernel
#define S_IFFACTORY 0x10000
#define S_IFFACTORY_NOSTAT 0x20000
#endif
#define UTIME_NOW 0x3FFFFFFF
#define UTIME_OMIT 0x3FFFFFFE
......
......@@ -217,6 +217,14 @@ Ref<Inode> AbstractInode::open(ioctx_t* /*ctx*/, const char* /*filename*/,
return errno = ENOTDIR, Ref<Inode>(NULL);
}
Ref<Inode> AbstractInode::factory(ioctx_t* /*ctx*/, const char* /*filename*/,
int /*flags*/, mode_t /*mode*/)
{
if ( inode_type == INODE_TYPE_DIR )
return errno = EBADF, Ref<Inode>(NULL);
return errno = ENOTDIR, Ref<Inode>(NULL);
}
int AbstractInode::mkdir(ioctx_t* /*ctx*/, const char* /*filename*/,
mode_t /*mode*/)
{
......
......@@ -205,7 +205,8 @@ int sys_faccessat(int dirfd, const char* path, int mode, int flags)
ioctx_t ctx; SetupUserIOCtx(&ctx);
Ref<Descriptor> from = PrepareLookup(pathcopy, dirfd);
if ( !from ) { delete[] pathcopy; return -1; }
int open_flags = O_READ | (flags & AT_SYMLINK_NOFOLLOW ? O_SYMLINK_NOFOLLOW : 0);
int open_flags = O_READ | O_IS_STAT |
(flags & AT_SYMLINK_NOFOLLOW ? O_SYMLINK_NOFOLLOW : 0);
Ref<Descriptor> desc = from->open(&ctx, pathcopy, open_flags);
delete[] pathcopy;
if ( !desc )
......@@ -290,7 +291,8 @@ int sys_fstatat(int dirfd, const char* path, struct stat* st, int flags)
ioctx_t ctx; SetupUserIOCtx(&ctx);
Ref<Descriptor> from = PrepareLookup(pathcopy, dirfd);
if ( !from ) { delete[] pathcopy; return -1; }
int open_flags = O_READ | (flags & AT_SYMLINK_NOFOLLOW ? O_SYMLINK_NOFOLLOW : 0);
int open_flags = O_READ | O_IS_STAT |
(flags & AT_SYMLINK_NOFOLLOW ? O_SYMLINK_NOFOLLOW : 0);
Ref<Descriptor> desc = from->open(&ctx, pathcopy, open_flags);
delete[] pathcopy;
if ( !desc )
......@@ -326,7 +328,8 @@ int sys_fstatvfsat(int dirfd, const char* path, struct statvfs* stvfs, int flags
ioctx_t ctx; SetupUserIOCtx(&ctx);
Ref<Descriptor> from = PrepareLookup(pathcopy, dirfd);
if ( !from ) { delete[] pathcopy; return -1; }
int open_flags = O_READ | (flags & AT_SYMLINK_NOFOLLOW ? O_SYMLINK_NOFOLLOW : 0);
int open_flags = O_READ | O_IS_STAT |
(flags & AT_SYMLINK_NOFOLLOW ? O_SYMLINK_NOFOLLOW : 0);
Ref<Descriptor> desc = from->open(&ctx, pathcopy, open_flags);
delete[] pathcopy;
if ( !desc )
......
......@@ -98,6 +98,13 @@ Ref<Vnode> Vnode::open(ioctx_t* ctx, const char* filename, int flags, mode_t mod
Ref<Inode> retinode = inode->open(ctx, filename, flags, mode);
if ( !retinode )
return Ref<Vnode>(NULL);
if ( retinode->type & S_IFFACTORY &&
!(retinode->type & S_IFFACTORY_NOSTAT && flags & O_IS_STAT) )
{
retinode = retinode->factory(ctx, filename, flags, mode);
if ( !retinode )
return Ref<Vnode>(NULL);
}
Ref<Vnode> retmountedat = mountedat;
ino_t retrootino = rootino;
dev_t retrootdev = rootdev;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment