MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sys_mount

Function sys_mount

freebsd/kern/vfs_mount.c:833–887  ·  view source on GitHub ↗

ARGSUSED */

Source from the content-addressed store, hash-verified

831#endif
832/* ARGSUSED */
833int
834sys_mount(struct thread *td, struct mount_args *uap)
835{
836 char *fstype;
837 struct vfsconf *vfsp = NULL;
838 struct mntarg *ma = NULL;
839 uint64_t flags;
840 int error;
841
842 /*
843 * Mount flags are now 64-bits. On 32-bit architectures only
844 * 32-bits are passed in, but from here on everything handles
845 * 64-bit flags correctly.
846 */
847 flags = uap->flags;
848
849 AUDIT_ARG_FFLAGS(flags);
850
851 /*
852 * Filter out MNT_ROOTFS. We do not want clients of mount() in
853 * userspace to set this flag, but we must filter it out if we want
854 * MNT_UPDATE on the root file system to work.
855 * MNT_ROOTFS should only be set by the kernel when mounting its
856 * root file system.
857 */
858 flags &= ~MNT_ROOTFS;
859
860 fstype = malloc(MFSNAMELEN, M_TEMP, M_WAITOK);
861 error = copyinstr(uap->type, fstype, MFSNAMELEN, NULL);
862 if (error) {
863 free(fstype, M_TEMP);
864 return (error);
865 }
866
867 AUDIT_ARG_TEXT(fstype);
868 vfsp = vfs_byname_kld(fstype, td, &error);
869 free(fstype, M_TEMP);
870 if (vfsp == NULL)
871 return (ENOENT);
872 if (((vfsp->vfc_flags & VFCF_SBDRY) != 0 &&
873 vfsp->vfc_vfsops_sd->vfs_cmount == NULL) ||
874 ((vfsp->vfc_flags & VFCF_SBDRY) == 0 &&
875 vfsp->vfc_vfsops->vfs_cmount == NULL))
876 return (EOPNOTSUPP);
877
878 ma = mount_argsu(ma, "fstype", uap->type, MFSNAMELEN);
879 ma = mount_argsu(ma, "fspath", uap->path, MNAMELEN);
880 ma = mount_argb(ma, flags & MNT_RDONLY, "noro");
881 ma = mount_argb(ma, !(flags & MNT_NOSUID), "nosuid");
882 ma = mount_argb(ma, !(flags & MNT_NOEXEC), "noexec");
883
884 if ((vfsp->vfc_flags & VFCF_SBDRY) != 0)
885 return (vfsp->vfc_vfsops_sd->vfs_cmount(ma, uap->data, flags));
886 return (vfsp->vfc_vfsops->vfs_cmount(ma, uap->data, flags));
887}
888
889/*
890 * vfs_domount_first(): first file system mount (not update)

Callers

nothing calls this directly

Calls 6

mallocFunction · 0.85
vfs_byname_kldFunction · 0.85
mount_argsuFunction · 0.85
mount_argbFunction · 0.85
freeFunction · 0.70
copyinstrFunction · 0.50

Tested by

no test coverage detected