-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcopystat.c
42 lines (34 loc) · 843 Bytes
/
tcopystat.c
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
31
32
33
34
35
36
37
38
39
40
41
42
#include <sys/stat.h>
#include <stdlib.h>
#include <time.h>
struct config_stat {
struct config_stat *succ;
char *fn; /* name of config file */
time_t mtime; /* time of last mod */
dev_t dev; /* device file resides on */
ino_t ino; /* inode number for file */
} *config_stat_list = NULL;
void
add_config_stat(fn, statp)
char *fn; /* name of file */
struct stat *statp; /* stat of the file, or NULL */
{
struct config_stat *new = (struct config_stat *) malloc(sizeof(*new));
new->fn = strcpy(malloc(strlen(fn)), fn);
if (statp) {
new->mtime = statp->st_mtime;
new->dev = statp->st_dev;
new->ino = statp->st_ino;
} else {
new->mtime = 0;
}
new->succ = config_stat_list;
config_stat_list = new;
}
main()
{
struct stat st;
stat("/dev/null", &st);
add_config_stat("/dev/null", &st);
exit(0);
}