Changeset 23a0368 in mainline
- Timestamp:
- 2017-03-30T19:52:23Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ae7bfbbd
- Parents:
- b5b5d84
- Location:
- uspace
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cat/cat.c
rb5b5d84 r23a0368 31 31 #include <stdlib.h> 32 32 #include <unistd.h> 33 #include <sys/stat.h>34 33 #include <getopt.h> 35 34 #include <str.h> … … 214 213 struct stat st; 215 214 216 if ( fstat(fd, &st) != EOK) {215 if (vfs_stat(fd, &st) != EOK) { 217 216 close(fd); 218 217 free(buff); 219 printf("Unable to fstat %d\n", fd);218 printf("Unable to vfs_stat %d\n", fd); 220 219 return 1; 221 220 } -
uspace/app/bdsh/cmds/modules/cp/cp.c
rb5b5d84 r23a0368 37 37 #include <fcntl.h> 38 38 #include <sys/stat.h> 39 #include <vfs/vfs.h> 39 40 #include <dirent.h> 40 41 #include "config.h" … … 83 84 struct stat s; 84 85 85 int r = stat(path, &s);86 87 if (r != 0)86 int r = vfs_stat_path(path, &s); 87 88 if (r != EOK) 88 89 return TYPE_NONE; 89 90 else if (s.is_directory) … … 341 342 342 343 /* Check if we are copying a directory into itself */ 343 stat(src_dent, &src_s);344 stat(dest_path, &dest_s);344 vfs_stat_path(src_dent, &src_s); 345 vfs_stat_path(dest_path, &dest_s); 345 346 346 347 if (dest_s.index == src_s.index && … … 394 395 } 395 396 396 if ( fstat(fd1, &st) != EOK) {397 if (vfs_stat(fd1, &st) != EOK) { 397 398 printf("Unable to fstat %d\n", fd1); 398 399 close(fd1); -
uspace/app/bdsh/cmds/modules/ls/ls.c
rb5b5d84 r23a0368 39 39 #include <getopt.h> 40 40 #include <sys/types.h> 41 #include < sys/stat.h>41 #include <vfs/vfs.h> 42 42 #include <str.h> 43 43 #include <sort.h> … … 185 185 buff[len] = '\0'; 186 186 187 rc = stat(buff, &tosort[nbdirs++].s);188 if (rc != 0) {187 rc = vfs_stat_path(buff, &tosort[nbdirs++].s); 188 if (rc != EOK) { 189 189 printf("ls: skipping bogus node %s\n", buff); 190 printf("error=%d\n", errno);190 printf("error=%d\n", rc); 191 191 goto out; 192 192 } … … 315 315 static unsigned int ls_scope(const char *path, struct dir_elem_t *de) 316 316 { 317 if ( stat(path, &de->s) != 0) {317 if (vfs_stat_path(path, &de->s) != EOK) { 318 318 cli_error(CL_ENOENT, "%s", path); 319 319 return LS_BOGUS; -
uspace/app/bdsh/cmds/modules/ls/ls.h
rb5b5d84 r23a0368 1 1 #ifndef LS_H 2 2 #define LS_H 3 4 #include <vfs/vfs.h> 3 5 4 6 /* Various values that can be returned by ls_scope() */ -
uspace/app/bdsh/cmds/modules/touch/touch.c
rb5b5d84 r23a0368 40 40 #include <str.h> 41 41 #include <getopt.h> 42 #include <sys/stat.h>43 42 #include <errno.h> 43 #include <vfs/vfs.h> 44 44 45 45 #include "config.h" … … 123 123 124 124 /* Check whether file exists if -c (--no-create) option is given */ 125 if ((!no_create) || ((no_create) && (stat(buff, &file_stat) == 0))) 125 if ((!no_create) || 126 ((no_create) && (vfs_stat_path(buff, &file_stat) == EOK))) { 126 127 fd = open(buff, O_RDWR | O_CREAT); 128 } 127 129 128 130 if (fd < 0) { -
uspace/app/bdsh/compl.c
rb5b5d84 r23a0368 33 33 #include <macros.h> 34 34 #include <stdlib.h> 35 #include < sys/stat.h>35 #include <vfs/vfs.h> 36 36 37 37 #include "cmds/cmds.h" … … 360 360 asprintf(&ent_path, "%s/%s", *cs->path, dent->d_name); 361 361 struct stat ent_stat; 362 if ( stat(ent_path, &ent_stat) != 0) {362 if (vfs_stat_path(ent_path, &ent_stat) != EOK) { 363 363 /* Error */ 364 364 free(ent_path); -
uspace/app/init/init.c
rb5b5d84 r23a0368 42 42 #include <errno.h> 43 43 #include <fcntl.h> 44 #include <sys/stat.h>45 44 #include <task.h> 46 45 #include <malloc.h> … … 156 155 { 157 156 struct stat s; 158 if ( stat(path, &s) != 0) {157 if (vfs_stat_path(path, &s) != EOK) { 159 158 printf("%s: Unable to stat %s\n", NAME, path); 160 159 return ENOENT; -
uspace/app/sysinst/futil.c
rb5b5d84 r23a0368 40 40 #include <stdlib.h> 41 41 #include <sys/stat.h> 42 #include <vfs/vfs.h> 42 43 #include <sys/types.h> 43 44 #include <dirent.h> … … 119 120 return ENOMEM; 120 121 121 rc = stat(srcp, &s);122 rc = vfs_stat_path(srcp, &s); 122 123 if (rc != EOK) 123 124 return EIO; … … 166 167 return ENOENT; 167 168 168 if ( fstat(sf, &st) != EOK) {169 if (vfs_stat(sf, &st) != EOK) { 169 170 close(sf); 170 171 return EIO; -
uspace/app/viewer/viewer.c
rb5b5d84 r23a0368 36 36 #include <unistd.h> 37 37 #include <fcntl.h> 38 #include < sys/stat.h>38 #include <vfs/vfs.h> 39 39 #include <errno.h> 40 40 #include <malloc.h> … … 115 115 116 116 struct stat stat; 117 int rc = fstat(fd, &stat);118 if (rc != 0) {117 int rc = vfs_stat(fd, &stat); 118 if (rc != EOK) { 119 119 close(fd); 120 120 return false; -
uspace/drv/bus/isa/isa.c
rb5b5d84 r23a0368 54 54 #include <ipc/irc.h> 55 55 #include <ipc/services.h> 56 #include < sys/stat.h>56 #include <vfs/vfs.h> 57 57 #include <irc.h> 58 58 #include <ns.h> … … 264 264 opened = true; 265 265 266 if ( fstat(fd, &st) != EOK) {267 ddf_msg(LVL_ERROR, "Unable to fstat %d", fd);266 if (vfs_stat(fd, &st) != EOK) { 267 ddf_msg(LVL_ERROR, "Unable to vfs_stat %d", fd); 268 268 goto cleanup; 269 269 } -
uspace/lib/bithenge/src/file.c
rb5b5d84 r23a0368 41 41 #include <stdio.h> 42 42 #include <stdlib.h> 43 #include < sys/stat.h>43 #include <vfs/vfs.h> 44 44 #include <sys/types.h> 45 45 #include <unistd.h> … … 104 104 105 105 struct stat stat; 106 int rc = fstat(fd, &stat);107 if (rc != 0) {106 int rc = vfs_stat(fd, &stat); 107 if (rc != EOK) { 108 108 if (needs_close) 109 109 close(fd); -
uspace/lib/c/generic/io/io.c
rb5b5d84 r23a0368 41 41 #include <stdbool.h> 42 42 #include <malloc.h> 43 #include <sys/stat.h>44 43 #include <async.h> 45 44 #include <io/kio.h> … … 765 764 int fseek(FILE *stream, off64_t offset, int whence) 766 765 { 766 int rc; 767 767 768 if (stream->error) 768 769 return -1; … … 785 786 break; 786 787 case SEEK_END: 787 if (fstat(stream->fd, &st) != EOK) { 788 /* errno was set by fstat() */ 788 rc = vfs_stat(stream->fd, &st); 789 if (rc != EOK) { 790 errno = rc; 789 791 stream->error = true; 790 792 return -1; -
uspace/lib/c/generic/vfs/vfs.c
rb5b5d84 r23a0368 641 641 /** Get file status. 642 642 * 643 * @param fil desFile descriptor643 * @param file File descriptor 644 644 * @param stat Place to store file information 645 645 * 646 * @return 0 on success, -1 on error and sets errno.647 */ 648 int fstat(int fildes, struct stat *stat)646 * @return EOK on success or a negative error code otherwise. 647 */ 648 int vfs_stat(int file, struct stat *stat) 649 649 { 650 650 sysarg_t rc; … … 653 653 async_exch_t *exch = vfs_exchange_begin(); 654 654 655 req = async_send_1(exch, VFS_IN_STAT, fil des, NULL);655 req = async_send_1(exch, VFS_IN_STAT, file, NULL); 656 656 rc = async_data_read_start(exch, (void *) stat, sizeof(struct stat)); 657 657 if (rc != EOK) { … … 663 663 if (rc_orig != EOK) 664 664 rc = rc_orig; 665 if (rc != EOK) {666 errno = rc;667 return -1;668 }669 665 670 return 0;666 return rc; 671 667 } 672 668 … … 674 670 async_wait_for(req, &rc); 675 671 676 if (rc != EOK) { 677 errno = rc; 678 return -1; 679 } 680 681 return 0; 672 return rc; 682 673 } 683 674 … … 687 678 * @param stat Place to store file information 688 679 * 689 * @return 0 on success, -1 on error and sets errno. 690 */ 691 int stat(const char *path, struct stat *stat) 692 { 693 int fd = vfs_lookup(path, 0); 694 if (fd < 0) { 695 errno = fd; 696 return -1; 697 } 698 699 int rc = fstat(fd, stat); 700 if (rc != EOK) { 701 close(fd); 702 errno = rc; 703 rc = -1; 704 } else 705 rc = close(fd); 680 * @return EOK on success or a negative error code otherwise. 681 */ 682 int vfs_stat_path(const char *path, struct stat *stat) 683 { 684 int file = vfs_lookup(path, 0); 685 if (file < 0) 686 return file; 687 688 int rc = vfs_stat(file, stat); 689 690 close(file); 706 691 707 692 return rc; … … 1057 1042 * @return On success returns session pointer. On error returns @c NULL. 1058 1043 */ 1059 async_sess_t *vfs_fd_session(int fil des, iface_t iface)1044 async_sess_t *vfs_fd_session(int file, iface_t iface) 1060 1045 { 1061 1046 struct stat stat; 1062 int rc = fstat(fildes, &stat);1047 int rc = vfs_stat(file, &stat); 1063 1048 if (rc != 0) 1064 1049 return NULL; … … 1122 1107 child = pa; 1123 1108 1124 rc = stat(child, &st);1109 rc = vfs_stat_path(child, &st); 1125 1110 if (rc != 0) { 1126 1111 free(child); … … 1152 1137 struct stat st; 1153 1138 1154 int rc = stat("/", &st);1139 int rc = vfs_stat_path("/", &st); 1155 1140 if (rc != 0) 1156 1141 return rc; … … 1165 1150 * @param file File located on the queried file system 1166 1151 * @param st Buffer for storing information 1167 * @return 0 on success. On error -1 is returned and errno is set.1152 * @return EOK on success or a negative error code otherwise. 1168 1153 */ 1169 1154 int vfs_statfs(int file, struct statfs *st) -
uspace/lib/c/include/sys/stat.h
rb5b5d84 r23a0368 36 36 #define LIBC_SYS_STAT_H_ 37 37 38 #include <sys/types.h>39 #include <stdbool.h>40 38 #include <ipc/vfs.h> 41 #include <ipc/loc.h>42 39 43 struct stat {44 fs_handle_t fs_handle;45 service_id_t service_id;46 fs_index_t index;47 unsigned int lnkcnt;48 bool is_file;49 bool is_directory;50 aoff64_t size;51 service_id_t service;52 };53 54 extern int fstat(int, struct stat *);55 extern int stat(const char *, struct stat *);56 40 extern int mkdir(const char *, mode_t); 57 41 -
uspace/lib/c/include/vfs/vfs.h
rb5b5d84 r23a0368 49 49 }; 50 50 51 struct stat { 52 fs_handle_t fs_handle; 53 service_id_t service_id; 54 fs_index_t index; 55 unsigned int lnkcnt; 56 bool is_file; 57 bool is_directory; 58 aoff64_t size; 59 service_id_t service; 60 }; 61 51 62 struct statfs { 52 63 char fs_name[FS_NAME_MAXLEN + 1]; … … 79 90 extern int vfs_root(void); 80 91 extern void vfs_root_set(int); 92 extern int vfs_stat(int, struct stat *); 93 extern int vfs_stat_path(const char *, struct stat *); 81 94 extern int vfs_statfs(int, struct statfs *); 82 95 extern int vfs_statfs_path(const char *, struct statfs *); -
uspace/lib/posix/source/internal/common.h
rb5b5d84 r23a0368 59 59 }) 60 60 61 /* Convert error code to positive errno and -1 return value */ 62 #define rcerrno(func, ...) ({ \ 63 int rc = func(__VA_ARGS__); \ 64 if (rc < 0) \ 65 errno = -rc; \ 66 rc; \ 67 }) 68 61 69 extern aoff64_t posix_pos[MAX_OPEN_FILES]; 62 70 -
uspace/lib/posix/source/sys/stat.c
rb5b5d84 r23a0368 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" … … 80 80 { 81 81 struct stat hst; 82 int rc = negerrno(fstat, fd, &hst);82 int rc = rcerrno(vfs_stat, fd, &hst); 83 83 if (rc < 0) 84 return rc;84 return -1; 85 85 stat_to_posix(st, &hst); 86 86 return 0; … … 110 110 { 111 111 struct stat hst; 112 int rc = negerrno(stat, path, &hst);112 int rc = rcerrno(vfs_stat_path, path, &hst); 113 113 if (rc < 0) 114 return rc;114 return -1; 115 115 stat_to_posix(st, &hst); 116 116 return 0; -
uspace/lib/posix/source/unistd.c
rb5b5d84 r23a0368 48 48 #include "libc/malloc.h" 49 49 #include "libc/vfs/vfs.h" 50 #include "libc/sys/stat.h"51 50 52 51 aoff64_t posix_pos[MAX_OPEN_FILES]; … … 221 220 { 222 221 struct stat st; 222 int rc; 223 223 224 224 switch (whence) { … … 230 230 break; 231 231 case SEEK_END: 232 if (fstat(fildes, &st) != EOK) {233 errno = -errno;232 rc = rcerrno(vfs_stat, fildes, &st); 233 if (rc != EOK) 234 234 return -1; 235 }236 235 posix_pos[fildes] = st.size + offset; 237 236 break; -
uspace/srv/devman/driver.c
rb5b5d84 r23a0368 34 34 #include <errno.h> 35 35 #include <fcntl.h> 36 #include <sys/stat.h>37 36 #include <io/log.h> 37 #include <vfs/vfs.h> 38 38 #include <loc.h> 39 39 #include <str_error.h> … … 142 142 /* Check whether the driver's binary exists. */ 143 143 struct stat s; 144 if ( stat(drv->binary_path, &s) != 0) {144 if (vfs_stat_path(drv->binary_path, &s) != EOK) { 145 145 log_msg(LOG_DEFAULT, LVL_ERROR, "Driver not found at path `%s'.", 146 146 drv->binary_path); -
uspace/srv/devman/match.c
rb5b5d84 r23a0368 37 37 #include <str_error.h> 38 38 #include <sys/types.h> 39 #include < sys/stat.h>39 #include <vfs/vfs.h> 40 40 41 41 #include "devman.h" … … 211 211 opened = true; 212 212 213 if ( fstat(fd, &st) != EOK) {213 if (vfs_stat(fd, &st) != EOK) { 214 214 log_msg(LOG_DEFAULT, LVL_ERROR, "Unable to fstat %d: %s.", fd, 215 215 str_error(errno));
Note:
See TracChangeset
for help on using the changeset viewer.