123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- #pragma once
- #include <sys/cdefs.h>
- #include <sys/types.h>
- __BEGIN_DECLS
- #define S_IFMT 0170000
- #define S_IFDIR 0040000
- #define S_IFCHR 0020000
- #define S_IFBLK 0060000
- #define S_IFREG 0100000
- #define S_IFIFO 0010000
- #define S_IFLNK 0120000
- #define S_IFSOCK 0140000
- #define S_ISUID 04000
- #define S_ISGID 02000
- #define S_ISVTX 01000
- #define S_IRUSR 0400
- #define S_IWUSR 0200
- #define S_IXUSR 0100
- #define S_IREAD S_IRUSR
- #define S_IWRITE S_IWUSR
- #define S_IEXEC S_IXUSR
- #define S_IRGRP 0040
- #define S_IWGRP 0020
- #define S_IXGRP 0010
- #define S_IROTH 0004
- #define S_IWOTH 0002
- #define S_IXOTH 0001
- #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
- #define S_IRWXG (S_IRWXU >> 3)
- #define S_IRWXO (S_IRWXG >> 3)
- #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
- #define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR)
- #define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK)
- #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
- #define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO)
- #define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK)
- #define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK)
- struct stat {
- dev_t st_dev; /* ID of device containing file */
- ino_t st_ino; /* inode number */
- mode_t st_mode; /* protection */
- nlink_t st_nlink; /* number of hard links */
- uid_t st_uid; /* user ID of owner */
- gid_t st_gid; /* group ID of owner */
- dev_t st_rdev; /* device ID (if special file) */
- off_t st_size; /* total size, in bytes */
- blksize_t st_blksize; /* blocksize for file system I/O */
- blkcnt_t st_blocks; /* number of 512B blocks allocated */
- time_t st_atime; /* time of last access */
- time_t st_mtime; /* time of last modification */
- time_t st_ctime; /* time of last status change */
- };
- mode_t umask(mode_t);
- int chmod(const char* pathname, mode_t);
- int fchmod(int fd, mode_t);
- int mkdir(const char* pathname, mode_t);
- int mkfifo(const char* pathname, mode_t);
- int fstat(int fd, struct stat* statbuf);
- int lstat(const char* path, struct stat* statbuf);
- int stat(const char* path, struct stat* statbuf);
- inline dev_t makedev(unsigned int major, unsigned int minor) { return (minor & 0xffu) | (major << 8u) | ((minor & ~0xffu) << 12u); }
- inline unsigned int major(dev_t dev) { return (dev & 0xfff00u) >> 8u; }
- inline unsigned int minor(dev_t dev) { return (dev & 0xffu) | ((dev >> 12u) & 0xfff00u); }
- __END_DECLS
|