Fix <fcntl.h> including <sys/stat.h> namespace pollution.

POSIX allows <fcntl.h> to include <sys/stat.h>, but doesn't require it.
There's little reason to do that, since they are separate headers, and
<fcntl.h> just needs the mode_t constants. Fix the code accidentally
relying on <fcntl.h> including <sys/stat.h>. The mode_t constants are now
provided in their own kernel header <sortix/mode.h>.

Additionally fix <sys/stat.h> pulling in all of <sys/types.h>, which is not
allowed by POSIX, which only requires a few types to be declared. Fix the
code accidentally relying on <sys/stat.h> including <sys/types.h>.

Finally fix <dirent.h> pulling in <stdint.h> through <sortix/dirent.h>.

The <sortix/__/dt.h> and <sortix/__/stat.h> headers are no longer required
and their contents have been merged into <sortix/__/dirent.h>.
This commit is contained in:
Jonas 'Sortie' Termansen 2018-07-14 22:34:48 +02:00
parent 9c3af039ca
commit 29555d72bb
17 changed files with 166 additions and 232 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, 2013, 2014, 2015 Jonas 'Sortie' Termansen.
* Copyright (c) 2011, 2012, 2013, 2014, 2015, 2018 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
@ -22,8 +22,6 @@
#include <sys/cdefs.h>
#include <sys/__/types.h>
#include <sortix/dirent.h>
#if defined(__is_sortix_libc)

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, 2013, 2014 Jonas 'Sortie' Termansen.
* Copyright (c) 2011, 2012, 2013, 2014, 2018 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
@ -24,14 +24,9 @@
#include <sys/__/types.h>
#include <sys/stat.h>
#include <sortix/fcntl.h>
#include <sortix/seek.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <sortix/mode.h>
/* The kernel would like to simply deal with one bit for each base access mode,
but using the traditional names O_RDONLY, O_WRONLY and O_RDWR for this would
@ -51,6 +46,20 @@ extern "C" {
typedef __pid_t pid_t;
#endif
#ifndef __off_t_defined
#define __off_t_defined
typedef __off_t off_t;
#endif
#ifndef __mode_t_defined
#define __mode_t_defined
typedef __mode_t mode_t;
#endif
#ifdef __cplusplus
extern "C" {
#endif
int creat(const char* path, mode_t mode);
int fcntl(int fd, int cmd, ...);
int open(const char* path, int oflag, ...);

View file

@ -21,6 +21,7 @@
#define INCLUDE_FSMARSHALL_MSG_H
#include <sys/cdefs.h>
#include <sys/types.h>
#include <stddef.h>

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, 2013, 2014, 2015 Jonas 'Sortie' Termansen.
* Copyright (c) 2011, 2012, 2013, 2014, 2015, 2018 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
@ -24,77 +24,24 @@
#include <sys/__/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __blkcnt_t_defined
#define __blkcnt_t_defined
typedef __blkcnt_t blkcnt_t;
#endif
#ifndef __blksize_t_defined
#define __blksize_t_defined
typedef __blksize_t blksize_t;
#endif
#ifndef __dev_t_defined
#define __dev_t_defined
typedef __dev_t dev_t;
#endif
#ifndef __ino_t_defined
#define __ino_t_defined
typedef __ino_t ino_t;
#endif
#include <sortix/timespec.h>
#include <sortix/stat.h>
#ifndef __mode_t_defined
#define __mode_t_defined
typedef __mode_t mode_t;
#endif
#ifndef __nlink_t_defined
#define __nlink_t_defined
typedef __nlink_t nlink_t;
#endif
#ifndef __uid_t_defined
#define __uid_t_defined
typedef __uid_t uid_t;
#endif
#ifndef __gid_t_defined
#define __gid_t_defined
typedef __gid_t gid_t;
#endif
#ifndef __off_t_defined
#define __off_t_defined
typedef __off_t off_t;
#endif
#ifndef __time_t_defined
#define __time_t_defined
typedef __time_t time_t;
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#include <sortix/timespec.h>
#include <sortix/stat.h>
#ifdef __cplusplus
extern "C" {
#endif
/* POSIX mandates that we define these compatibility macros to support programs
that are yet to embrace struct timespec. */
#define st_atime st_atim.tv_sec
#define st_ctime st_ctim.tv_sec
#define st_mtime st_mtim.tv_sec
#ifdef __cplusplus
extern "C" {
#endif
int chmod(const char* path, mode_t mode);
int fchmod(int fd, mode_t mode);
int fchmodat(int dirfd, const char* path, mode_t mode, int flags);