2 * <sys/stat.h> wrapper functions.
5 * Jonathan Pryor (jonpryor@vt.edu)
7 * Copyright (C) 2004 Jonathan Pryor
12 #endif /* ndef _GNU_SOURCE */
14 #include <sys/types.h>
25 struct Mono_Posix_Syscall_Stat
{
26 /* dev_t */ mph_dev_t st_dev
; /* device */
27 /* ino_t */ mph_ino_t st_ino
; /* inode */
28 /* mode_t */ guint32 st_mode
; /* protection */
29 guint32 _padding_
; /* structure padding */
30 /* nlink_t */ mph_nlink_t st_nlink
; /* number of hard links */
31 /* uid_t */ mph_uid_t st_uid
; /* user ID of owner */
32 /* gid_t */ mph_gid_t st_gid
; /* group ID of owner */
33 /* dev_t */ mph_dev_t st_rdev
; /* device type (if inode device) */
34 /* off_t */ mph_off_t st_size
; /* total size, in bytes */
35 /* blksize_t */ mph_blksize_t st_blksize
; /* blocksize for filesystem I/O */
36 /* blkcnt_t */ mph_blkcnt_t st_blocks
; /* number of blocks allocated */
38 /* st_atime, st_mtime, and st_ctime are macros (!), so use a slightly
39 * different name to appease CPP */
41 /* time_t */ mph_time_t st_atime_
; /* time of last access */
42 /* time_t */ mph_time_t st_mtime_
; /* time of last modification */
43 /* time_t */ mph_time_t st_ctime_
; /* time of last status change */
47 copy_stat (struct Mono_Posix_Syscall_Stat
*to
, struct stat
*from
)
49 if (Mono_Posix_ToFilePermissions (from
->st_mode
, &to
->st_mode
) == -1)
51 to
->st_dev
= from
->st_dev
;
52 to
->st_ino
= from
->st_ino
;
53 to
->st_nlink
= from
->st_nlink
;
54 to
->st_uid
= from
->st_uid
;
55 to
->st_gid
= from
->st_gid
;
56 to
->st_rdev
= from
->st_rdev
;
57 to
->st_size
= from
->st_size
;
58 to
->st_blksize
= from
->st_blksize
;
59 to
->st_blocks
= from
->st_blocks
;
60 to
->st_atime_
= from
->st_atime
;
61 to
->st_mtime_
= from
->st_mtime
;
62 to
->st_ctime_
= from
->st_ctime
;
67 Mono_Posix_Syscall_stat (const char *file_name
, struct Mono_Posix_Syscall_Stat
*buf
)
76 r
= stat (file_name
, &_buf
);
77 if (r
!= -1 && copy_stat (buf
, &_buf
) == -1)
83 Mono_Posix_Syscall_fstat (int filedes
, struct Mono_Posix_Syscall_Stat
*buf
)
92 r
= fstat (filedes
, &_buf
);
93 if (r
!= -1 && copy_stat (buf
, &_buf
) == -1)
99 Mono_Posix_Syscall_lstat (const char *file_name
, struct Mono_Posix_Syscall_Stat
*buf
)
108 r
= lstat (file_name
, &_buf
);
109 if (r
!= -1 && copy_stat (buf
, &_buf
) == -1)
115 Mono_Posix_Syscall_mknod (const char *pathname
, guint32 mode
, mph_dev_t dev
)
117 if (Mono_Posix_FromFilePermissions (mode
, &mode
) == -1)
119 return mknod (pathname
, mode
, dev
);