Changes in uspace/lib/posix/sys/stat.c [eca52a8:9b1503e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/sys/stat.c
reca52a8 r9b1503e 36 36 #define LIBPOSIX_INTERNAL 37 37 38 #include "stat.h" 38 39 #include "../internal/common.h" 39 #include "stat.h" 40 41 #include "../errno.h" 42 #include "../libc/mem.h" 40 #include <mem.h> 43 41 44 42 /** 45 * Convert HelenOS stat struct into POSIX stat struct (if possible) .43 * Convert HelenOS stat struct into POSIX stat struct (if possible) 46 44 * 47 * @param dest POSIX stat struct.48 * @param src HelenOS stat struct.45 * @param dest 46 * @param src 49 47 */ 50 48 static void stat_to_posix(struct posix_stat *dest, struct stat *src) … … 53 51 54 52 dest->st_dev = src->device; 55 dest->st_ino = src->index;56 53 57 54 /* HelenOS doesn't support permissions, so we set them all */ … … 69 66 70 67 /** 71 * Retrieve file status for file associated with file descriptor.72 68 * 73 * @param fd File descriptor of the opened file.74 * @param st Status structure to be filled with information.75 * @return Zero on success, -1 otherwise.69 * @param fd 70 * @param st 71 * @return 76 72 */ 77 73 int posix_fstat(int fd, struct posix_stat *st) 78 74 { 79 75 struct stat hst; 80 int rc = fstat(fd, &hst); 81 if (rc < 0) { 82 /* fstat() returns negative error code instead of using errno. 83 */ 84 errno = -rc; 76 if (fstat(fd, &hst) == -1) { 77 // TODO: propagate a POSIX compatible errno 85 78 return -1; 86 79 } … … 90 83 91 84 /** 92 * Retrieve file status for symbolic link.93 85 * 94 * @param path Path to the symbolic link.95 * @param st Status structure to be filled with information.96 * @return Zero on success, -1 otherwise.86 * @param path 87 * @param st 88 * @return 97 89 */ 98 int posix_lstat(const char * path, struct posix_stat *st)90 int posix_lstat(const char *restrict path, struct posix_stat *restrict st) 99 91 { 100 / * There are currently no symbolic links in HelenOS. */101 return posix_stat(path, st);92 // TODO 93 not_implemented(); 102 94 } 103 95 104 96 /** 105 * Retrieve file status for regular file (or symbolic link target).106 97 * 107 * @param path Path to the file/link.108 * @param st Status structure to be filled with information.109 * @return Zero on success, -1 otherwise.98 * @param path 99 * @param st 100 * @return 110 101 */ 111 102 int posix_stat(const char *path, struct posix_stat *st) 112 103 { 113 104 struct stat hst; 114 int rc = stat(path, &hst); 115 if (rc < 0) { 116 /* stat() returns negative error code instead of using errno. 117 */ 118 errno = -rc; 105 if (stat(path, &hst) == -1) { 106 // TODO: propagate a POSIX compatible errno 119 107 return -1; 120 108 } … … 124 112 125 113 /** 126 * Change permission bits for the file if possible.127 114 * 128 * @param path Path to the file.129 * @param mode Permission bits to be set.130 * @return Zero on success, -1 otherwise.115 * @param path 116 * @param mode 117 * @return 131 118 */ 132 119 int posix_chmod(const char *path, mode_t mode) 133 120 { 134 / * HelenOS doesn't support permissions, return success. */135 return 0;121 // TODO 122 not_implemented(); 136 123 } 137 124 138 125 /** 139 * Set the file mode creation mask of the process.140 126 * 141 * @param mask Set permission bits are cleared in the related creation 142 * functions. Non-permission bits are ignored. 143 * @return Previous file mode creation mask. 127 * @param mask 128 * @return 144 129 */ 145 130 mode_t posix_umask(mode_t mask) 146 131 { 147 / * HelenOS doesn't support permissions, return empty mask. */148 return 0;132 // TODO 133 not_implemented(); 149 134 } 150 135
Note:
See TracChangeset
for help on using the changeset viewer.