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