svn commit: r257004 - in projects/vps/sys: kern vps
Will Andrews
will at FreeBSD.org
Wed Oct 23 18:36:07 UTC 2013
Author: will
Date: Wed Oct 23 18:36:05 2013
New Revision: 257004
URL: http://svnweb.freebsd.org/changeset/base/257004
Log:
Sync with svn.7he.at/vps/trunk r199.
r199 | klaus | 2013-07-30 04:29:38 -0600 (Tue, 30 Jul 2013) | 3 lines
Showing relative paths for mountpoints in vps.
Submitted by: Klaus P. Ohrhallinger <k at 7he.at>
Modified:
projects/vps/sys/kern/vfs_syscalls.c
projects/vps/sys/vps/vps2.h
projects/vps/sys/vps/vps_priv.c
Modified: projects/vps/sys/kern/vfs_syscalls.c
==============================================================================
--- projects/vps/sys/kern/vfs_syscalls.c Wed Oct 23 18:35:06 2013 (r257003)
+++ projects/vps/sys/kern/vfs_syscalls.c Wed Oct 23 18:36:05 2013 (r257004)
@@ -339,9 +339,18 @@ kern_statfs(struct thread *td, char *pat
error = VFS_STATFS(mp, sp);
if (error)
goto out;
- if (priv_check(td, PRIV_VFS_GENERATION)) {
+#ifdef VPS
+ if (td->td_ucred->cr_vps != vps0) {
bcopy(sp, &sb, sizeof(sb));
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
+ vps_statfs(td->td_ucred, mp, &sb);
+ sp = &sb;
+ }
+#endif
+ if (priv_check(td, PRIV_VFS_GENERATION)) {
+ if (sp != &sb)
+ bcopy(sp, &sb, sizeof(sb));
+ sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
prison_enforce_statfs(td->td_ucred, mp, &sb);
sp = &sb;
}
@@ -423,9 +432,18 @@ kern_fstatfs(struct thread *td, int fd,
error = VFS_STATFS(mp, sp);
if (error)
goto out;
- if (priv_check(td, PRIV_VFS_GENERATION)) {
+#ifdef VPS
+ if (td->td_ucred->cr_vps != vps0) {
bcopy(sp, &sb, sizeof(sb));
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
+ vps_statfs(td->td_ucred, mp, &sb);
+ sp = &sb;
+ }
+#endif
+ if (priv_check(td, PRIV_VFS_GENERATION)) {
+ if (sp != &sb)
+ bcopy(sp, &sb, sizeof(sb));
+ sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
prison_enforce_statfs(td->td_ucred, mp, &sb);
sp = &sb;
}
@@ -536,9 +554,18 @@ kern_getfsstat(struct thread *td, struct
vfs_unbusy(mp);
continue;
}
- if (priv_check(td, PRIV_VFS_GENERATION)) {
+#ifdef VPS
+ if (td->td_ucred->cr_vps != vps0) {
bcopy(sp, &sb, sizeof(sb));
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
+ vps_statfs(td->td_ucred, mp, &sb);
+ sp = &sb;
+ }
+#endif
+ if (priv_check(td, PRIV_VFS_GENERATION)) {
+ if (sp != &sb)
+ bcopy(sp, &sb, sizeof(sb));
+ sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
prison_enforce_statfs(td->td_ucred, mp, &sb);
sp = &sb;
}
Modified: projects/vps/sys/vps/vps2.h
==============================================================================
--- projects/vps/sys/vps/vps2.h Wed Oct 23 18:35:06 2013 (r257003)
+++ projects/vps/sys/vps/vps2.h Wed Oct 23 18:36:05 2013 (r257004)
@@ -162,7 +162,6 @@ int vps_free_locked(struct vps *);
int vps_destroy(struct vps *);
void vps_ref(struct vps *, struct ucred *);
void vps_deref(struct vps *, struct ucred *);
-int vps_canseemount(struct ucred *, struct mount *);
int vps_devfs_ruleset_create(struct vps *vps);
int vps_devfs_ruleset_destroy(struct vps *vps);
@@ -219,6 +218,9 @@ int vps_ioc_getconsfd(struct vps *, stru
struct in_addr;
struct in6_addr;
struct vps_arg_item;
+struct ucred;
+struct mount;
+struct statfs;
void vps_priv_setdefault(struct vps *, struct vps_param *);
int vps_priv_setitem(struct vps *, struct vps *, struct vps_arg_item *);
@@ -228,6 +230,8 @@ int vps_ip_getitemall(struct vps *, stru
int vps_priv_check(struct ucred *, int);
int vps_ip4_check(struct vps *, struct in_addr *, struct in_addr *);
int vps_ip6_check(struct vps *, struct in6_addr *, u_int8_t);
+int vps_canseemount(struct ucred *, struct mount *);
+void vps_statfs(struct ucred *cred, struct mount *mp, struct statfs *sp);
int vps_console_fdopen(struct cdev *, int, struct thread *, struct file *);
int vps_console_init(void);
Modified: projects/vps/sys/vps/vps_priv.c
==============================================================================
--- projects/vps/sys/vps/vps_priv.c Wed Oct 23 18:35:06 2013 (r257003)
+++ projects/vps/sys/vps/vps_priv.c Wed Oct 23 18:36:05 2013 (r257004)
@@ -550,6 +550,37 @@ out:
return (error);
}
+void
+vps_statfs(struct ucred *cred, struct mount *mp, struct statfs *sp)
+{
+ char buf[MAXPATHLEN];
+ struct vps *vps;
+ int len;
+
+ vps = cred->cr_vps;
+
+ if (vps == vps0)
+ return;
+
+ if (vps->_rootpath[0] == 0)
+ return;
+
+ memcpy(buf, sp->f_mntonname, sizeof(buf));
+ bzero(sp->f_mntonname, sizeof(sp->f_mntonname));
+ len = sizeof(buf) - strlen(vps->_rootpath);
+ if (len > sizeof(sp->f_mntonname))
+ len = sizeof(sp->f_mntonname);
+ memcpy(sp->f_mntonname, buf + strlen(vps->_rootpath), len);
+ sp->f_mntonname[sizeof(sp->f_mntonname) - 1] = '\0';
+
+ if (sp->f_mntonname[0] == '\0')
+ /* This is the case where for the root fs. */
+ strcpy(sp->f_mntonname, "/");
+
+ DBGCORE("%s: vps=%p [%s] --> [%s]\n",
+ __func__, vps, buf, sp->f_mntonname);
+}
+
int
vps_priv_setitem(struct vps *vpsp, struct vps *vps,
struct vps_arg_item *item)
More information about the svn-src-projects
mailing list