Deleted Added
full compact
vfs_mountroot.c (231949) vfs_mountroot.c (241896)
1/*-
2 * Copyright (c) 2010 Marcel Moolenaar
3 * Copyright (c) 1999-2004 Poul-Henning Kamp
4 * Copyright (c) 1999 Michael Smith
5 * Copyright (c) 1989, 1993
6 * The Regents of the University of California. All rights reserved.
7 * (c) UNIX System Laboratories, Inc.
8 * All or some portions of this file are derived from material licensed

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

33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 */
37
38#include "opt_rootdevname.h"
39
40#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2010 Marcel Moolenaar
3 * Copyright (c) 1999-2004 Poul-Henning Kamp
4 * Copyright (c) 1999 Michael Smith
5 * Copyright (c) 1989, 1993
6 * The Regents of the University of California. All rights reserved.
7 * (c) UNIX System Laboratories, Inc.
8 * All or some portions of this file are derived from material licensed

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

33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 */
37
38#include "opt_rootdevname.h"
39
40#include <sys/cdefs.h>
41__FBSDID("$FreeBSD: head/sys/kern/vfs_mountroot.c 231949 2012-02-21 01:05:12Z kib $");
41__FBSDID("$FreeBSD: head/sys/kern/vfs_mountroot.c 241896 2012-10-22 17:50:54Z kib $");
42
43#include <sys/param.h>
44#include <sys/conf.h>
45#include <sys/cons.h>
46#include <sys/fcntl.h>
47#include <sys/jail.h>
48#include <sys/kernel.h>
49#include <sys/malloc.h>

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

867
868static int
869vfs_mountroot_readconf(struct thread *td, struct sbuf *sb)
870{
871 static char buf[128];
872 struct nameidata nd;
873 off_t ofs;
874 ssize_t resid;
42
43#include <sys/param.h>
44#include <sys/conf.h>
45#include <sys/cons.h>
46#include <sys/fcntl.h>
47#include <sys/jail.h>
48#include <sys/kernel.h>
49#include <sys/malloc.h>

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

867
868static int
869vfs_mountroot_readconf(struct thread *td, struct sbuf *sb)
870{
871 static char buf[128];
872 struct nameidata nd;
873 off_t ofs;
874 ssize_t resid;
875 int error, flags, len, vfslocked;
875 int error, flags, len;
876
876
877 NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE,
878 "/.mount.conf", td);
877 NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/.mount.conf", td);
879 flags = FREAD;
880 error = vn_open(&nd, &flags, 0, NULL);
881 if (error)
882 return (error);
883
878 flags = FREAD;
879 error = vn_open(&nd, &flags, 0, NULL);
880 if (error)
881 return (error);
882
884 vfslocked = NDHASGIANT(&nd);
885 NDFREE(&nd, NDF_ONLY_PNBUF);
886 ofs = 0;
887 len = sizeof(buf) - 1;
888 while (1) {
889 error = vn_rdwr(UIO_READ, nd.ni_vp, buf, len, ofs,
890 UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred,
891 NOCRED, &resid, td);
892 if (error)
893 break;
894 if (resid == len)
895 break;
896 buf[len - resid] = 0;
897 sbuf_printf(sb, "%s", buf);
898 ofs += len - resid;
899 }
900
901 VOP_UNLOCK(nd.ni_vp, 0);
902 vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
883 NDFREE(&nd, NDF_ONLY_PNBUF);
884 ofs = 0;
885 len = sizeof(buf) - 1;
886 while (1) {
887 error = vn_rdwr(UIO_READ, nd.ni_vp, buf, len, ofs,
888 UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred,
889 NOCRED, &resid, td);
890 if (error)
891 break;
892 if (resid == len)
893 break;
894 buf[len - resid] = 0;
895 sbuf_printf(sb, "%s", buf);
896 ofs += len - resid;
897 }
898
899 VOP_UNLOCK(nd.ni_vp, 0);
900 vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
903 VFS_UNLOCK_GIANT(vfslocked);
904 return (error);
905}
906
907static void
908vfs_mountroot_wait(void)
909{
910 struct root_hold_token *h;
911 struct timeval lastfail;

--- 129 unchanged lines hidden ---
901 return (error);
902}
903
904static void
905vfs_mountroot_wait(void)
906{
907 struct root_hold_token *h;
908 struct timeval lastfail;

--- 129 unchanged lines hidden ---