Changeset 438f355 in mainline
- Timestamp:
- 2017-04-02T21:24:22Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ca7506f
- Parents:
- c23275a
- Location:
- uspace/lib/c
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
rc23275a r438f355 149 149 generic/udebug.c \ 150 150 generic/vfs/canonify.c \ 151 generic/vfs/inbox.c \ 152 generic/vfs/mtab.c \ 151 153 generic/vfs/vfs.c \ 152 154 generic/rcu.c \ 153 155 generic/setjmp.c \ 154 generic/vfs/inbox.c \155 156 generic/stack.c \ 156 157 generic/stacktrace.c \ -
uspace/lib/c/generic/vfs/vfs.c
rc23275a r438f355 33 33 */ 34 34 35 #include <vfs/vfs.h> 35 36 #include <vfs/canonify.h> 36 #include <vfs/vfs.h>37 37 #include <vfs/vfs_mtab.h> 38 38 #include <vfs/vfs_sess.h> 39 39 #include <macros.h> 40 40 #include <stdlib.h> 41 #include <dirent.h>42 41 #include <sys/types.h> 43 42 #include <ipc/services.h> … … 882 881 } 883 882 884 static void process_mp(const char *path, struct stat *stat, list_t *mtab_list)885 {886 mtab_ent_t *ent;887 888 ent = (mtab_ent_t *) malloc(sizeof(mtab_ent_t));889 if (!ent)890 return;891 892 link_initialize(&ent->link);893 str_cpy(ent->mp, sizeof(ent->mp), path);894 ent->service_id = stat->service_id;895 896 struct statfs stfs;897 if (vfs_statfs_path(path, &stfs) == EOK)898 str_cpy(ent->fs_name, sizeof(ent->fs_name), stfs.fs_name);899 else900 str_cpy(ent->fs_name, sizeof(ent->fs_name), "?");901 902 list_append(&ent->link, mtab_list);903 }904 905 static int vfs_get_mtab_visit(const char *path, list_t *mtab_list,906 fs_handle_t fs_handle, service_id_t service_id)907 {908 DIR *dir;909 struct dirent *dirent;910 911 dir = opendir(path);912 if (!dir)913 return ENOENT;914 915 while ((dirent = readdir(dir)) != NULL) {916 char *child;917 struct stat st;918 int rc;919 920 rc = asprintf(&child, "%s/%s", path, dirent->d_name);921 if (rc < 0) {922 closedir(dir);923 return rc;924 }925 926 char *pa = vfs_absolutize(child, NULL);927 if (!pa) {928 free(child);929 closedir(dir);930 return ENOMEM;931 }932 933 free(child);934 child = pa;935 936 rc = vfs_stat_path(child, &st);937 if (rc != 0) {938 free(child);939 closedir(dir);940 return rc;941 }942 943 if (st.fs_handle != fs_handle || st.service_id != service_id) {944 /*945 * We have discovered a mountpoint.946 */947 process_mp(child, &st, mtab_list);948 }949 950 if (st.is_directory) {951 (void) vfs_get_mtab_visit(child, mtab_list,952 st.fs_handle, st.service_id);953 }954 955 free(child);956 }957 958 closedir(dir);959 return EOK;960 }961 962 int vfs_get_mtab_list(list_t *mtab_list)963 {964 struct stat st;965 966 int rc = vfs_stat_path("/", &st);967 if (rc != 0)968 return rc;969 970 process_mp("/", &st, mtab_list);971 972 return vfs_get_mtab_visit("/", mtab_list, st.fs_handle, st.service_id);973 }974 975 883 /** Get filesystem statistics. 976 884 * -
uspace/lib/c/include/vfs/vfs.h
rc23275a r438f355 79 79 extern int vfs_fhandle(FILE *, int *); 80 80 81 extern int vfs_get_mtab_list(list_t *mtab_list);82 83 81 extern async_exch_t *vfs_exchange_begin(void); 84 82 extern void vfs_exchange_end(async_exch_t *); -
uspace/lib/c/include/vfs/vfs_mtab.h
rc23275a r438f355 47 47 } mtab_ent_t; 48 48 49 extern int vfs_get_mtab_list(list_t *); 50 49 51 #endif 50 52
Note:
See TracChangeset
for help on using the changeset viewer.