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 22:38:16 +00:00
|
|
|
/*
|
2017-01-09 22:40:56 +00:00
|
|
|
* Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017 Jonas 'Sortie' Termansen.
|
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 22:38:16 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* sortix/kernel/vnode.h
|
|
|
|
* Nodes in the virtual filesystem.
|
|
|
|
*/
|
2012-08-07 22:19:44 +00:00
|
|
|
|
2013-03-22 19:19:45 +00:00
|
|
|
#ifndef INCLUDE_SORTIX_KERNEL_VNODE_H
|
|
|
|
#define INCLUDE_SORTIX_KERNEL_VNODE_H
|
|
|
|
|
2013-12-20 20:55:05 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2013-03-22 19:19:45 +00:00
|
|
|
#include <sortix/timespec.h>
|
2012-08-07 22:19:44 +00:00
|
|
|
|
|
|
|
#include <sortix/kernel/refcount.h>
|
|
|
|
|
2015-11-20 01:57:09 +00:00
|
|
|
struct dirent;
|
2017-01-09 22:40:56 +00:00
|
|
|
struct iovec;
|
|
|
|
struct msghdr;
|
2012-08-07 22:19:44 +00:00
|
|
|
struct stat;
|
2014-01-20 23:53:18 +00:00
|
|
|
struct statvfs;
|
2016-01-23 19:56:07 +00:00
|
|
|
struct termios;
|
2013-12-20 20:55:05 +00:00
|
|
|
struct wincurpos;
|
2012-08-07 22:19:44 +00:00
|
|
|
struct winsize;
|
|
|
|
|
|
|
|
namespace Sortix {
|
|
|
|
|
2012-12-29 22:09:09 +00:00
|
|
|
class PollNode;
|
2012-08-07 22:19:44 +00:00
|
|
|
class Inode;
|
|
|
|
struct ioctx_struct;
|
|
|
|
typedef struct ioctx_struct ioctx_t;
|
|
|
|
|
|
|
|
// An interface describing all operations possible on an vnode.
|
|
|
|
class Vnode : public Refcountable
|
|
|
|
{
|
|
|
|
public: /* These must never change after construction and is read-only. */
|
|
|
|
ino_t ino;
|
|
|
|
dev_t dev;
|
|
|
|
mode_t type; // For use by S_IS* macros.
|
|
|
|
|
|
|
|
public:
|
|
|
|
Vnode(Ref<Inode> inode, Ref<Vnode> mountedat, ino_t rootino, dev_t rootdev);
|
|
|
|
virtual ~Vnode();
|
|
|
|
int sync(ioctx_t* ctx);
|
|
|
|
int stat(ioctx_t* ctx, struct stat* st);
|
2014-01-20 23:53:18 +00:00
|
|
|
int statvfs(ioctx_t* ctx, struct statvfs* stvfs);
|
2012-08-07 22:19:44 +00:00
|
|
|
int chmod(ioctx_t* ctx, mode_t mode);
|
|
|
|
int chown(ioctx_t* ctx, uid_t owner, gid_t group);
|
|
|
|
int truncate(ioctx_t* ctx, off_t length);
|
|
|
|
off_t lseek(ioctx_t* ctx, off_t offset, int whence);
|
|
|
|
ssize_t read(ioctx_t* ctx, uint8_t* buf, size_t count);
|
2017-01-09 22:40:56 +00:00
|
|
|
ssize_t readv(ioctx_t* ctx, const struct iovec* iov, int iovcnt);
|
2012-08-07 22:19:44 +00:00
|
|
|
ssize_t pread(ioctx_t* ctx, uint8_t* buf, size_t count, off_t off);
|
2017-01-09 22:40:56 +00:00
|
|
|
ssize_t preadv(ioctx_t* ctx, const struct iovec* iov, int iovcnt,
|
|
|
|
off_t off);
|
2012-08-07 22:19:44 +00:00
|
|
|
ssize_t write(ioctx_t* ctx, const uint8_t* buf, size_t count);
|
2017-01-09 22:40:56 +00:00
|
|
|
ssize_t writev(ioctx_t* ctx, const struct iovec* iov, int iovcnt);
|
2012-08-07 22:19:44 +00:00
|
|
|
ssize_t pwrite(ioctx_t* ctx, const uint8_t* buf, size_t count, off_t off);
|
2017-01-09 22:40:56 +00:00
|
|
|
ssize_t pwritev(ioctx_t* ctx, const struct iovec* iov, int iovcnt,
|
|
|
|
off_t off);
|
2016-02-24 15:29:37 +00:00
|
|
|
int utimens(ioctx_t* ctx, const struct timespec* times);
|
2012-08-07 22:19:44 +00:00
|
|
|
int isatty(ioctx_t* ctx);
|
2015-11-20 01:57:09 +00:00
|
|
|
ssize_t readdirents(ioctx_t* ctx, struct dirent* dirent, size_t size,
|
|
|
|
off_t start);
|
2012-08-07 22:19:44 +00:00
|
|
|
Ref<Vnode> open(ioctx_t* ctx, const char* filename, int flags, mode_t mode);
|
|
|
|
int mkdir(ioctx_t* ctx, const char* filename, mode_t mode);
|
|
|
|
int unlink(ioctx_t* ctx, const char* filename);
|
|
|
|
int rmdir(ioctx_t* ctx, const char* filename);
|
|
|
|
int link(ioctx_t* ctx, const char* filename, Ref<Vnode> node);
|
|
|
|
int symlink(ioctx_t* ctx, const char* oldname, const char* filename);
|
|
|
|
ssize_t readlink(ioctx_t* ctx, char* buf, size_t bufsiz);
|
|
|
|
int fsbind(ioctx_t* ctx, Vnode* node, int flags);
|
2013-12-20 20:55:05 +00:00
|
|
|
int tcgetwincurpos(ioctx_t* ctx, struct wincurpos* wcp);
|
2016-11-15 20:08:41 +00:00
|
|
|
int ioctl(ioctx_t* ctx, int cmd, uintptr_t arg);
|
2013-06-12 00:18:07 +00:00
|
|
|
int tcsetpgrp(ioctx_t* ctx, pid_t pgid);
|
|
|
|
pid_t tcgetpgrp(ioctx_t* ctx);
|
2012-08-07 22:19:44 +00:00
|
|
|
int settermmode(ioctx_t* ctx, unsigned mode);
|
|
|
|
int gettermmode(ioctx_t* ctx, unsigned* mode);
|
2012-12-29 22:09:09 +00:00
|
|
|
int poll(ioctx_t* ctx, PollNode* node);
|
2012-12-20 15:19:07 +00:00
|
|
|
int rename_here(ioctx_t* ctx, Ref<Vnode> from, const char* oldname,
|
|
|
|
const char* newname);
|
2017-02-25 16:00:24 +00:00
|
|
|
Ref<Vnode> accept4(ioctx_t* ctx, uint8_t* addr, size_t* addrlen, int flags);
|
2013-03-19 21:40:37 +00:00
|
|
|
int bind(ioctx_t* ctx, const uint8_t* addr, size_t addrlen);
|
|
|
|
int connect(ioctx_t* ctx, const uint8_t* addr, size_t addrlen);
|
|
|
|
int listen(ioctx_t* ctx, int backlog);
|
|
|
|
ssize_t recv(ioctx_t* ctx, uint8_t* buf, size_t count, int flags);
|
2017-01-09 22:40:56 +00:00
|
|
|
ssize_t recvmsg(ioctx_t* ctx, struct msghdr* msg, int flags);
|
2013-03-19 21:40:37 +00:00
|
|
|
ssize_t send(ioctx_t* ctx, const uint8_t* buf, size_t count, int flags);
|
2017-01-09 22:40:56 +00:00
|
|
|
ssize_t sendmsg(ioctx_t* ctx, const struct msghdr* msg, int flags);
|
2014-02-28 16:10:08 +00:00
|
|
|
int getsockopt(ioctx_t* ctx, int level, int option_name,
|
|
|
|
void* option_value, size_t* option_size_ptr);
|
|
|
|
int setsockopt(ioctx_t* ctx, int level, int option_name,
|
|
|
|
const void* option_value, size_t option_size);
|
2014-05-05 19:36:40 +00:00
|
|
|
ssize_t tcgetblob(ioctx_t* ctx, const char* name, void* buffer, size_t count);
|
|
|
|
ssize_t tcsetblob(ioctx_t* ctx, const char* name, const void* buffer, size_t count);
|
2014-05-07 12:14:38 +00:00
|
|
|
int unmount(ioctx_t* ctx, const char* filename, int flags);
|
|
|
|
int fsm_fsbind(ioctx_t* ctx, Ref<Vnode> target, int flags);
|
|
|
|
Ref<Vnode> fsm_mount(ioctx_t* ctx, const char* filename, const struct stat* rootst, int flags);
|
2016-01-23 19:56:07 +00:00
|
|
|
int tcdrain(ioctx_t* ctx);
|
|
|
|
int tcflow(ioctx_t* ctx, int action);
|
|
|
|
int tcflush(ioctx_t* ctx, int queue_selector);
|
|
|
|
int tcgetattr(ioctx_t* ctx, struct termios* tio);
|
|
|
|
pid_t tcgetsid(ioctx_t* ctx);
|
|
|
|
int tcsendbreak(ioctx_t* ctx, int duration);
|
|
|
|
int tcsetattr(ioctx_t* ctx, int actions, const struct termios* tio);
|
2016-08-06 13:44:37 +00:00
|
|
|
int shutdown(ioctx_t* ctx, int how);
|
2017-02-23 19:12:26 +00:00
|
|
|
int getpeername(ioctx_t* ctx, uint8_t* addr, size_t* addrsize);
|
|
|
|
int getsockname(ioctx_t* ctx, uint8_t* addr, size_t* addrsize);
|
2012-08-07 22:19:44 +00:00
|
|
|
|
2013-01-30 19:33:13 +00:00
|
|
|
public /*TODO: private*/:
|
2012-08-07 22:19:44 +00:00
|
|
|
Ref<Inode> inode;
|
|
|
|
Ref<Vnode> mountedat;
|
|
|
|
ino_t rootino;
|
|
|
|
dev_t rootdev;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Sortix
|
|
|
|
|
|
|
|
#endif
|