Rev 5141 | Rev 9952 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5141 | Rev 5215 | ||
---|---|---|---|
Line 11... | Line 11... | ||
11 | * and need not follow the licensing terms described here, provided that |
11 | * and need not follow the licensing terms described here, provided that |
12 | * the new terms are clearly indicated on the first page of each file where |
12 | * the new terms are clearly indicated on the first page of each file where |
13 | * they apply. |
13 | * they apply. |
14 | */ |
14 | */ |
15 | #include |
15 | #include |
- | 16 | #include |
|
16 | #include |
17 | #include |
- | 18 | #include |
|
- | 19 | #include |
|
17 | #include "glue.h" |
20 | #include "glue.h" |
Line 18... | Line 21... | ||
18 | 21 | ||
19 | /* |
22 | /* |
20 | * stat -- Since we have no file system, we just return an error. |
23 | * stat -- Since we have no file system, we just return an error. |
21 | */ |
24 | */ |
22 | int |
25 | int |
23 | _DEFUN (stat, (path, buf), |
26 | _DEFUN (stat, (path, buf), |
24 | const char *path _AND |
27 | const char *path _AND |
25 | struct stat *buf) |
28 | struct stat *buf) |
- | 29 | { |
|
- | 30 | ||
- | 31 | fileinfo_t info; |
|
- | 32 | struct tm time; |
|
- | 33 | ||
- | 34 | if( get_fileinfo(path, &info)) |
|
26 | { |
35 | { |
27 | errno = EIO; |
36 | errno = ENOENT; |
- | 37 | return (-1); |
|
- | 38 | }; |
|
- | 39 | ||
- | 40 | memset (buf, 0, sizeof (* buf)); |
|
- | 41 | ||
- | 42 | buf->st_size = info.size; |
|
- | 43 | ||
- | 44 | if (info.attr & 0x10) |
|
- | 45 | buf->st_mode = S_IFDIR; |
|
- | 46 | else |
|
- | 47 | { |
|
- | 48 | if (info.attr & 0x07) |
|
- | 49 | buf->st_mode = S_IFREG|S_IRUSR|S_IXUSR; |
|
- | 50 | else |
|
- | 51 | buf->st_mode = S_IFREG|S_IRUSR|S_IWUSR|S_IXUSR; |
|
- | 52 | } |
|
- | 53 | ||
- | 54 | buf->st_blksize = 4096; |
|
- | 55 | ||
- | 56 | time.tm_sec = info.atime.sec; |
|
- | 57 | time.tm_min = info.atime.min; |
|
- | 58 | time.tm_hour = info.atime.hour; |
|
- | 59 | time.tm_mday = info.adate.day; |
|
- | 60 | time.tm_mon = info.adate.month; |
|
- | 61 | time.tm_year = info.adate.year - 1900; |
|
- | 62 | time.tm_isdst = -1; |
|
- | 63 | buf->st_atime = mktime(&time); |
|
- | 64 | ||
- | 65 | time.tm_sec = info.ctime.sec; |
|
- | 66 | time.tm_min = info.ctime.min; |
|
- | 67 | time.tm_hour = info.ctime.hour; |
|
- | 68 | time.tm_mday = info.cdate.day; |
|
- | 69 | time.tm_mon = info.cdate.month; |
|
- | 70 | time.tm_year = info.cdate.year - 1900; |
|
- | 71 | time.tm_isdst = -1; |
|
- | 72 | buf->st_ctime = mktime(&time); |
|
- | 73 | ||
- | 74 | time.tm_sec = info.mtime.sec; |
|
- | 75 | time.tm_min = info.mtime.min; |
|
- | 76 | time.tm_hour = info.mtime.hour; |
|
- | 77 | time.tm_mday = info.mdate.day; |
|
- | 78 | time.tm_mon = info.mdate.month; |
|
- | 79 | time.tm_year = info.mdate.year - 1900; |
|
- | 80 | time.tm_isdst = -1; |
|
- | 81 | buf->st_mtime = mktime(&time); |
|
- | 82 | ||
- | 83 | return (0); |
|
- | 84 | } |
|
- | 85 | ||
- | 86 | ||
- | 87 | int |
|
- | 88 | _DEFUN (lstat, (path, buf), |
|
- | 89 | const char *path _AND |
|
- | 90 | struct stat *buf) |
|
- | 91 | { |
|
28 | return (-1); |
92 | return stat(path, buf); |