|
Lines 123-138
Link Here
|
| 123 |
bcopy(argp->ul, pmp->pm_ul, sizeof(pmp->pm_ul)); |
123 |
bcopy(argp->ul, pmp->pm_ul, sizeof(pmp->pm_ul)); |
| 124 |
bcopy(argp->lu, pmp->pm_lu, sizeof(pmp->pm_lu)); |
124 |
bcopy(argp->lu, pmp->pm_lu, sizeof(pmp->pm_lu)); |
| 125 |
} |
125 |
} |
| 126 |
|
126 |
|
| 127 |
#ifndef __FreeBSD__ |
|
|
| 128 |
/* |
| 129 |
* GEMDOS knows nothing (yet) about win95 |
| 130 |
*/ |
| 131 |
if (pmp->pm_flags & MSDOSFSMNT_GEMDOSFS) |
| 132 |
pmp->pm_flags |= MSDOSFSMNT_NOWIN95; |
| 133 |
#endif |
| 134 |
|
| 135 |
if (pmp->pm_flags & MSDOSFSMNT_NOWIN95) |
127 |
if (pmp->pm_flags & MSDOSFSMNT_NOWIN95) |
| 136 |
pmp->pm_flags |= MSDOSFSMNT_SHORTNAME; |
128 |
pmp->pm_flags |= MSDOSFSMNT_SHORTNAME; |
| 137 |
else if (!(pmp->pm_flags & |
129 |
else if (!(pmp->pm_flags & |
| 138 |
(MSDOSFSMNT_SHORTNAME | MSDOSFSMNT_LONGNAME))) { |
130 |
(MSDOSFSMNT_SHORTNAME | MSDOSFSMNT_LONGNAME))) { |
|
Lines 154-222
Link Here
|
| 154 |
} |
146 |
} |
| 155 |
return 0; |
147 |
return 0; |
| 156 |
} |
148 |
} |
| 157 |
|
149 |
|
| 158 |
#ifndef __FreeBSD__ |
|
|
| 159 |
int |
| 160 |
msdosfs_mountroot() |
| 161 |
{ |
| 162 |
register struct mount *mp; |
| 163 |
struct proc *p = curproc; /* XXX */ |
| 164 |
size_t size; |
| 165 |
int error; |
| 166 |
struct msdosfs_args args; |
| 167 |
|
| 168 |
if (root_device->dv_class != DV_DISK) |
| 169 |
return (ENODEV); |
| 170 |
|
| 171 |
/* |
| 172 |
* Get vnodes for swapdev and rootdev. |
| 173 |
*/ |
| 174 |
if (bdevvp(rootdev, &rootvp)) |
| 175 |
panic("msdosfs_mountroot: can't setup rootvp"); |
| 176 |
|
| 177 |
mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK); |
| 178 |
bzero((char *)mp, (u_long)sizeof(struct mount)); |
| 179 |
mp->mnt_op = &msdosfs_vfsops; |
| 180 |
mp->mnt_flag = 0; |
| 181 |
LIST_INIT(&mp->mnt_vnodelist); |
| 182 |
|
| 183 |
args.flags = 0; |
| 184 |
args.uid = 0; |
| 185 |
args.gid = 0; |
| 186 |
args.mask = 0777; |
| 187 |
|
| 188 |
if ((error = mountmsdosfs(rootvp, mp, p, &args)) != 0) { |
| 189 |
free(mp, M_MOUNT); |
| 190 |
return (error); |
| 191 |
} |
| 192 |
|
| 193 |
if ((error = update_mp(mp, &args)) != 0) { |
| 194 |
(void)msdosfs_unmount(mp, 0, p); |
| 195 |
free(mp, M_MOUNT); |
| 196 |
return (error); |
| 197 |
} |
| 198 |
|
| 199 |
if ((error = vfs_lock(mp)) != 0) { |
| 200 |
(void)msdosfs_unmount(mp, 0, p); |
| 201 |
free(mp, M_MOUNT); |
| 202 |
return (error); |
| 203 |
} |
| 204 |
|
| 205 |
TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); |
| 206 |
mp->mnt_vnodecovered = NULLVP; |
| 207 |
(void) copystr("/", mp->mnt_stat.f_mntonname, MNAMELEN - 1, |
| 208 |
&size); |
| 209 |
bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); |
| 210 |
(void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, |
| 211 |
&size); |
| 212 |
bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); |
| 213 |
(void)msdosfs_statfs(mp, &mp->mnt_stat, p); |
| 214 |
vfs_unlock(mp); |
| 215 |
return (0); |
| 216 |
} |
| 217 |
#endif |
| 218 |
|
| 219 |
/* |
150 |
/* |
| 220 |
* mp - path - addr in user space of mount point (ie /usr or whatever) |
151 |
* mp - path - addr in user space of mount point (ie /usr or whatever) |
| 221 |
* data - addr in user space of mount params including the name of the block |
152 |
* data - addr in user space of mount params including the name of the block |
| 222 |
* special file to treat as a filesystem. |
153 |
* special file to treat as a filesystem. |
|
Lines 236-243
Link Here
|
| 236 |
size_t size; |
167 |
size_t size; |
| 237 |
int error, flags; |
168 |
int error, flags; |
| 238 |
mode_t accessmode; |
169 |
mode_t accessmode; |
| 239 |
|
170 |
|
|
|
171 |
/* Check to see if we are mounting root */ |
| 172 |
if (mp->mnt_flag & MNT_ROOTFS) |
| 173 |
panic("msdosfs_mount: root support yanked"); |
| 174 |
|
| 240 |
error = copyin(data, (caddr_t)&args, sizeof(struct msdosfs_args)); |
175 |
error = copyin(data, (caddr_t)&args, sizeof(struct msdosfs_args)); |
| 241 |
if (error) |
176 |
if (error) |
| 242 |
return (error); |
177 |
return (error); |
| 243 |
if (args.magic != MSDOSFS_ARGSMAGIC) |
178 |
if (args.magic != MSDOSFS_ARGSMAGIC) |
|
Lines 261-272
Link Here
|
| 261 |
if (error) |
196 |
if (error) |
| 262 |
return (error); |
197 |
return (error); |
| 263 |
if ((pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_kern_flag & MNTK_WANTRDWR)) { |
198 |
if ((pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_kern_flag & MNTK_WANTRDWR)) { |
| 264 |
/* |
199 |
/* |
| 265 |
* If upgrade to read-write by non-root, then verify |
200 |
* If upgrade to read-write by regular user, then verify |
| 266 |
* that user has necessary permissions on the device. |
201 |
* that user has necessary permissions on the device. |
| 267 |
*/ |
202 |
*/ |
| 268 |
if (p->p_ucred->cr_uid != 0) { |
203 |
if (suser(p)) { |
| 269 |
devvp = pmp->pm_devvp; |
204 |
devvp = pmp->pm_devvp; |
| 270 |
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); |
205 |
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); |
| 271 |
error = VOP_ACCESS(devvp, VREAD | VWRITE, |
206 |
error = VOP_ACCESS(devvp, VREAD | VWRITE, |
| 272 |
p->p_ucred, p); |
207 |
p->p_ucred, p); |
|
Lines 278-286
Link Here
|
| 278 |
} |
213 |
} |
| 279 |
pmp->pm_flags &= ~MSDOSFSMNT_RONLY; |
214 |
pmp->pm_flags &= ~MSDOSFSMNT_RONLY; |
| 280 |
} |
215 |
} |
| 281 |
if (args.fspec == 0) { |
216 |
if (args.fspec == 0) { |
| 282 |
#ifdef __notyet__ /* doesn't work correctly with current mountd XXX */ |
217 |
#ifdef __notyet__ /* doesn't work correctly with current mountd XXX */ |
| 283 |
if (args.flags & MSDOSFSMNT_MNTOPT) { |
218 |
if (args.flags & MSDOSFSMNT_MNTOPT) { |
| 284 |
pmp->pm_flags &= ~MSDOSFSMNT_MNTOPT; |
219 |
pmp->pm_flags &= ~MSDOSFSMNT_MNTOPT; |
| 285 |
pmp->pm_flags |= args.flags & MSDOSFSMNT_MNTOPT; |
220 |
pmp->pm_flags |= args.flags & MSDOSFSMNT_MNTOPT; |
| 286 |
if (pmp->pm_flags & MSDOSFSMNT_NOWIN95) |
221 |
if (pmp->pm_flags & MSDOSFSMNT_NOWIN95) |
|
Lines 311-319
Link Here
|
| 311 |
/* |
246 |
/* |
| 312 |
* If mount by non-root, then verify that user has necessary |
247 |
* If mount by non-root, then verify that user has necessary |
| 313 |
* permissions on the device. |
248 |
* permissions on the device. |
| 314 |
*/ |
249 |
*/ |
| 315 |
if (p->p_ucred->cr_uid != 0) { |
250 |
if (suser(p)) { |
| 316 |
accessmode = VREAD; |
251 |
accessmode = VREAD; |
| 317 |
if ((mp->mnt_flag & MNT_RDONLY) == 0) |
252 |
if ((mp->mnt_flag & MNT_RDONLY) == 0) |
| 318 |
accessmode |= VWRITE; |
253 |
accessmode |= VWRITE; |
| 319 |
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); |
254 |
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); |
|
Lines 367-378
Link Here
|
| 367 |
{ |
302 |
{ |
| 368 |
struct msdosfsmount *pmp; |
303 |
struct msdosfsmount *pmp; |
| 369 |
struct buf *bp; |
304 |
struct buf *bp; |
| 370 |
dev_t dev = devvp->v_rdev; |
305 |
dev_t dev = devvp->v_rdev; |
| 371 |
#ifndef __FreeBSD__ |
|
|
| 372 |
struct partinfo dpart; |
| 373 |
int bsize = 0, dtype = 0, tmp; |
| 374 |
#endif |
| 375 |
union bootsector *bsp; |
306 |
union bootsector *bsp; |
| 376 |
struct byte_bpb33 *b33; |
307 |
struct byte_bpb33 *b33; |
| 377 |
struct byte_bpb50 *b50; |
308 |
struct byte_bpb50 *b50; |
| 378 |
struct byte_bpb710 *b710; |
309 |
struct byte_bpb710 *b710; |
|
Lines 406-439
Link Here
|
| 406 |
|
337 |
|
| 407 |
bp = NULL; /* both used in error_exit */ |
338 |
bp = NULL; /* both used in error_exit */ |
| 408 |
pmp = NULL; |
339 |
pmp = NULL; |
| 409 |
|
340 |
|
| 410 |
#ifndef __FreeBSD__ |
|
|
| 411 |
if (argp->flags & MSDOSFSMNT_GEMDOSFS) { |
| 412 |
/* |
| 413 |
* We need the disklabel to calculate the size of a FAT entry |
| 414 |
* later on. Also make sure the partition contains a filesystem |
| 415 |
* of type FS_MSDOS. This doesn't work for floppies, so we have |
| 416 |
* to check for them too. |
| 417 |
* |
| 418 |
* At least some parts of the msdos fs driver seem to assume |
| 419 |
* that the size of a disk block will always be 512 bytes. |
| 420 |
* Let's check it... |
| 421 |
*/ |
| 422 |
error = VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, |
| 423 |
FREAD, NOCRED, p); |
| 424 |
if (error) |
| 425 |
goto error_exit; |
| 426 |
tmp = dpart.part->p_fstype; |
| 427 |
dtype = dpart.disklab->d_type; |
| 428 |
bsize = dpart.disklab->d_secsize; |
| 429 |
if (bsize != 512 || (dtype!=DTYPE_FLOPPY && tmp!=FS_MSDOS)) { |
| 430 |
error = EINVAL; |
| 431 |
goto error_exit; |
| 432 |
} |
| 433 |
} |
| 434 |
#endif |
| 435 |
|
| 436 |
/* |
341 |
/* |
| 437 |
* Read the boot sector of the filesystem, and then check the |
342 |
* Read the boot sector of the filesystem, and then check the |
| 438 |
* boot signature. If not a dos boot sector then error out. |
343 |
* boot signature. If not a dos boot sector then error out. |
| 439 |
* |
344 |
* |
|
Lines 447-465
Link Here
|
| 447 |
b33 = (struct byte_bpb33 *)bsp->bs33.bsBPB; |
352 |
b33 = (struct byte_bpb33 *)bsp->bs33.bsBPB; |
| 448 |
b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB; |
353 |
b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB; |
| 449 |
b710 = (struct byte_bpb710 *)bsp->bs710.bsPBP; |
354 |
b710 = (struct byte_bpb710 *)bsp->bs710.bsPBP; |
| 450 |
|
355 |
|
| 451 |
#ifndef __FreeBSD__ |
|
|
| 452 |
if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) { |
| 453 |
#endif |
| 454 |
#ifndef MSDOSFS_NOCHECKSIG |
356 |
#ifndef MSDOSFS_NOCHECKSIG |
| 455 |
if (bsp->bs50.bsBootSectSig0 != BOOTSIG0 |
357 |
if (bsp->bs50.bsBootSectSig0 != BOOTSIG0 |
| 456 |
|| bsp->bs50.bsBootSectSig1 != BOOTSIG1) { |
358 |
|| bsp->bs50.bsBootSectSig1 != BOOTSIG1) { |
| 457 |
error = EINVAL; |
359 |
error = EINVAL; |
| 458 |
goto error_exit; |
360 |
goto error_exit; |
| 459 |
} |
|
|
| 460 |
#endif |
| 461 |
#ifndef __FreeBSD__ |
| 462 |
} |
361 |
} |
| 463 |
#endif |
362 |
#endif |
| 464 |
|
363 |
|
| 465 |
pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK); |
364 |
pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK); |
|
Lines 484-508
Link Here
|
| 484 |
|
383 |
|
| 485 |
/* calculate the ratio of sector size to DEV_BSIZE */ |
384 |
/* calculate the ratio of sector size to DEV_BSIZE */ |
| 486 |
pmp->pm_BlkPerSec = pmp->pm_BytesPerSec / DEV_BSIZE; |
385 |
pmp->pm_BlkPerSec = pmp->pm_BytesPerSec / DEV_BSIZE; |
| 487 |
|
386 |
|
| 488 |
#ifndef __FreeBSD__ |
387 |
/* XXX - We should probably check more values here */ |
| 489 |
if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) { |
388 |
if (!pmp->pm_BytesPerSec || !SecPerClust |
| 490 |
#endif |
389 |
|| !pmp->pm_Heads || pmp->pm_Heads > 255 |
| 491 |
/* XXX - We should probably check more values here */ |
|
|
| 492 |
if (!pmp->pm_BytesPerSec || !SecPerClust |
| 493 |
|| !pmp->pm_Heads || pmp->pm_Heads > 255 |
| 494 |
#ifdef PC98 |
390 |
#ifdef PC98 |
| 495 |
|| !pmp->pm_SecPerTrack || pmp->pm_SecPerTrack > 255) { |
391 |
|| !pmp->pm_SecPerTrack || pmp->pm_SecPerTrack > 255) { |
| 496 |
#else |
392 |
#else |
| 497 |
|| !pmp->pm_SecPerTrack || pmp->pm_SecPerTrack > 63) { |
393 |
|| !pmp->pm_SecPerTrack || pmp->pm_SecPerTrack > 63) { |
| 498 |
#endif |
394 |
#endif |
| 499 |
error = EINVAL; |
395 |
error = EINVAL; |
| 500 |
goto error_exit; |
396 |
goto error_exit; |
| 501 |
} |
|
|
| 502 |
#ifndef __FreeBSD__ |
| 503 |
} |
397 |
} |
| 504 |
#endif |
|
|
| 505 |
|
398 |
|
| 506 |
if (pmp->pm_Sectors == 0) { |
399 |
if (pmp->pm_Sectors == 0) { |
| 507 |
pmp->pm_HiddenSects = getulong(b50->bpbHiddenSecs); |
400 |
pmp->pm_HiddenSects = getulong(b50->bpbHiddenSecs); |
| 508 |
pmp->pm_HugeSectors = getulong(b50->bpbHugeSectors); |
401 |
pmp->pm_HugeSectors = getulong(b50->bpbHugeSectors); |
|
Lines 583-606
Link Here
|
| 583 |
pmp->pm_maxcluster = (pmp->pm_HugeSectors - pmp->pm_firstcluster) / |
476 |
pmp->pm_maxcluster = (pmp->pm_HugeSectors - pmp->pm_firstcluster) / |
| 584 |
SecPerClust + 1; |
477 |
SecPerClust + 1; |
| 585 |
pmp->pm_fatsize = pmp->pm_FATsecs * DEV_BSIZE; /* XXX not used? */ |
478 |
pmp->pm_fatsize = pmp->pm_FATsecs * DEV_BSIZE; /* XXX not used? */ |
| 586 |
|
479 |
|
| 587 |
#ifndef __FreeBSD__ |
|
|
| 588 |
if (argp->flags & MSDOSFSMNT_GEMDOSFS) { |
| 589 |
if ((pmp->pm_maxcluster <= (0xff0 - 2)) |
| 590 |
&& ((dtype == DTYPE_FLOPPY) || ((dtype == DTYPE_VNODE) |
| 591 |
&& ((pmp->pm_Heads == 1) || (pmp->pm_Heads == 2)))) |
| 592 |
) { |
| 593 |
pmp->pm_fatmask = FAT12_MASK; |
| 594 |
pmp->pm_fatmult = 3; |
| 595 |
pmp->pm_fatdiv = 2; |
| 596 |
} else { |
| 597 |
pmp->pm_fatmask = FAT16_MASK; |
| 598 |
pmp->pm_fatmult = 2; |
| 599 |
pmp->pm_fatdiv = 1; |
| 600 |
} |
| 601 |
} else |
| 602 |
#endif |
| 603 |
if (pmp->pm_fatmask == 0) { |
480 |
if (pmp->pm_fatmask == 0) { |
| 604 |
if (pmp->pm_maxcluster |
481 |
if (pmp->pm_maxcluster |
| 605 |
<= ((CLUST_RSRVD - CLUST_FIRST) & FAT12_MASK)) { |
482 |
<= ((CLUST_RSRVD - CLUST_FIRST) & FAT12_MASK)) { |
| 606 |
/* |
483 |
/* |