vfs_mount.c (152217) | vfs_mount.c (152332) |
---|---|
1/*- 2 * Copyright (c) 1999-2004 Poul-Henning Kamp 3 * Copyright (c) 1999 Michael Smith 4 * Copyright (c) 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * (c) UNIX System Laboratories, Inc. 7 * All or some portions of this file are derived from material licensed 8 * to the University of California by American Telephone and Telegraph --- 21 unchanged lines hidden (view full) --- 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1999-2004 Poul-Henning Kamp 3 * Copyright (c) 1999 Michael Smith 4 * Copyright (c) 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * (c) UNIX System Laboratories, Inc. 7 * All or some portions of this file are derived from material licensed 8 * to the University of California by American Telephone and Telegraph --- 21 unchanged lines hidden (view full) --- 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/kern/vfs_mount.c 152217 2005-11-09 02:26:38Z rodrigc $"); | 38__FBSDID("$FreeBSD: head/sys/kern/vfs_mount.c 152332 2005-11-12 14:41:44Z rodrigc $"); |
39 40#include <sys/param.h> 41#include <sys/conf.h> 42#include <sys/jail.h> 43#include <sys/kernel.h> 44#include <sys/libkern.h> 45#include <sys/mac.h> 46#include <sys/malloc.h> --- 313 unchanged lines hidden (view full) --- 360 int flags; 361 } */ *uap; 362{ 363 struct uio *auio; 364 struct iovec *iov; 365 unsigned int i; 366 int error; 367 u_int iovcnt; | 39 40#include <sys/param.h> 41#include <sys/conf.h> 42#include <sys/jail.h> 43#include <sys/kernel.h> 44#include <sys/libkern.h> 45#include <sys/mac.h> 46#include <sys/malloc.h> --- 313 unchanged lines hidden (view full) --- 360 int flags; 361 } */ *uap; 362{ 363 struct uio *auio; 364 struct iovec *iov; 365 unsigned int i; 366 int error; 367 u_int iovcnt; |
368 const char *name; |
|
368 369 /* Kick out MNT_ROOTFS early as it is legal internally */ 370 if (uap->flags & MNT_ROOTFS) 371 return (EINVAL); 372 373 iovcnt = uap->iovcnt; 374 /* 375 * Check that we have an even number of iovec's --- 11 unchanged lines hidden (view full) --- 387 free(auio, M_IOV); 388 return (EINVAL); 389 } 390 iov++; 391 } 392 error = vfs_donmount(td, uap->flags, auio); 393 394 /* copyout the errmsg */ | 369 370 /* Kick out MNT_ROOTFS early as it is legal internally */ 371 if (uap->flags & MNT_ROOTFS) 372 return (EINVAL); 373 374 iovcnt = uap->iovcnt; 375 /* 376 * Check that we have an even number of iovec's --- 11 unchanged lines hidden (view full) --- 388 free(auio, M_IOV); 389 return (EINVAL); 390 } 391 iov++; 392 } 393 error = vfs_donmount(td, uap->flags, auio); 394 395 /* copyout the errmsg */ |
395 for (i = 0; (error != 0) && (i < iovcnt); i += 2) { 396 const char *name = (const char *)auio->uio_iov[i].iov_base; 397 if (!strcmp(name, "errmsg")) { 398 copyout(auio->uio_iov[i+1].iov_base, 399 uap->iovp[i+1].iov_base, uap->iovp[i+1].iov_len); 400 | 396 for (i = 0; error != 0 && i < iovcnt; i += 2) { 397 name = (const char *)auio->uio_iov[i].iov_base; 398 if (strcmp(name, "errmsg") == 0) { 399 copyout(auio->uio_iov[i + 1].iov_base, 400 uap->iovp[i + 1].iov_base, uap->iovp[i + 1].iov_len); |
401 break; 402 } 403 } 404 405 free(auio, M_IOV); 406 return (error); 407} 408 --- 62 unchanged lines hidden (view full) --- 471 crfree(mp->mnt_cred); 472 free(mp, M_MOUNT); 473} 474 475static int 476vfs_donmount(struct thread *td, int fsflags, struct uio *fsoptions) 477{ 478 struct vfsoptlist *optlist; | 401 break; 402 } 403 } 404 405 free(auio, M_IOV); 406 return (error); 407} 408 --- 62 unchanged lines hidden (view full) --- 471 crfree(mp->mnt_cred); 472 free(mp, M_MOUNT); 473} 474 475static int 476vfs_donmount(struct thread *td, int fsflags, struct uio *fsoptions) 477{ 478 struct vfsoptlist *optlist; |
479 struct iovec *iov_errmsg = NULL; | 479 struct iovec *iov_errmsg; |
480 char *fstype, *fspath; | 480 char *fstype, *fspath; |
481 int error, fstypelen, fspathlen; 482 int i; | 481 int error, fstypelen, fspathlen, i; |
483 | 482 |
483 iov_errmsg = NULL; 484 |
|
484 for (i = 0; i < fsoptions->uio_iovcnt; i += 2) { | 485 for (i = 0; i < fsoptions->uio_iovcnt; i += 2) { |
485 if (!strcmp((char *)fsoptions->uio_iov[i].iov_base, "errmsg")) 486 iov_errmsg = &fsoptions->uio_iov[i+1]; | 486 if (strcmp((char *)fsoptions->uio_iov[i].iov_base, "errmsg") == 0) 487 iov_errmsg = &fsoptions->uio_iov[i + 1]; |
487 } 488 489 error = vfs_buildopts(fsoptions, &optlist); 490 if (error) 491 return (error); 492 493 /* 494 * We need these two options before the others, 495 * and they are mandatory for any filesystem. 496 * Ensure they are NUL terminated as well. 497 */ 498 fstypelen = 0; 499 error = vfs_getopt(optlist, "fstype", (void **)&fstype, &fstypelen); 500 if (error || fstype[fstypelen - 1] != '\0') { 501 error = EINVAL; | 488 } 489 490 error = vfs_buildopts(fsoptions, &optlist); 491 if (error) 492 return (error); 493 494 /* 495 * We need these two options before the others, 496 * and they are mandatory for any filesystem. 497 * Ensure they are NUL terminated as well. 498 */ 499 fstypelen = 0; 500 error = vfs_getopt(optlist, "fstype", (void **)&fstype, &fstypelen); 501 if (error || fstype[fstypelen - 1] != '\0') { 502 error = EINVAL; |
502 if (iov_errmsg) | 503 if (iov_errmsg != NULL) |
503 strncpy((char *)iov_errmsg->iov_base, "Invalid fstype", 504 iov_errmsg->iov_len); 505 goto bail; 506 } 507 fspathlen = 0; 508 error = vfs_getopt(optlist, "fspath", (void **)&fspath, &fspathlen); 509 if (error || fspath[fspathlen - 1] != '\0') { 510 error = EINVAL; --- 12 unchanged lines hidden (view full) --- 523 error = ENAMETOOLONG; 524 goto bail; 525 } 526 527 mtx_lock(&Giant); 528 error = vfs_domount(td, fstype, fspath, fsflags, optlist); 529 mtx_unlock(&Giant); 530bail: | 504 strncpy((char *)iov_errmsg->iov_base, "Invalid fstype", 505 iov_errmsg->iov_len); 506 goto bail; 507 } 508 fspathlen = 0; 509 error = vfs_getopt(optlist, "fspath", (void **)&fspath, &fspathlen); 510 if (error || fspath[fspathlen - 1] != '\0') { 511 error = EINVAL; --- 12 unchanged lines hidden (view full) --- 524 error = ENAMETOOLONG; 525 goto bail; 526 } 527 528 mtx_lock(&Giant); 529 error = vfs_domount(td, fstype, fspath, fsflags, optlist); 530 mtx_unlock(&Giant); 531bail: |
531 if (error && iov_errmsg != NULL) { 532 /* save the errmsg */ | 532 if (error != 0 && iov_errmsg != NULL) { 533 /* Save the errmsg so we can return it to userspace. */ |
533 char *errmsg; 534 int len, ret; 535 ret = vfs_getopt(optlist, "errmsg", (void **)&errmsg, &len); | 534 char *errmsg; 535 int len, ret; 536 ret = vfs_getopt(optlist, "errmsg", (void **)&errmsg, &len); |
536 if(ret == 0 && len > 0) | 537 if (ret == 0 && len > 0) |
537 strncpy((char *)iov_errmsg->iov_base, errmsg, 538 iov_errmsg->iov_len); 539 540 } 541 | 538 strncpy((char *)iov_errmsg->iov_base, errmsg, 539 iov_errmsg->iov_len); 540 541 } 542 |
542 if (error) | 543 if (error != 0) |
543 vfs_freeopts(optlist); 544 return (error); 545} 546 547/* 548 * --------------------------------------------------------------------- 549 * Old mount API. 550 */ --- 1275 unchanged lines hidden --- | 544 vfs_freeopts(optlist); 545 return (error); 546} 547 548/* 549 * --------------------------------------------------------------------- 550 * Old mount API. 551 */ --- 1275 unchanged lines hidden --- |