Annotation of embedaddon/libpdel/sys/fs_mount.c, revision 1.1
1.1 ! misho 1:
! 2: /*
! 3: * Copyright (c) 2001-2002 Packet Design, LLC.
! 4: * All rights reserved.
! 5: *
! 6: * Subject to the following obligations and disclaimer of warranty,
! 7: * use and redistribution of this software, in source or object code
! 8: * forms, with or without modifications are expressly permitted by
! 9: * Packet Design; provided, however, that:
! 10: *
! 11: * (i) Any and all reproductions of the source or object code
! 12: * must include the copyright notice above and the following
! 13: * disclaimer of warranties; and
! 14: * (ii) No rights are granted, in any manner or form, to use
! 15: * Packet Design trademarks, including the mark "PACKET DESIGN"
! 16: * on advertising, endorsements, or otherwise except as such
! 17: * appears in the above copyright notice or in the software.
! 18: *
! 19: * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
! 20: * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
! 21: * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
! 22: * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
! 23: * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
! 24: * OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
! 25: * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
! 26: * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
! 27: * RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE
! 28: * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
! 29: * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
! 30: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
! 31: * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
! 32: * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
! 33: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 34: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
! 35: * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
! 36: * THE POSSIBILITY OF SUCH DAMAGE.
! 37: *
! 38: * Author: Archie Cobbs <archie@freebsd.org>
! 39: */
! 40:
! 41: #include <sys/types.h>
! 42: #include <sys/param.h>
! 43: #include <sys/mount.h>
! 44:
! 45: #include <ufs/ufs/ufsmount.h>
! 46:
! 47: #include <stdio.h>
! 48: #include <stddef.h>
! 49: #include <string.h>
! 50: #include <syslog.h>
! 51: #include <errno.h>
! 52: #include <fstab.h>
! 53:
! 54: #include <openssl/ssl.h>
! 55:
! 56: #include "sys/fs_mount.h"
! 57:
! 58: /*
! 59: * Mount a filesystem.
! 60: */
! 61: int
! 62: fs_mount(const char *where, int flags)
! 63: {
! 64: struct fstab *fstab;
! 65: struct ufs_args ufs_args;
! 66: void *mnt_args;
! 67: int errno_save;
! 68: int rtn = -1;
! 69:
! 70: /* Get /etc/fstab entry for mount point */
! 71: fstab = getfsfile(where);
! 72:
! 73: /* Check for error */
! 74: if ((fstab = getfsfile(where)) == NULL) {
! 75: errno = ENOENT;
! 76: goto done;
! 77: }
! 78:
! 79: /* Set up args */
! 80: memset(&ufs_args, 0, sizeof(ufs_args));
! 81: ufs_args.fspec = fstab->fs_spec;
! 82: mnt_args = &ufs_args;
! 83:
! 84: /* Try to mount */
! 85: if (mount(fstab->fs_vfstype, where, flags, mnt_args) == 0)
! 86: rtn = 0;
! 87:
! 88: done:
! 89: /* Clean up */
! 90: errno_save = errno;
! 91: endfsent();
! 92: errno = errno_save;
! 93: return (rtn);
! 94: }
! 95:
! 96: /*
! 97: * Unmount a filesystem.
! 98: */
! 99: int
! 100: fs_unmount(const char *where, int flags)
! 101: {
! 102: if (unmount(where, flags) == -1)
! 103: return (-1);
! 104: return (0);
! 105: }
! 106:
! 107:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>