summaryrefslogtreecommitdiff
path: root/src/user/touch.cc
blob: b978f52cf4181481a4b006d6cde738741249209b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "ulib/stdio.h"
#include "ulib/stdlib.h"
#include "user/user.h"
#include "common/fcntl.h"

int main(int argc, char *argv[])
{
    int i, fd;

    if (argc < 2)
    {
        printf("Usage: touch files...\n");
        exit(1);
    }

    for (i = 1; i < argc; i++)
    {
        fd = open(argv[i], O_CREATE | O_RDWR);
        if (fd < 0)
        {
            printf("touch: cannot touch %s\n", argv[i]);
            exit(1);
        }
        close(fd);
    }
    exit(0);
}