/*
 * wnix, a Unix-like operating system for WebAssembly applications.
 * Copyright (C) 2025  Xavier Del Campo Romero
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef _SYS_STAT_H
#define _SYS_STAT_H

#include <sys/types.h>
#include <time.h>

#define S_IRWXU 0700
#define S_IRUSR 0400
#define S_IWUSR 0200
#define S_IXUSR 0100
#define S_IRWXG 070
#define S_IRGRP 040
#define S_IWGRP 020
#define S_IXGRP 010
#define S_IRWXO 07
#define S_IROTH 04
#define S_IWOTH 02
#define S_IXOTH 1

#define S_IFBLK ((mode_t)1)
#define S_IFCHR ((mode_t)(1 << 1))
#define S_IFIFO ((mode_t)(1 << 2))
#define S_IFREG ((mode_t)(1 << 3))
#define S_IFDIR ((mode_t)(1 << 4))
#define S_IFLNK ((mode_t)(1 << 5))
#define S_IFSOCK ((mode_t)(1 << 6))

#define S_ISBLK(__m) ((__m) & S_IFBLK)
#define S_ISCHR(__m) ((__m) & S_IFCHR)
#define S_ISDIR(__m) ((__m) & S_IFDIR)
#define S_ISFIFO(__m) ((__m) & S_IFIFO)
#define S_ISREG(__m) ((__m) & S_IFREG)
#define S_ISLNK(__m) ((__m) & S_IFLNK)
#define S_ISSOCK(__m) ((__m) & S_IFSOCK)

struct stat
{
    dev_t st_dev;
    ino_t st_ino;
    mode_t st_mode;
    nlink_t st_nlink;
    uid_t st_uid;
    gid_t st_gid;
    dev_t st_rdev;
    off_t st_size;
    struct timespec st_atim, st_mtim, st_ctim;
    blksize_t st_blksize;
    blkcnt_t st_blocks;
};

int mkdir(const char *__pathname, mode_t __flags);
mode_t umask(mode_t __mask);

#endif
