Deleted Added
full compact
cd9660_vfsops.c (25287) cd9660_vfsops.c (25460)
1/*-
2 * Copyright (c) 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley
6 * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
7 * Support code is derived from software contributed to Berkeley
8 * by Atsushi Murai (amurai@spec.co.jp).

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)cd9660_vfsops.c 8.18 (Berkeley) 5/22/95
1/*-
2 * Copyright (c) 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley
6 * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
7 * Support code is derived from software contributed to Berkeley
8 * by Atsushi Murai (amurai@spec.co.jp).

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)cd9660_vfsops.c 8.18 (Berkeley) 5/22/95
39 * $Id: cd9660_vfsops.c,v 1.23 1997/04/29 15:52:53 joerg Exp $
39 * $Id: cd9660_vfsops.c,v 1.24 1997/04/29 17:11:51 joerg Exp $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/namei.h>
45#include <sys/proc.h>
46#include <sys/kernel.h>
47#include <sys/vnode.h>
48#include <miscfs/specfs/specdev.h>
49#include <sys/mount.h>
50#include <sys/buf.h>
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/namei.h>
45#include <sys/proc.h>
46#include <sys/kernel.h>
47#include <sys/vnode.h>
48#include <miscfs/specfs/specdev.h>
49#include <sys/mount.h>
50#include <sys/buf.h>
51#include <sys/cdio.h>
52#include <sys/conf.h>
51#include <sys/fcntl.h>
52#include <sys/errno.h>
53#include <sys/malloc.h>
54#include <sys/stat.h>
55
56#include <isofs/cd9660/iso.h>
57#include <isofs/cd9660/iso_rrip.h>
58#include <isofs/cd9660/cd9660_node.h>

--- 30 unchanged lines hidden (view full) ---

89};
90VFS_SET(cd9660_vfsops, cd9660, MOUNT_CD9660, VFCF_READONLY);
91
92
93/*
94 * Called by vfs_mountroot when iso is going to be mounted as root.
95 */
96
53#include <sys/fcntl.h>
54#include <sys/errno.h>
55#include <sys/malloc.h>
56#include <sys/stat.h>
57
58#include <isofs/cd9660/iso.h>
59#include <isofs/cd9660/iso_rrip.h>
60#include <isofs/cd9660/cd9660_node.h>

--- 30 unchanged lines hidden (view full) ---

91};
92VFS_SET(cd9660_vfsops, cd9660, MOUNT_CD9660, VFCF_READONLY);
93
94
95/*
96 * Called by vfs_mountroot when iso is going to be mounted as root.
97 */
98
99static int iso_get_ssector __P((dev_t dev, struct proc *p));
97static int iso_mountfs __P((struct vnode *devvp, struct mount *mp,
98 struct proc *p, struct iso_args *argp));
100static int iso_mountfs __P((struct vnode *devvp, struct mount *mp,
101 struct proc *p, struct iso_args *argp));
102static int iso_mountroot __P((struct mount *mp, struct proc *p));
99
103
100int
101cd9660_mountroot()
104/*
105 * Try to find the start of the last data track on this CD-ROM. This
106 * is used to mount the last session of a multi-session CD. Bail out
107 * and return 0 if we fail, this is always a safe bet.
108 */
109static int
110iso_get_ssector(dev, p)
111 dev_t dev;
112 struct proc *p;
102{
113{
114 struct ioc_toc_header h;
115 struct ioc_read_toc_single_entry t;
116 int i;
117 struct bdevsw *bd;
118 d_ioctl_t *ioctlp;
119
120 bd = bdevsw[major(dev)];
121 ioctlp = bd->d_ioctl;
122 if (ioctlp == NULL)
123 return 0;
124
125 if (ioctlp(dev, CDIOREADTOCHEADER, (caddr_t)&h, FREAD, p) == -1)
126 return 0;
127
128 for (i = h.ending_track; i >= 0; i--) {
129 t.address_format = CD_LBA_FORMAT;
130 t.track = i;
131 if (ioctlp(dev, CDIOREADTOCENTRY, (caddr_t)&t, FREAD, p) == -1)
132 return 0;
133 if ((t.entry.control & 4) != 0)
134 /* found a data track */
135 break;
136 }
137
138 if (i < 0)
139 return 0;
140
141 return ntohl(t.entry.addr.lba);
142}
143
144static int
145iso_mountroot(mp, p)
103 struct mount *mp;
146 struct mount *mp;
104 struct proc *p = curproc; /* XXX */
147 struct proc *p;
148{
105 struct iso_args args;
106 int error;
149 struct iso_args args;
150 int error;
107
151
108 /*
109 * Get vnode for rootdev.
110 */
111 if ((error = bdevvp(swapdev, &swapdev_vp)) ||
112 (error = bdevvp(rootdev, &rootvp))) {
152 /*
153 * Get vnode for rootdev.
154 */
155 if ((error = bdevvp(swapdev, &swapdev_vp)) ||
156 (error = bdevvp(rootdev, &rootvp))) {
113 printf("cd9660_mountroot: can't setup bdevvp's");
157 printf("iso_mountroot: can't setup bdevvp's");
114 return (error);
115 }
116
158 return (error);
159 }
160
117 if (error = vfs_rootmountalloc("cd9660", "root_device", &mp))
118 return (error);
119 args.flags = ISOFSMNT_ROOT;
161 args.flags = ISOFSMNT_ROOT;
120 if (error = iso_mountfs(rootvp, mp, p, &args)) {
121 mp->mnt_vfc->vfc_refcount--;
122 vfs_unbusy(mp, p);
123 free(mp, M_MOUNT);
162 args.ssector = iso_get_ssector(rootdev, p);
163 if (bootverbose)
164 printf("iso_mountroot(): using session at block %d\n",
165 args.ssector);
166 if (error = iso_mountfs(rootvp, mp, p, &args))
124 return (error);
167 return (error);
125 }
126 simple_lock(&mountlist_slock);
127 CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
128 simple_unlock(&mountlist_slock);
168
129 (void)cd9660_statfs(mp, &mp->mnt_stat, p);
169 (void)cd9660_statfs(mp, &mp->mnt_stat, p);
130 vfs_unbusy(mp, p);
131 return (0);
132}
133
134/*
135 * VFS Operations.
136 *
137 * mount system call
138 */

--- 6 unchanged lines hidden (view full) ---

145 struct proc *p;
146{
147 struct vnode *devvp;
148 struct iso_args args;
149 u_int size;
150 int error;
151 struct iso_mnt *imp = 0;
152
170 return (0);
171}
172
173/*
174 * VFS Operations.
175 *
176 * mount system call
177 */

--- 6 unchanged lines hidden (view full) ---

184 struct proc *p;
185{
186 struct vnode *devvp;
187 struct iso_args args;
188 u_int size;
189 int error;
190 struct iso_mnt *imp = 0;
191
192 if ((mp->mnt_flag & MNT_ROOTFS) != 0)
193 return (iso_mountroot(mp, p));
194
153 if ((error = copyin(data, (caddr_t)&args, sizeof (struct iso_args))))
154 return (error);
155
156 if ((mp->mnt_flag & MNT_RDONLY) == 0)
157 return (EROFS);
158
159 /*
160 * If updating, check whether changing from read-only to

--- 669 unchanged lines hidden ---
195 if ((error = copyin(data, (caddr_t)&args, sizeof (struct iso_args))))
196 return (error);
197
198 if ((mp->mnt_flag & MNT_RDONLY) == 0)
199 return (EROFS);
200
201 /*
202 * If updating, check whether changing from read-only to

--- 669 unchanged lines hidden ---