blob: 2540421a1fabb75cd05984d9d5862b759301ef94 (
plain) (
blame)
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
28
29
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;
}
|