GMS Linux: start?

This commit is contained in:
2025-12-30 01:20:20 +00:00
commit ac241a9148
48 changed files with 2028 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
TARGET = touch
SRCS = touch.c
CC = gcc
CFLAGS = -static -Wall
OUT_BIN ?= $(TARGET)
all: $(OUT_BIN)
$(OUT_BIN): $(SRCS)
@echo " [CC] Compiling to $(OUT_BIN)..."
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f $(TARGET)
+24
View File
@@ -0,0 +1,24 @@
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
int main(int argc, char *argv[]) {
if (argc != 2) {
printf("Usage: touch <filename>\n");
return 1;
}
// O_CREAT: 없으면 생성
// O_TRUNC: 있으면 내용을 비움 (0바이트로 만듦)
// 0644: 파일 권한 (rw-r--r--)
int fd = open(argv[1], O_CREAT | O_TRUNC | O_WRONLY, 0644);
if (fd < 0) {
perror("touch");
return 1;
}
close(fd);
return 0;
}