8 /* XXX until that st_Xtime macroses used, we have to undefine them,
9 * because of minix_prev_stat
15 static void prev_stat2new_stat(struct stat
*new, struct minix_prev_stat
*prev
)
17 /* Copy field by field because of st_gid type mismath and
18 * difference in order after atime.
20 new->st_dev
= prev
->st_dev
;
21 new->st_ino
= prev
->st_ino
;
22 new->st_mode
= prev
->st_mode
;
23 new->st_nlink
= prev
->st_nlink
;
24 new->st_uid
= prev
->st_uid
;
25 new->st_gid
= prev
->st_gid
;
26 new->st_rdev
= prev
->st_rdev
;
27 new->st_size
= prev
->st_size
;
28 new->st_atimespec
.tv_sec
= prev
->st_atime
;
29 new->st_mtimespec
.tv_sec
= prev
->st_mtime
;
30 new->st_ctimespec
.tv_sec
= prev
->st_ctime
;
33 __weak_alias(_stat
, __stat50
);
34 __weak_alias(_lstat
, __lstat50
);
35 __weak_alias(_fstat
, __fstat50
);
37 int stat(const char *name
, struct stat
*buffer
)
41 struct minix_prev_stat old_sb
;
43 m
.m1_i1
= strlen(name
) + 1;
44 m
.m1_p1
= (char *) __UNCONST(name
);
45 m
.m1_p2
= (char *) buffer
;
47 if((r
= _syscall(VFS_PROC_NR
, STAT
, &m
)) >= 0 || errno
!= ENOSYS
)
52 /* ENOSYS: new binary and old VFS, fallback to PREV_STAT.
53 * User has struct stat (buffer), VFS still fills minix_prev_stat.
55 m
.m1_i1
= strlen(name
) + 1;
56 m
.m1_p1
= (char *) __UNCONST(name
);
57 m
.m1_p2
= (char *) &old_sb
;
59 if((r
= _syscall(VFS_PROC_NR
, PREV_STAT
, &m
)) < 0)
62 memset(buffer
, 0, sizeof(struct stat
));
63 prev_stat2new_stat(buffer
, &old_sb
);
68 int _fstat(int fd
, struct stat
*buffer
) { return fstat(fd
, buffer
); }
70 int fstat(int fd
, struct stat
*buffer
)
74 struct minix_prev_stat old_sb
;
77 m
.m1_p1
= (char *) buffer
;
79 if((r
= _syscall(VFS_PROC_NR
, FSTAT
, &m
)) >= 0 || errno
!= ENOSYS
)
84 /* ENOSYS: new binary and old VFS, fallback to PREV_STAT.
85 * User has struct stat (buffer), VFS still fills minix_prev_stat.
88 m
.m1_p1
= (char *) &old_sb
;
90 if((r
= _syscall(VFS_PROC_NR
, PREV_FSTAT
, &m
)) < 0)
93 memset(buffer
, 0, sizeof(struct stat
));
94 prev_stat2new_stat(buffer
, &old_sb
);
99 int _lstat(const char *name
, struct stat
*buffer
) { return lstat(name
, buffer
); }
101 int lstat(const char *name
, struct stat
*buffer
)
105 struct minix_prev_stat old_sb
;
107 m
.m1_i1
= strlen(name
) + 1;
108 m
.m1_p1
= (char *) __UNCONST(name
);
109 m
.m1_p2
= (char *) buffer
;
111 if((r
= _syscall(VFS_PROC_NR
, LSTAT
, &m
)) >= 0 || errno
!= ENOSYS
)
116 /* ENOSYS: new binary and old VFS, fallback to PREV_STAT.
117 * User has struct stat (buffer), VFS still fills minix_prev_stat.
119 m
.m1_i1
= strlen(name
) + 1;
120 m
.m1_p1
= (char *) __UNCONST(name
);
121 m
.m1_p2
= (char *) &old_sb
;
123 if((r
= _syscall(VFS_PROC_NR
, PREV_LSTAT
, &m
)) < 0)
126 memset(buffer
, 0, sizeof(struct stat
));
127 prev_stat2new_stat(buffer
, &old_sb
);