Mailing List Archive

Add a new /proc/xen file called 'capabilities'. Currently, when read in dom0 it will return 'control_d', and be empty when read in a guest. This provides a convenient way to allow the root user to detect whether they're running in a guest or dom0, and e.g
# HG changeset patch
# User iap10@freefall.cl.cam.ac.uk
# Node ID 06c3b8e194d7085693af4af75eea0187be6bf984
# Parent 82f61375cd742d3e944b319f63a7b1e87797c2d6

Add a new /proc/xen file called 'capabilities'. Currently, when read in dom0 it will return 'control_d', and be empty when read in a guest. This provides a convenient way to allow the root user to detect whether they're running in a guest or dom0, and e.g. gate whether to start xend. In future, when we add more fine grained capabilities we will add other details into this file.

Signed-off-by: ian@xensource.com

diff -r 82f61375cd74 -r 06c3b8e194d7 linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Thu Dec 1 01:36:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c Thu Dec 1 01:43:04 2005
@@ -33,6 +33,7 @@
#include <asm-xen/xen_proc.h>

static struct proc_dir_entry *privcmd_intf;
+static struct proc_dir_entry *capabilities_intf;

static int privcmd_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long data)
@@ -234,12 +235,28 @@
.mmap = privcmd_mmap,
};

+static int capabilities_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ int len = 0;
+ *page = 0;
+
+ if (xen_start_info->flags & SIF_INITDOMAIN)
+ len = sprintf( page, "control_d\n" );
+
+ *eof = 1;
+ return len;
+}

static int __init privcmd_init(void)
{
privcmd_intf = create_xen_proc_entry("privcmd", 0400);
if (privcmd_intf != NULL)
privcmd_intf->proc_fops = &privcmd_file_ops;
+
+ capabilities_intf = create_xen_proc_entry("capabilities", 0400 );
+ if (capabilities_intf != NULL)
+ capabilities_intf->read_proc = capabilities_read;

return 0;
}

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog