CS350 COS
COS
Loading...
Searching...
No Matches
stat.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <syscall.h>
Include dependency graph for stat.c:

Go to the source code of this file.

Functions

int main (int argc, const char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
const char *  argv[] 
)

Definition at line 12 of file stat.c.

13{
14 int status;
15 struct stat sb;
16
17 if (argc < 2) {
18 fputs("Requires an argument\n", stdout);
19 return 1;
20 }
21
22 if (argc > 2) {
23 fputs("Too many arguments, expected one\n", stdout);
24 return 1;
25 }
26
27 status = OSStat(argv[1], &sb);
28 if (status != 0) {
29 fputs("Cannot stat file\n", stdout);
30 return 0;
31 }
32
33 printf(" File: \"%s\"\n", argv[1]);
34 printf(" Size: %d\n", sb.st_size);
35 printf("Blocks: %d\n", sb.st_blocks);
36 printf(" Inode: %d\n", sb.st_ino);
37
38 return 0;
39}
int OSStat(const char *path, struct stat *sb)
Definition: syscall.c:89
Definition: stat.h:5
int printf(const char *fmt,...)
Definition: printf.c:212
int fputs(const char *str, FILE *fh)
Definition: file.c:132
FILE * stdout
Definition: file.c:16
Here is the call graph for this function: