ia64/xen-unstable

changeset 8150:06c3b8e194d7

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
author iap10@freefall.cl.cam.ac.uk
date Thu Dec 01 02:43:04 2005 +0100 (2005-12-01)
parents 82f61375cd74
children 6bc8ceab6dff
files linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Thu Dec 01 02:36:46 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Thu Dec 01 02:43:04 2005 +0100
     1.3 @@ -33,6 +33,7 @@
     1.4  #include <asm-xen/xen_proc.h>
     1.5  
     1.6  static struct proc_dir_entry *privcmd_intf;
     1.7 +static struct proc_dir_entry *capabilities_intf;
     1.8  
     1.9  static int privcmd_ioctl(struct inode *inode, struct file *file,
    1.10                           unsigned int cmd, unsigned long data)
    1.11 @@ -234,6 +235,18 @@ static struct file_operations privcmd_fi
    1.12  	.mmap  = privcmd_mmap,
    1.13  };
    1.14  
    1.15 +static int capabilities_read(char *page, char **start, off_t off,
    1.16 +                        int count, int *eof, void *data)
    1.17 +{
    1.18 +	int len = 0;
    1.19 +	*page = 0;
    1.20 +
    1.21 +	if (xen_start_info->flags & SIF_INITDOMAIN)
    1.22 +		len = sprintf( page, "control_d\n" );
    1.23 +
    1.24 +	*eof = 1;
    1.25 +	return len;
    1.26 +}
    1.27  
    1.28  static int __init privcmd_init(void)
    1.29  {
    1.30 @@ -241,6 +254,10 @@ static int __init privcmd_init(void)
    1.31  	if (privcmd_intf != NULL)
    1.32  		privcmd_intf->proc_fops = &privcmd_file_ops;
    1.33  
    1.34 +	capabilities_intf = create_xen_proc_entry("capabilities", 0400 );
    1.35 +	if (capabilities_intf != NULL)
    1.36 +		capabilities_intf->read_proc = capabilities_read;
    1.37 +
    1.38  	return 0;
    1.39  }
    1.40