MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vfs_mountroot_readconf

Function vfs_mountroot_readconf

freebsd/kern/vfs_mountroot.c:939–973  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

937}
938
939static int
940vfs_mountroot_readconf(struct thread *td, struct sbuf *sb)
941{
942 static char buf[128];
943 struct nameidata nd;
944 off_t ofs;
945 ssize_t resid;
946 int error, flags, len;
947
948 NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/.mount.conf", td);
949 flags = FREAD;
950 error = vn_open(&nd, &flags, 0, NULL);
951 if (error)
952 return (error);
953
954 NDFREE(&nd, NDF_ONLY_PNBUF);
955 ofs = 0;
956 len = sizeof(buf) - 1;
957 while (1) {
958 error = vn_rdwr(UIO_READ, nd.ni_vp, buf, len, ofs,
959 UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred,
960 NOCRED, &resid, td);
961 if (error)
962 break;
963 if (resid == len)
964 break;
965 buf[len - resid] = 0;
966 sbuf_printf(sb, "%s", buf);
967 ofs += len - resid;
968 }
969
970 VOP_UNLOCK(nd.ni_vp);
971 vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
972 return (error);
973}
974
975static void
976vfs_mountroot_wait(void)

Callers 1

vfs_mountrootFunction · 0.85

Calls 5

NDFREEFunction · 0.85
sbuf_printfFunction · 0.85
vn_openFunction · 0.70
vn_rdwrFunction · 0.70
vn_closeFunction · 0.70

Tested by

no test coverage detected