5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
25 */
26
27 #include <sys/types.h>
28 #include <sys/t_lock.h>
29 #include <sys/param.h>
30 #include <sys/time.h>
31 #include <sys/systm.h>
32 #include <sys/sysmacros.h>
33 #include <sys/resource.h>
34 #include <sys/signal.h>
35 #include <sys/cred.h>
36 #include <sys/user.h>
37 #include <sys/buf.h>
38 #include <sys/vfs.h>
39 #include <sys/vfs_opreg.h>
40 #include <sys/stat.h>
41 #include <sys/vnode.h>
42 #include <sys/mode.h>
43 #include <sys/proc.h>
44 #include <sys/disp.h>
104 dev_t, struct ud_map *, struct pmap_typ2 *);
105 uint32_t ud_get_lbsize(dev_t, uint32_t *);
106
107 static int32_t udf_mount(struct vfs *,
108 struct vnode *, struct mounta *, struct cred *);
109 static int32_t udf_unmount(struct vfs *, int, struct cred *);
110 static int32_t udf_root(struct vfs *, struct vnode **);
111 static int32_t udf_statvfs(struct vfs *, struct statvfs64 *);
112 static int32_t udf_sync(struct vfs *, int16_t, struct cred *);
113 static int32_t udf_vget(struct vfs *, struct vnode **, struct fid *);
114 static int32_t udf_mountroot(struct vfs *vfsp, enum whymountroot);
115
116 static int udfinit(int, char *);
117
118 static mntopts_t udfs_mntopts;
119
120 static vfsdef_t vfw = {
121 VFSDEF_VERSION,
122 "udfs",
123 udfinit,
124 VSW_HASPROTO|VSW_CANREMOUNT|VSW_STATS|VSW_CANLOFI,
125 &udfs_mntopts
126 };
127
128 static mntopts_t udfs_mntopts = {
129 0,
130 NULL
131 };
132
133 /*
134 * Module linkage information for the kernel.
135 */
136 extern struct mod_ops mod_fsops;
137
138 static struct modlfs modlfs = {
139 &mod_fsops, "filesystem for UDFS", &vfw
140 };
141
142 static struct modlinkage modlinkage = {
143 MODREV_1, (void *)&modlfs, NULL
144 };
472
473 /*
474 * Flush any pending I/O to file system vfsp.
475 * The ud_update() routine will only flush *all* udf files.
476 */
477 /*ARGSUSED*/
478 /* ARGSUSED */
479 static int32_t
480 udf_sync(struct vfs *vfsp, int16_t flag, struct cred *cr)
481 {
482 ud_printf("udf_sync\n");
483
484 ud_update(flag);
485 return (0);
486 }
487
488
489
490 /* ARGSUSED */
491 static int32_t
492 udf_vget(struct vfs *vfsp,
493 struct vnode **vpp, struct fid *fidp)
494 {
495 int32_t error = 0;
496 struct udf_fid *udfid;
497 struct udf_vfs *udf_vfsp;
498 struct ud_inode *ip;
499
500 ud_printf("udf_vget\n");
501
502 udf_vfsp = (struct udf_vfs *)vfsp->vfs_data;
503 if (udf_vfsp == NULL) {
504 *vpp = NULL;
505 return (0);
506 }
507
508 udfid = (struct udf_fid *)fidp;
509 if ((error = ud_iget(vfsp, udfid->udfid_prn,
510 udfid->udfid_icb_lbn, &ip, NULL, CRED())) != 0) {
511 *vpp = NULL;
512 return (error);
513 }
595 if (rootvp) {
596 VN_RELE(rootvp);
597 rootvp = (struct vnode *)0;
598 }
599 return (error);
600 }
601
602 if (why == ROOT_INIT) {
603 vfs_add((struct vnode *)0, vfsp,
604 (vfsp->vfs_flag & VFS_RDONLY) ? MS_RDONLY : 0);
605 }
606 vfs_unlock(vfsp);
607 return (0);
608 }
609
610
611 /* ------------------------- local routines ------------------------- */
612
613
614 static int32_t
615 ud_mountfs(struct vfs *vfsp,
616 enum whymountroot why, dev_t dev, char *name,
617 struct cred *cr, int32_t isroot)
618 {
619 struct vnode *devvp = NULL;
620 int32_t error = 0;
621 int32_t needclose = 0;
622 struct udf_vfs *udf_vfsp = NULL;
623 struct log_vol_int_desc *lvid;
624 struct ud_inode *rip = NULL;
625 struct vnode *rvp = NULL;
626 int32_t i, lbsize;
627 uint32_t avd_loc;
628 struct ud_map *map;
629 int32_t desc_len;
630
631 ud_printf("ud_mountfs\n");
632
633 if (why == ROOT_INIT) {
634 /*
635 * Open the device.
636 */
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
25 * Copyright (c) 2017 by Delphix. All rights reserved.
26 */
27
28 #include <sys/types.h>
29 #include <sys/t_lock.h>
30 #include <sys/param.h>
31 #include <sys/time.h>
32 #include <sys/systm.h>
33 #include <sys/sysmacros.h>
34 #include <sys/resource.h>
35 #include <sys/signal.h>
36 #include <sys/cred.h>
37 #include <sys/user.h>
38 #include <sys/buf.h>
39 #include <sys/vfs.h>
40 #include <sys/vfs_opreg.h>
41 #include <sys/stat.h>
42 #include <sys/vnode.h>
43 #include <sys/mode.h>
44 #include <sys/proc.h>
45 #include <sys/disp.h>
105 dev_t, struct ud_map *, struct pmap_typ2 *);
106 uint32_t ud_get_lbsize(dev_t, uint32_t *);
107
108 static int32_t udf_mount(struct vfs *,
109 struct vnode *, struct mounta *, struct cred *);
110 static int32_t udf_unmount(struct vfs *, int, struct cred *);
111 static int32_t udf_root(struct vfs *, struct vnode **);
112 static int32_t udf_statvfs(struct vfs *, struct statvfs64 *);
113 static int32_t udf_sync(struct vfs *, int16_t, struct cred *);
114 static int32_t udf_vget(struct vfs *, struct vnode **, struct fid *);
115 static int32_t udf_mountroot(struct vfs *vfsp, enum whymountroot);
116
117 static int udfinit(int, char *);
118
119 static mntopts_t udfs_mntopts;
120
121 static vfsdef_t vfw = {
122 VFSDEF_VERSION,
123 "udfs",
124 udfinit,
125 VSW_HASPROTO|VSW_CANREMOUNT|VSW_STATS|VSW_CANLOFI|VSW_MOUNTDEV,
126 &udfs_mntopts
127 };
128
129 static mntopts_t udfs_mntopts = {
130 0,
131 NULL
132 };
133
134 /*
135 * Module linkage information for the kernel.
136 */
137 extern struct mod_ops mod_fsops;
138
139 static struct modlfs modlfs = {
140 &mod_fsops, "filesystem for UDFS", &vfw
141 };
142
143 static struct modlinkage modlinkage = {
144 MODREV_1, (void *)&modlfs, NULL
145 };
473
474 /*
475 * Flush any pending I/O to file system vfsp.
476 * The ud_update() routine will only flush *all* udf files.
477 */
478 /*ARGSUSED*/
479 /* ARGSUSED */
480 static int32_t
481 udf_sync(struct vfs *vfsp, int16_t flag, struct cred *cr)
482 {
483 ud_printf("udf_sync\n");
484
485 ud_update(flag);
486 return (0);
487 }
488
489
490
491 /* ARGSUSED */
492 static int32_t
493 udf_vget(struct vfs *vfsp, struct vnode **vpp, struct fid *fidp)
494 {
495 int32_t error = 0;
496 struct udf_fid *udfid;
497 struct udf_vfs *udf_vfsp;
498 struct ud_inode *ip;
499
500 ud_printf("udf_vget\n");
501
502 udf_vfsp = (struct udf_vfs *)vfsp->vfs_data;
503 if (udf_vfsp == NULL) {
504 *vpp = NULL;
505 return (0);
506 }
507
508 udfid = (struct udf_fid *)fidp;
509 if ((error = ud_iget(vfsp, udfid->udfid_prn,
510 udfid->udfid_icb_lbn, &ip, NULL, CRED())) != 0) {
511 *vpp = NULL;
512 return (error);
513 }
595 if (rootvp) {
596 VN_RELE(rootvp);
597 rootvp = (struct vnode *)0;
598 }
599 return (error);
600 }
601
602 if (why == ROOT_INIT) {
603 vfs_add((struct vnode *)0, vfsp,
604 (vfsp->vfs_flag & VFS_RDONLY) ? MS_RDONLY : 0);
605 }
606 vfs_unlock(vfsp);
607 return (0);
608 }
609
610
611 /* ------------------------- local routines ------------------------- */
612
613
614 static int32_t
615 ud_mountfs(struct vfs *vfsp, enum whymountroot why, dev_t dev, char *name,
616 struct cred *cr, int32_t isroot)
617 {
618 struct vnode *devvp = NULL;
619 int32_t error = 0;
620 int32_t needclose = 0;
621 struct udf_vfs *udf_vfsp = NULL;
622 struct log_vol_int_desc *lvid;
623 struct ud_inode *rip = NULL;
624 struct vnode *rvp = NULL;
625 int32_t i, lbsize;
626 uint32_t avd_loc;
627 struct ud_map *map;
628 int32_t desc_len;
629
630 ud_printf("ud_mountfs\n");
631
632 if (why == ROOT_INIT) {
633 /*
634 * Open the device.
635 */
|