From b97c59ff2177dd31919f9e592932ca21fc796bd1 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 12 Jul 2019 11:56:58 +0200 Subject: [PATCH] mescc: Mes C Library: Support GNU Tar: Add creat, mknod. * include/linux/x86_64/syscall.h (SYS_mknod): New macro. * include/linux/x86/syscall.h (SYS_mknod): New macro. * lib/linux/mknod.c: New file. * build-aux/configure-lib.sh (libc_gnu_SOURCES): Add it. * include/sys/stat.h (mknod): Declare it. * include/fcntl.h (creat): New macro. --- build-aux/configure-lib.sh | 1 + include/fcntl.h | 1 + include/linux/x86/syscall.h | 1 + include/linux/x86_64/syscall.h | 1 + include/sys/stat.h | 1 + lib/linux/mknod.c | 29 +++++++++++++++++++++++++++++ 6 files changed, 34 insertions(+) create mode 100644 lib/linux/mknod.c diff --git a/build-aux/configure-lib.sh b/build-aux/configure-lib.sh index 0831f210..ea9edee0 100644 --- a/build-aux/configure-lib.sh +++ b/build-aux/configure-lib.sh @@ -312,6 +312,7 @@ lib/linux/kill.c lib/linux/link.c lib/linux/lstat.c lib/linux/mkdir.c +lib/linux/mknod.c lib/linux/nanosleep.c lib/linux/pipe.c lib/linux/readlink.c diff --git a/include/fcntl.h b/include/fcntl.h index 148d5ea6..f29d56ac 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -48,6 +48,7 @@ #define F_GETFL 3 #define F_SETFL 4 +#define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode) int dup (int old); int dup2 (int old, int new); int fcntl (int filedes, int command, ...); diff --git a/include/linux/x86/syscall.h b/include/linux/x86/syscall.h index 620a8b7d..e8de351a 100644 --- a/include/linux/x86/syscall.h +++ b/include/linux/x86/syscall.h @@ -86,5 +86,6 @@ // tar #define SYS_symlink 0x53 #define SYS_readlink 0x55 +#define SYS_mknod 0x0e #endif // __MES_LINUX_X86_SYSCALL_H diff --git a/include/linux/x86_64/syscall.h b/include/linux/x86_64/syscall.h index 10c3f31b..36ef06bc 100644 --- a/include/linux/x86_64/syscall.h +++ b/include/linux/x86_64/syscall.h @@ -83,5 +83,6 @@ // tar #define SYS_symlink 0x58 #define SYS_readlink 0x59 +#define SYS_mknod 0x85 #endif // __MES_LINUX_X86_64_SYSCALL_H diff --git a/include/sys/stat.h b/include/sys/stat.h index 6db24496..891f31c8 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -85,6 +85,7 @@ struct stat int chmod (char const *file_name, mode_t mode); int fstat (int filedes, struct stat *buf); int mkdir (char const *file_name, mode_t mode); +int mknod (char const *file_name, mode_t mode, dev_t dev); int chown (char const *file_name, uid_t owner, gid_t group); int rmdir (char const *file_name); int stat (char const *file_name, struct stat *buf); diff --git a/lib/linux/mknod.c b/lib/linux/mknod.c new file mode 100644 index 00000000..8339f7a6 --- /dev/null +++ b/lib/linux/mknod.c @@ -0,0 +1,29 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * GNU Mes 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +#include +#include + +int +mknod (char const *file_name, mode_t mode, dev_t dev) +{ + return _sys_call3 (SYS_mknod, (long) file_name, (long) mode, (long) dev); +}