diff options
Diffstat (limited to 'owner/owner.c')
-rw-r--r-- | owner/owner.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/owner/owner.c b/owner/owner.c new file mode 100644 index 0000000..2540421 --- /dev/null +++ b/owner/owner.c @@ -0,0 +1,30 @@ +/* + * owner.c - Implementation of the "print file owner UID" utility + * Project Horizon + * + * Copyright (c) 2019 Adélie Linux and contributors. All rights reserved. + * This code is licensed under the NCSA license. + * + * SPDX-License-Identifier: NCSA + */ + +#include <stdio.h> /* fprintf, perror */ +#include <stdlib.h> /* EXIT_* */ +#include <sys/stat.h> /* stat(3) and friends */ + +int main(int argc, char *argv[]) { + if(argc != 2) { + fprintf(stderr, "hscript-printowner: requires a path or file\n"); + return EXIT_FAILURE; + } + + struct stat buf; + if(stat(argv[1], &buf) != 0) { + perror("hscript-printowner: stat"); + return EXIT_FAILURE; + } + + fprintf(stdout, "%d\n", buf.st_uid); + + return EXIT_SUCCESS; +} |