lfn
serial
ticket/834-toolchain-update
topic/msim-upgrade
topic/simplify-dev-export
Last change
on this file since 30d396b was f5c8046, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 14 years ago |
add basics of libcompat
|
-
Property mode
set to
100644
|
File size:
897 bytes
|
Line | |
---|
1 |
|
---|
2 | #include "stat.h"
|
---|
3 | #include <mem.h>
|
---|
4 |
|
---|
5 | #undef stat
|
---|
6 | #undef fstat
|
---|
7 |
|
---|
8 | static void stat_to_posix (struct posix_stat *dest, struct stat *src) {
|
---|
9 |
|
---|
10 | memset(dest, 0, sizeof(struct posix_stat));
|
---|
11 |
|
---|
12 | dest->st_dev = src->device;
|
---|
13 |
|
---|
14 | /* HelenOS doesn't support permissions, so we set them all */
|
---|
15 | dest->st_mode = S_IRWXU | S_IRWXG | S_IRWXO;
|
---|
16 | if (src->is_file)
|
---|
17 | dest->st_mode |= S_IFREG;
|
---|
18 | if (src->is_directory)
|
---|
19 | dest->st_mode |= S_IFDIR;
|
---|
20 |
|
---|
21 | dest->st_nlink = src->lnkcnt;
|
---|
22 | dest->st_size = src->size;
|
---|
23 | }
|
---|
24 |
|
---|
25 | int posix_fstat(int fd, struct posix_stat *st) {
|
---|
26 | struct stat hst;
|
---|
27 | if (fstat(fd, &hst) == -1) {
|
---|
28 | // FIXME: propagate a POSIX compatible errno
|
---|
29 | return -1;
|
---|
30 | }
|
---|
31 | stat_to_posix(st, &hst);
|
---|
32 | return 0;
|
---|
33 | }
|
---|
34 |
|
---|
35 | int posix_stat(const char *path, struct posix_stat *st) {
|
---|
36 | struct stat hst;
|
---|
37 | if (stat(path, &hst) == -1) {
|
---|
38 | // FIXME: propagate a POSIX compatible errno
|
---|
39 | return -1;
|
---|
40 | }
|
---|
41 | stat_to_posix(st, &hst);
|
---|
42 | return 0;
|
---|
43 | }
|
---|
44 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.