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

Function vfs_export

freebsd/kern/vfs_export.c:299–371  ·  view source on GitHub ↗

* High level function to manipulate export options on a mount point * and the passed in netexport. * Struct export_args *argp is the variable used to twiddle options, * the structure is described in sys/mount.h */

Source from the content-addressed store, hash-verified

297 * the structure is described in sys/mount.h
298 */
299int
300vfs_export(struct mount *mp, struct export_args *argp)
301{
302 struct netexport *nep;
303 int error;
304
305 if ((argp->ex_flags & (MNT_DELEXPORT | MNT_EXPORTED)) == 0)
306 return (EINVAL);
307
308 if ((argp->ex_flags & MNT_EXPORTED) != 0 &&
309 (argp->ex_numsecflavors < 0
310 || argp->ex_numsecflavors >= MAXSECFLAVORS))
311 return (EINVAL);
312
313 error = 0;
314 lockmgr(&mp->mnt_explock, LK_EXCLUSIVE, NULL);
315 nep = mp->mnt_export;
316 if (argp->ex_flags & MNT_DELEXPORT) {
317 if (nep == NULL) {
318 error = ENOENT;
319 goto out;
320 }
321 if (mp->mnt_flag & MNT_EXPUBLIC) {
322 vfs_setpublicfs(NULL, NULL, NULL);
323 MNT_ILOCK(mp);
324 mp->mnt_flag &= ~MNT_EXPUBLIC;
325 MNT_IUNLOCK(mp);
326 }
327 vfs_free_addrlist(nep);
328 mp->mnt_export = NULL;
329 free(nep, M_MOUNT);
330 nep = NULL;
331 MNT_ILOCK(mp);
332 mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED);
333 MNT_IUNLOCK(mp);
334 }
335 if (argp->ex_flags & MNT_EXPORTED) {
336 if (nep == NULL) {
337 nep = malloc(sizeof(struct netexport), M_MOUNT, M_WAITOK | M_ZERO);
338 mp->mnt_export = nep;
339 }
340 if (argp->ex_flags & MNT_EXPUBLIC) {
341 if ((error = vfs_setpublicfs(mp, nep, argp)) != 0)
342 goto out;
343 MNT_ILOCK(mp);
344 mp->mnt_flag |= MNT_EXPUBLIC;
345 MNT_IUNLOCK(mp);
346 }
347 if (argp->ex_numsecflavors == 0) {
348 argp->ex_numsecflavors = 1;
349 argp->ex_secflavors[0] = AUTH_SYS;
350 }
351 if ((error = vfs_hang_addrlist(mp, nep, argp)))
352 goto out;
353 MNT_ILOCK(mp);
354 mp->mnt_flag |= MNT_EXPORTED;
355 MNT_IUNLOCK(mp);
356 }

Callers 1

vfs_domount_updateFunction · 0.85

Calls 6

vfs_setpublicfsFunction · 0.85
vfs_free_addrlistFunction · 0.85
mallocFunction · 0.85
vfs_hang_addrlistFunction · 0.85
vfs_deleteoptFunction · 0.85
freeFunction · 0.70

Tested by

no test coverage detected