• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <sys/stat.h>
2 
3 /* It's easy to change kernel to support stat */
4 
5 struct stat_portable {
6     unsigned long long  st_dev;
7     unsigned char       __pad0[4];
8 
9     unsigned long       __st_ino;
10     unsigned int        st_mode;
11     unsigned int        st_nlink;
12 
13     unsigned long       st_uid;
14     unsigned long       st_gid;
15 
16     unsigned long long  st_rdev;
17     unsigned char       __pad3[4];
18 
19     long long           st_size;
20     unsigned long       st_blksize;
21     unsigned long long  st_blocks;
22 
23     unsigned long       st_atime;
24     unsigned long       st_atime_nsec;
25 
26     unsigned long       st_mtime;
27     unsigned long       st_mtime_nsec;
28 
29     unsigned long       st_ctime;
30     unsigned long       st_ctime_nsec;
31 
32     unsigned long long  st_ino;
33 };
34 
35 /*
36 The MIPS Version is
37 struct stat {
38     unsigned long       st_dev;
39     unsigned long       __pad0[3];
40 
41     unsigned long long  st_ino;
42 
43     unsigned int        st_mode;
44     unsigned int        st_nlink;
45 
46     unsigned long       st_uid;
47     unsigned long       st_gid;
48 
49     unsigned long       st_rdev;
50     unsigned long       __pad1[3];
51 
52     long long           st_size;
53 
54     unsigned long       st_atime;
55     unsigned long       st_atime_nsec;
56 
57     unsigned long       st_mtime;
58     unsigned long       st_mtime_nsec;
59 
60     unsigned long       st_ctime;
61     unsigned long       st_ctime_nsec;
62 
63     unsigned long       st_blksize;
64     unsigned long       __pad2;
65 
66     unsigned long long  st_blocks;
67 };
68 */
69 
70 /* Real Stat Syscall */
71 extern int stat(const char *, struct stat *);
72 
73 /* Note: The Portable Header will define stat to stat_portable */
stat_portable(const char * path,struct stat_portable * s)74 int stat_portable(const char *path, struct stat_portable *s)
75 {
76    struct stat mips_stat;
77    int ret = stat(path,&mips_stat);
78    s->st_dev = mips_stat.st_dev;
79    s->__st_ino = mips_stat.st_ino;
80    s->st_mode = mips_stat.st_mode;
81    s->st_nlink = mips_stat.st_nlink;
82    s->st_uid = mips_stat.st_uid;
83    s->st_gid = mips_stat.st_gid;
84    s->st_rdev = mips_stat.st_rdev;
85    s->st_size = mips_stat.st_size;
86    s->st_blksize = mips_stat.st_blksize;
87    s->st_blocks = mips_stat.st_blocks;
88    s->st_atime = mips_stat.st_atime;
89    s->st_atime_nsec = mips_stat.st_atime_nsec;
90    s->st_mtime = mips_stat.st_mtime;
91    s->st_mtime_nsec = mips_stat.st_mtime_nsec;
92    s->st_ctime = mips_stat.st_ctime;
93    s->st_ctime_nsec = mips_stat.st_ctime_nsec;
94    s->st_ino =  mips_stat.st_ino;
95    return ret;
96 }
97