Changeset 368ee04 in mainline for uspace/lib/posix/source/sys/stat.c
- Timestamp:
- 2017-04-05T18:10:39Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 93ad8166
- Parents:
- 39f892a9 (diff), 2166728 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/source/sys/stat.c
r39f892a9 r368ee04 39 39 #include "../internal/common.h" 40 40 #include "posix/sys/stat.h" 41 #include "libc/ sys/stat.h"41 #include "libc/vfs/vfs.h" 42 42 43 43 #include "posix/errno.h" … … 49 49 * @param dest POSIX stat struct. 50 50 * @param src HelenOS stat struct. 51 * 52 * @return 0 on success, -1 on error. 51 53 */ 52 static voidstat_to_posix(struct posix_stat *dest, struct stat *src)54 static int stat_to_posix(struct posix_stat *dest, struct stat *src) 53 55 { 54 56 memset(dest, 0, sizeof(struct posix_stat)); … … 68 70 dest->st_nlink = src->lnkcnt; 69 71 dest->st_size = src->size; 72 73 if (src->size > INT64_MAX) { 74 errno = ERANGE; 75 return -1; 76 } 77 78 return 0; 70 79 } 71 80 … … 80 89 { 81 90 struct stat hst; 82 int rc = negerrno(fstat, fd, &hst);91 int rc = rcerrno(vfs_stat, fd, &hst); 83 92 if (rc < 0) 84 return rc; 85 stat_to_posix(st, &hst); 86 return 0; 93 return -1; 94 return stat_to_posix(st, &hst); 87 95 } 88 96 … … 110 118 { 111 119 struct stat hst; 112 int rc = negerrno(stat, path, &hst);120 int rc = rcerrno(vfs_stat_path, path, &hst); 113 121 if (rc < 0) 114 return rc; 115 stat_to_posix(st, &hst); 116 return 0; 122 return -1; 123 return stat_to_posix(st, &hst); 117 124 } 118 125 … … 124 131 * @return Zero on success, -1 otherwise. 125 132 */ 126 int posix_chmod(const char *path, mode_t mode)133 int posix_chmod(const char *path, posix_mode_t mode) 127 134 { 128 135 /* HelenOS doesn't support permissions, return success. */ … … 137 144 * @return Previous file mode creation mask. 138 145 */ 139 mode_t posix_umask(mode_t mask)146 posix_mode_t posix_umask(posix_mode_t mask) 140 147 { 141 148 /* HelenOS doesn't support permissions, return empty mask. */ … … 143 150 } 144 151 152 /** 153 * Create a directory. 154 * 155 * @param path Path to the new directory. 156 * @param mode Permission bits to be set. 157 * @return Zero on success, -1 otherwise. 158 */ 159 int posix_mkdir(const char *path, posix_mode_t mode) 160 { 161 int rc = rcerrno(vfs_link_path, path, KIND_DIRECTORY, NULL); 162 if (rc != EOK) 163 return -1; 164 else 165 return 0; 166 } 167 145 168 /** @} 146 169 */
Note:
See TracChangeset
for help on using the changeset viewer.