| 1026 | ****************************************************************************/ |
| 1027 | |
| 1028 | static int hostfs_bind(FAR struct inode *blkdriver, FAR const void *data, |
| 1029 | FAR void **handle) |
| 1030 | { |
| 1031 | FAR struct hostfs_mountpt_s *fs; |
| 1032 | FAR char *options; |
| 1033 | FAR char *saveptr; |
| 1034 | FAR char *ptr; |
| 1035 | int len; |
| 1036 | int ret; |
| 1037 | |
| 1038 | /* Validate the block driver is NULL */ |
| 1039 | |
| 1040 | if (blkdriver || !data) |
| 1041 | { |
| 1042 | return -ENODEV; |
| 1043 | } |
| 1044 | |
| 1045 | /* Create an instance of the mountpt state structure */ |
| 1046 | |
| 1047 | fs = (FAR struct hostfs_mountpt_s *) |
| 1048 | fs_heap_zalloc(sizeof(struct hostfs_mountpt_s)); |
| 1049 | |
| 1050 | if (fs == NULL) |
| 1051 | { |
| 1052 | return -ENOMEM; |
| 1053 | } |
| 1054 | |
| 1055 | /* The options we support are: |
| 1056 | * "fs=whatever", remote dir |
| 1057 | */ |
| 1058 | |
| 1059 | options = fs_heap_strdup(data); |
| 1060 | if (!options) |
| 1061 | { |
| 1062 | fs_heap_free(fs); |
| 1063 | return -ENOMEM; |
| 1064 | } |
| 1065 | |
| 1066 | ptr = strtok_r(options, ",", &saveptr); |
| 1067 | while (ptr != NULL) |
| 1068 | { |
| 1069 | if ((strncmp(ptr, "fs=", 3) == 0)) |
| 1070 | { |
| 1071 | strlcpy(fs->fs_root, &ptr[3], sizeof(fs->fs_root)); |
| 1072 | } |
| 1073 | |
| 1074 | ptr = strtok_r(NULL, ",", &saveptr); |
| 1075 | } |
| 1076 | |
| 1077 | fs_heap_free(options); |
| 1078 | |
| 1079 | /* Take the lock for the mount */ |
| 1080 | |
| 1081 | ret = nxmutex_lock(&g_lock); |
| 1082 | if (ret < 0) |
| 1083 | { |
| 1084 | fs_heap_free(fs); |
| 1085 | return ret; |
nothing calls this directly
no test coverage detected