Squash commits for public release
This commit is contained in:
5
userland/utilities/touch/.info.mk
Normal file
5
userland/utilities/touch/.info.mk
Normal file
@@ -0,0 +1,5 @@
|
||||
APPS += TOUCH
|
||||
|
||||
TOUCH_NAME = touch
|
||||
TOUCH_LIBS = c
|
||||
TOUCH_INSTALL_PATH = bin/
|
||||
8
userland/utilities/touch/BUILD.gn
Normal file
8
userland/utilities/touch/BUILD.gn
Normal file
@@ -0,0 +1,8 @@
|
||||
import("//build/userland/TEMPLATE.gni")
|
||||
|
||||
xOS_executable("touch") {
|
||||
install_path = "bin/"
|
||||
sources = [ "main.c" ]
|
||||
configs = [ "//build/userland:userland_flags" ]
|
||||
deplibs = [ "libc" ]
|
||||
}
|
||||
25
userland/utilities/touch/main.c
Normal file
25
userland/utilities/touch/main.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (argc < 2) {
|
||||
write(1, "Usage: touch files...\n", 22);
|
||||
return 0;
|
||||
}
|
||||
|
||||
mode_t std_mode = S_IFREG | S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if ((fd = creat(argv[i], std_mode)) < 0) {
|
||||
write(1, "touch: failed to create\n", 24);
|
||||
break;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user