@@ -20,12 +20,16 @@
* This file contains codes for implementation of 'dev' filesystem.
*/
+#define __KERNEL__
+
#include <asm/fcntl.h>
#include <asm/mman.h>
#include <asm/prctl.h>
#include <asm/unistd.h>
#include <errno.h>
#include <linux/fcntl.h>
+#include <linux/stat.h>
#include <pal.h>
#include <pal_error.h>
#include <shim_fs.h>
@@ -34,10 +38,6 @@
#include <shim_profile.h>
#include <shim_utils.h>
-// TODO: For some reason S_IF* macros are missing if this file is included before our headers. We
-// should investigate and fix this behavior.
-#include <linux/stat.h>
-
#define EMPTY_DEV_OPS \
{ \
.open = NULL, \
* This file contains codes for implementation of 'pipe' filesystem.
#include <pal_debug.h>
@@ -35,10 +39,6 @@
#include <shim_thread.h>
-// TODO: For some reason S_I{R,W}USR macros are missing if this file is included before our headers.
-// We should investigate and fix this behavior.
static ssize_t pipe_read(struct shim_handle* hdl, void* buf, size_t count) {
PAL_NUM bytes = DkStreamRead(hdl->pal_handle, 0, count, buf, NULL, 0);
* This file contains codes for implementation of 'proc' filesystem.
extern const struct proc_nm_ops nm_thread;
extern const struct proc_fs_ops fs_thread;
extern const struct proc_dir dir_thread;
@@ -1,18 +1,18 @@
#include <shim_internal.h>
static int proc_info_mode(const char* name, mode_t* mode) {
// The path is implicitly set by calling this function
__UNUSED(name);
@@ -1,9 +1,13 @@
@@ -14,10 +18,6 @@
static int parse_ipc_thread_name(const char* name, IDTYPE* pidptr, const char** next,
size_t* next_len, const char** nextnext) {
const char* p = name;
@@ -13,10 +17,6 @@
static int parse_thread_name(const char* name, IDTYPE* pidptr, const char** next, size_t* next_len,
const char** nextnext) {
@@ -22,21 +22,18 @@
* directory cache.
+#include <asm/fcntl.h>
+#include <linux/fcntl.h>
#include <stdbool.h>
-#include <shim_internal.h>
-#include <shim_utils.h>
-#include <shim_thread.h>
-#include <shim_handle.h>
+#include <pal.h>
+#include <shim_handle.h>
+#include <shim_internal.h>
-#include <pal.h>
-#include <linux/fcntl.h>
-#include <asm/fcntl.h>
+#include <shim_thread.h>
+#include <shim_utils.h>
/* Advances a char pointer (string) past any repeated slashes and returns the result.
* Must be a null-terminated string. */
@@ -20,22 +20,22 @@
* This file contains codes for implementation of 'socket' filesystem.
static int socket_close(struct shim_handle* hdl) {
/* XXX: Shouldn't this do something? */
__UNUSED(hdl);
@@ -22,9 +22,12 @@
* "sendfile".
@@ -35,10 +38,6 @@
-/* FIXME(mkow): for some reason it must be included last, otherwise S_IFREG is not being
- * defined inside (sic!). */
/* The kernel would look up the parent directory, and remove the child from the inode. But we are
* working with the PAL, so we open the file, truncate and close it. */
int shim_do_unlink(const char* file) {