MCPcopy Create free account
hub / github.com/apache/nuttx / rpmsgfs_bind

Function rpmsgfs_bind

fs/rpmsgfs/rpmsgfs.c:1066–1167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1064 ****************************************************************************/
1065
1066static int rpmsgfs_bind(FAR struct inode *blkdriver, FAR const void *data,
1067 FAR void **handle)
1068{
1069 FAR struct rpmsgfs_mountpt_s *fs;
1070 FAR const char *cpuname = NULL;
1071 FAR char *options;
1072 char *saveptr;
1073 char *ptr;
1074 int len;
1075 int ret;
1076
1077 /* Validate the block driver is NULL */
1078
1079 if (blkdriver || !data)
1080 {
1081 return -ENODEV;
1082 }
1083
1084 /* Create an instance of the mountpt state structure */
1085
1086 fs = (FAR struct rpmsgfs_mountpt_s *)
1087 fs_heap_zalloc(sizeof(struct rpmsgfs_mountpt_s));
1088
1089 if (fs == NULL)
1090 {
1091 return -ENOMEM;
1092 }
1093
1094 /* The options we support are:
1095 * "fs=whatever,cpu=cpuname", remote dir
1096 * "timeout=xx", connect timeout, unit (ms)
1097 */
1098
1099 options = fs_heap_strdup(data);
1100 if (!options)
1101 {
1102 fs_heap_free(fs);
1103 return -ENOMEM;
1104 }
1105
1106 /* Set timeout default value */
1107
1108 fs->timeout = INT_MAX;
1109
1110 ptr = strtok_r(options, ",", &saveptr);
1111 while (ptr != NULL)
1112 {
1113 if ((strncmp(ptr, "fs=", 3) == 0))
1114 {
1115 strlcpy(fs->fs_root, &ptr[3], sizeof(fs->fs_root));
1116 }
1117 else if ((strncmp(ptr, "cpu=", 4) == 0))
1118 {
1119 cpuname = &ptr[4];
1120 }
1121 else if ((strncmp(ptr, "timeout=", 8) == 0))
1122 {
1123 fs->timeout = atoi(&ptr[8]);

Callers

nothing calls this directly

Calls 11

fs_heap_zallocFunction · 0.85
fs_heap_strdupFunction · 0.85
fs_heap_freeFunction · 0.85
strtok_rFunction · 0.85
atoiFunction · 0.85
rpmsgfs_client_bindFunction · 0.85
nxmutex_initFunction · 0.85
strncmpFunction · 0.50
strlcpyFunction · 0.50
strlenFunction · 0.50
strlcatFunction · 0.50

Tested by

no test coverage detected