Lines Matching +full:mount +full:- +full:point

4  * Copyright (c) 2020-2024 Nordic Semiconductor ASA
6 * SPDX-License-Identifier: Apache-2.0
27 /* lock to protect mount list operations */
30 /* Maps an identifier used in mount points to the file system
41 ep->fstp = NULL; in registry_clear_entry()
47 int rv = -ENOSPC; in registry_add()
52 if (ep->fstp == NULL) { in registry_add()
53 ep->type = type; in registry_add()
54 ep->fstp = fstp; in registry_add()
68 if ((ep->fstp != NULL) && (ep->type == type)) { in registry_find()
79 return (ep != NULL) ? ep->fstp : NULL; in fs_type_get()
93 len = itr->mountp_len; in fs_get_mnt_point()
96 * Move to next node if mount point length is in fs_get_mnt_point()
98 * name is shorter than the mount point name. in fs_get_mnt_point()
106 * separator where mount point name ends. in fs_get_mnt_point()
112 /* Check for mount point match */ in fs_get_mnt_point()
113 if (strncmp(name, itr->mnt_point, len) == 0) { in fs_get_mnt_point()
121 return -ENOENT; in fs_get_mnt_point()
126 *match_len = mnt_p->mountp_len; in fs_get_mnt_point()
136 int rc = -EINVAL; in fs_open()
142 return -EINVAL; in fs_open()
145 if (zfp->mp != NULL) { in fs_open()
146 return -EBUSY; in fs_open()
151 LOG_ERR("mount point not found!!"); in fs_open()
155 if (((mp->flags & FS_MOUNT_FLAG_READ_ONLY) != 0) && in fs_open()
157 return -EROFS; in fs_open()
160 CHECKIF(mp->fs->open == NULL) { in fs_open()
161 return -ENOTSUP; in fs_open()
168 return -EACCES; in fs_open()
170 CHECKIF(mp->fs->truncate == NULL) { in fs_open()
172 return -ENOTSUP; in fs_open()
177 zfp->mp = mp; in fs_open()
178 rc = mp->fs->open(zfp, file_name, flags); in fs_open()
181 zfp->mp = NULL; in fs_open()
186 zfp->flags = flags; in fs_open()
190 rc = mp->fs->truncate(zfp, 0); in fs_open()
193 zfp->mp = NULL; in fs_open()
203 int rc = -EINVAL; in fs_close()
205 if (zfp->mp == NULL) { in fs_close()
209 CHECKIF(zfp->mp->fs->close == NULL) { in fs_close()
210 return -ENOTSUP; in fs_close()
213 rc = zfp->mp->fs->close(zfp); in fs_close()
219 zfp->mp = NULL; in fs_close()
226 int rc = -EINVAL; in fs_read()
228 if (zfp->mp == NULL) { in fs_read()
229 return -EBADF; in fs_read()
232 CHECKIF(zfp->mp->fs->read == NULL) { in fs_read()
233 return -ENOTSUP; in fs_read()
236 rc = zfp->mp->fs->read(zfp, ptr, size); in fs_read()
246 int rc = -EINVAL; in fs_write()
248 if (zfp->mp == NULL) { in fs_write()
249 return -EBADF; in fs_write()
252 CHECKIF(zfp->mp->fs->write == NULL) { in fs_write()
253 return -ENOTSUP; in fs_write()
256 rc = zfp->mp->fs->write(zfp, ptr, size); in fs_write()
266 int rc = -ENOTSUP; in fs_seek()
268 if (zfp->mp == NULL) { in fs_seek()
269 return -EBADF; in fs_seek()
272 CHECKIF(zfp->mp->fs->lseek == NULL) { in fs_seek()
273 return -ENOTSUP; in fs_seek()
276 rc = zfp->mp->fs->lseek(zfp, offset, whence); in fs_seek()
286 int rc = -ENOTSUP; in fs_tell()
288 if (zfp->mp == NULL) { in fs_tell()
289 return -EBADF; in fs_tell()
292 CHECKIF(zfp->mp->fs->tell == NULL) { in fs_tell()
293 return -ENOTSUP; in fs_tell()
296 rc = zfp->mp->fs->tell(zfp); in fs_tell()
306 int rc = -EINVAL; in fs_truncate()
308 if (zfp->mp == NULL) { in fs_truncate()
309 return -EBADF; in fs_truncate()
312 CHECKIF(zfp->mp->fs->truncate == NULL) { in fs_truncate()
313 return -ENOTSUP; in fs_truncate()
316 rc = zfp->mp->fs->truncate(zfp, length); in fs_truncate()
326 int rc = -EINVAL; in fs_sync()
328 if (zfp->mp == NULL) { in fs_sync()
329 return -EBADF; in fs_sync()
332 CHECKIF(zfp->mp->fs->sync == NULL) { in fs_sync()
333 return -ENOTSUP; in fs_sync()
336 rc = zfp->mp->fs->sync(zfp); in fs_sync()
348 int rc = -EINVAL; in fs_opendir()
353 return -EINVAL; in fs_opendir()
356 if (zdp->mp != NULL || zdp->dirp != NULL) { in fs_opendir()
357 return -EBUSY; in fs_opendir()
362 /* Open VFS root dir, marked by zdp->mp == NULL */ in fs_opendir()
365 zdp->mp = NULL; in fs_opendir()
366 zdp->dirp = sys_dlist_peek_head(&fs_mnt_list); in fs_opendir()
375 LOG_ERR("mount point not found!!"); in fs_opendir()
379 CHECKIF(mp->fs->opendir == NULL) { in fs_opendir()
380 return -ENOTSUP; in fs_opendir()
383 zdp->mp = mp; in fs_opendir()
384 rc = zdp->mp->fs->opendir(zdp, abs_path); in fs_opendir()
386 zdp->mp = NULL; in fs_opendir()
387 zdp->dirp = NULL; in fs_opendir()
396 if (zdp->mp) { in fs_readdir()
398 int rc = -EINVAL; in fs_readdir()
400 CHECKIF(zdp->mp->fs->readdir == NULL) { in fs_readdir()
401 return -ENOTSUP; in fs_readdir()
406 rc = zdp->mp->fs->readdir(zdp, entry); in fs_readdir()
410 if (entry->name[0] == 0) { in fs_readdir()
413 if (entry->type != FS_DIR_ENTRY_DIR) { in fs_readdir()
416 if ((strcmp(entry->name, ".") != 0) in fs_readdir()
417 && (strcmp(entry->name, "..") != 0)) { in fs_readdir()
429 if (zdp->dirp == NULL) { in fs_readdir()
431 entry->name[0] = 0; in fs_readdir()
435 /* Find the current and next entries in the mount point dlist */ in fs_readdir()
442 if (node == zdp->dirp) { in fs_readdir()
450 entry->type = FS_DIR_ENTRY_DIR; in fs_readdir()
451 strncpy(entry->name, mnt->mnt_point + 1, in fs_readdir()
452 sizeof(entry->name) - 1); in fs_readdir()
453 entry->name[sizeof(entry->name) - 1] = 0; in fs_readdir()
454 entry->size = 0; in fs_readdir()
466 * call to readdir -- return an error in fs_readdir()
468 return -ENOENT; in fs_readdir()
471 zdp->dirp = next; in fs_readdir()
477 int rc = -EINVAL; in fs_closedir()
479 if (zdp->mp == NULL) { in fs_closedir()
481 zdp->dirp = NULL; in fs_closedir()
485 CHECKIF(zdp->mp->fs->closedir == NULL) { in fs_closedir()
486 return -ENOTSUP; in fs_closedir()
489 rc = zdp->mp->fs->closedir(zdp); in fs_closedir()
495 zdp->mp = NULL; in fs_closedir()
496 zdp->dirp = NULL; in fs_closedir()
504 int rc = -EINVAL; in fs_mkdir()
509 return -EINVAL; in fs_mkdir()
514 LOG_ERR("mount point not found!!"); in fs_mkdir()
518 if (mp->flags & FS_MOUNT_FLAG_READ_ONLY) { in fs_mkdir()
519 return -EROFS; in fs_mkdir()
522 CHECKIF(mp->fs->mkdir == NULL) { in fs_mkdir()
523 return -ENOTSUP; in fs_mkdir()
526 rc = mp->fs->mkdir(mp, abs_path); in fs_mkdir()
537 int rc = -EINVAL; in fs_unlink()
542 return -EINVAL; in fs_unlink()
547 LOG_ERR("mount point not found!!"); in fs_unlink()
551 if (mp->flags & FS_MOUNT_FLAG_READ_ONLY) { in fs_unlink()
552 return -EROFS; in fs_unlink()
555 CHECKIF(mp->fs->unlink == NULL) { in fs_unlink()
556 return -ENOTSUP; in fs_unlink()
559 rc = mp->fs->unlink(mp, abs_path); in fs_unlink()
571 int rc = -EINVAL; in fs_rename()
576 return -EINVAL; in fs_rename()
581 LOG_ERR("mount point not found!!"); in fs_rename()
585 if (mp->flags & FS_MOUNT_FLAG_READ_ONLY) { in fs_rename()
586 return -EROFS; in fs_rename()
591 LOG_ERR("mount point not same!!"); in fs_rename()
592 return -EINVAL; in fs_rename()
595 CHECKIF(mp->fs->rename == NULL) { in fs_rename()
596 return -ENOTSUP; in fs_rename()
599 rc = mp->fs->rename(mp, from, to); in fs_rename()
610 int rc = -EINVAL; in fs_stat()
615 return -EINVAL; in fs_stat()
620 LOG_ERR("mount point not found!!"); in fs_stat()
624 CHECKIF(mp->fs->stat == NULL) { in fs_stat()
625 return -ENOTSUP; in fs_stat()
628 rc = mp->fs->stat(mp, abs_path, entry); in fs_stat()
629 if (rc == -ENOENT) { in fs_stat()
645 return -EINVAL; in fs_statvfs()
650 LOG_ERR("mount point not found!!"); in fs_statvfs()
654 CHECKIF(mp->fs->statvfs == NULL) { in fs_statvfs()
655 return -ENOTSUP; in fs_statvfs()
658 rc = mp->fs->statvfs(mp, abs_path, stat); in fs_statvfs()
671 int rc = -EINVAL; in fs_mount()
677 if ((mp == NULL) || (mp->mnt_point == NULL)) { in fs_mount()
678 LOG_ERR("mount point not initialized!!"); in fs_mount()
679 return -EINVAL; in fs_mount()
682 if (sys_dnode_is_linked(&mp->node)) { in fs_mount()
684 return -EBUSY; in fs_mount()
687 len = strlen(mp->mnt_point); in fs_mount()
689 if ((len <= 1) || (mp->mnt_point[0] != '/')) { in fs_mount()
690 LOG_ERR("invalid mount point!!"); in fs_mount()
691 return -EINVAL; in fs_mount()
696 /* Check if mount point already exists */ in fs_mount()
700 if (len != itr->mountp_len) { in fs_mount()
704 CHECKIF(mp->fs_data == itr->fs_data) { in fs_mount()
706 rc = -EBUSY; in fs_mount()
710 if (strncmp(mp->mnt_point, itr->mnt_point, len) == 0) { in fs_mount()
711 LOG_ERR("mount point already exists!!"); in fs_mount()
712 rc = -EBUSY; in fs_mount()
718 fs = fs_type_get(mp->type); in fs_mount()
721 rc = -ENOENT; in fs_mount()
725 CHECKIF(fs->mount == NULL) { in fs_mount()
726 LOG_ERR("fs type %d does not support mounting", mp->type); in fs_mount()
727 rc = -ENOTSUP; in fs_mount()
731 if (fs->unmount == NULL) { in fs_mount()
732 LOG_WRN("mount path %s is not unmountable", in fs_mount()
733 mp->mnt_point); in fs_mount()
736 rc = fs->mount(mp); in fs_mount()
738 LOG_ERR("fs mount error (%d)", rc); in fs_mount()
742 /* Update mount point data and append it to the list */ in fs_mount()
743 mp->mountp_len = len; in fs_mount()
744 mp->fs = fs; in fs_mount()
746 sys_dlist_append(&fs_mnt_list, &mp->node); in fs_mount()
747 LOG_DBG("fs mounted at %s", mp->mnt_point); in fs_mount()
758 int rc = -EINVAL; in fs_mkfs()
768 rc = -ENOENT; in fs_mkfs()
772 CHECKIF(fs->mkfs == NULL) { in fs_mkfs()
774 rc = -ENOTSUP; in fs_mkfs()
778 rc = fs->mkfs(dev_id, cfg, flags); in fs_mkfs()
793 int rc = -EINVAL; in fs_unmount()
801 if (!sys_dnode_is_linked(&mp->node)) { in fs_unmount()
806 CHECKIF(mp->fs->unmount == NULL) { in fs_unmount()
808 rc = -ENOTSUP; in fs_unmount()
812 rc = mp->fs->unmount(mp); in fs_unmount()
818 /* remove mount node from the list */ in fs_unmount()
819 sys_dlist_remove(&mp->node); in fs_unmount()
820 LOG_DBG("fs unmounted from %s", mp->mnt_point); in fs_unmount()
830 int rc = -ENOENT; in fs_readmount()
851 *name = itr->mnt_point; in fs_readmount()
867 rc = -EALREADY; in fs_register()
888 if ((ep == NULL) || (ep->fstp != fs)) { in fs_unregister()
889 rc = -EINVAL; in fs_unregister()