Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.
All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.
All imported code from other projects is compatible with this license.
All GPL licensed code from other projects had previously been removed.
Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-02 17:38:16 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012, 2013, 2014, 2015 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
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* fs/kram.h
|
|
|
|
* Kernel RAM filesystem.
|
|
|
|
*/
|
2012-08-07 18:19:44 -04:00
|
|
|
|
|
|
|
#ifndef SORTIX_FS_KRAM_H
|
|
|
|
#define SORTIX_FS_KRAM_H
|
|
|
|
|
|
|
|
#include <sortix/kernel/inode.h>
|
|
|
|
#include <sortix/kernel/kthread.h>
|
2013-03-12 09:24:31 -04:00
|
|
|
#include <sortix/kernel/fcache.h>
|
2012-08-07 18:19:44 -04:00
|
|
|
|
|
|
|
namespace Sortix {
|
|
|
|
namespace KRAMFS {
|
|
|
|
|
|
|
|
struct DirEntry
|
|
|
|
{
|
|
|
|
Ref<Inode> inode;
|
|
|
|
char* name;
|
|
|
|
};
|
|
|
|
|
|
|
|
class File : public AbstractInode
|
|
|
|
{
|
|
|
|
public:
|
2014-09-22 11:35:54 -04:00
|
|
|
File(InodeType inode_type, mode_t type, dev_t dev, ino_t ino, uid_t owner,
|
|
|
|
gid_t group, mode_t mode);
|
2012-08-07 18:19:44 -04:00
|
|
|
virtual ~File();
|
|
|
|
virtual int truncate(ioctx_t* ctx, off_t length);
|
|
|
|
virtual off_t lseek(ioctx_t* ctx, off_t offset, int whence);
|
2017-01-09 17:40:56 -05:00
|
|
|
virtual ssize_t preadv(ioctx_t* ctx, const struct iovec* iov, int iovcnt,
|
2012-08-07 18:19:44 -04:00
|
|
|
off_t off);
|
2017-01-09 17:40:56 -05:00
|
|
|
virtual ssize_t pwritev(ioctx_t* ctx, const struct iovec* iov, int iovcnt,
|
|
|
|
off_t off);
|
2014-09-22 11:35:54 -04:00
|
|
|
virtual ssize_t readlink(ioctx_t* ctx, char* buf, size_t bufsiz);
|
2015-05-31 14:18:21 -04:00
|
|
|
virtual ssize_t tcgetblob(ioctx_t* ctx, const char* name, void* buffer,
|
|
|
|
size_t count);
|
|
|
|
virtual int statvfs(ioctx_t* ctx, struct statvfs* stvfs);
|
2012-08-07 18:19:44 -04:00
|
|
|
|
|
|
|
private:
|
2013-03-12 09:24:31 -04:00
|
|
|
FileCache fcache;
|
2012-08-07 18:19:44 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class Dir : public AbstractInode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Dir(dev_t dev, ino_t ino, uid_t owner, gid_t group, mode_t mode);
|
|
|
|
virtual ~Dir();
|
2015-11-19 20:57:09 -05:00
|
|
|
virtual ssize_t readdirents(ioctx_t* ctx, struct dirent* dirent,
|
|
|
|
size_t size, off_t start);
|
2012-08-07 18:19:44 -04:00
|
|
|
virtual Ref<Inode> open(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);
|
|
|
|
virtual int unlink(ioctx_t* ctx, const char* filename);
|
|
|
|
virtual int unlink_raw(ioctx_t* ctx, const char* filename);
|
|
|
|
virtual int rmdir(ioctx_t* ctx, const char* filename);
|
|
|
|
virtual int rmdir_me(ioctx_t* ctx);
|
|
|
|
virtual int symlink(ioctx_t* ctx, const char* oldname,
|
|
|
|
const char* filename);
|
2012-12-20 10:19:07 -05:00
|
|
|
virtual int rename_here(ioctx_t* ctx, Ref<Inode> from, const char* oldname,
|
|
|
|
const char* newname);
|
2015-05-31 14:18:21 -04:00
|
|
|
virtual ssize_t tcgetblob(ioctx_t* ctx, const char* name, void* buffer,
|
|
|
|
size_t count);
|
|
|
|
virtual int statvfs(ioctx_t* ctx, struct statvfs* stvfs);
|
2012-08-07 18:19:44 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
size_t FindChild(const char* filename);
|
|
|
|
bool AddChild(const char* filename, Ref<Inode> inode);
|
|
|
|
void RemoveChild(size_t index);
|
|
|
|
|
|
|
|
private:
|
2014-09-22 12:10:07 -04:00
|
|
|
kthread_mutex_t dir_lock;
|
|
|
|
size_t children_used;
|
|
|
|
size_t children_length;
|
2012-08-07 18:19:44 -04:00
|
|
|
DirEntry* children;
|
2014-09-22 12:10:07 -04:00
|
|
|
bool shut_down;
|
2012-08-07 18:19:44 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KRAMFS
|
|
|
|
} // namespace Sortix
|
|
|
|
|
|
|
|
#endif
|