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

Function rpmsgfs_open

fs/rpmsgfs/rpmsgfs.c:279–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277 ****************************************************************************/
278
279static int rpmsgfs_open(FAR struct file *filep, FAR const char *relpath,
280 int oflags, mode_t mode)
281{
282 FAR struct inode *inode;
283 FAR struct rpmsgfs_mountpt_s *fs;
284 FAR struct rpmsgfs_ofile_s *hf;
285 FAR char *path;
286 int ret;
287
288 /* Sanity checks */
289
290 DEBUGASSERT((filep->f_priv == NULL) && (filep->f_inode != NULL));
291
292 /* Get the mountpoint inode reference from the file structure and the
293 * mountpoint private data from the inode structure
294 */
295
296 inode = filep->f_inode;
297 fs = inode->i_private;
298
299 DEBUGASSERT(fs != NULL);
300
301 path = lib_get_pathbuffer();
302 if (path == NULL)
303 {
304 return -ENOMEM;
305 }
306
307 /* Take the lock */
308
309 ret = nxmutex_lock(&fs->fs_lock);
310 if (ret < 0)
311 {
312 lib_put_pathbuffer(path);
313 return ret;
314 }
315
316 /* Allocate memory for the open file */
317
318 hf = fs_heap_malloc(sizeof *hf);
319 if (hf == NULL)
320 {
321 ret = -ENOMEM;
322 goto errout_with_lock;
323 }
324
325 /* Append to the host's root directory */
326
327 rpmsgfs_mkpath(fs, relpath, path, PATH_MAX);
328
329 /* Try to open the file in the host file system */
330
331 hf->fd = rpmsgfs_client_open(fs->handle, path, oflags, mode);
332 if (hf->fd < 0)
333 {
334 /* Error opening file */
335
336 ret = hf->fd;

Callers

nothing calls this directly

Calls 7

nxmutex_lockFunction · 0.85
fs_heap_mallocFunction · 0.85
rpmsgfs_mkpathFunction · 0.85
rpmsgfs_client_openFunction · 0.85
rpmsgfs_client_lseekFunction · 0.85
fs_heap_freeFunction · 0.85
nxmutex_unlockFunction · 0.85

Tested by

no test coverage detected