Example #1
0
extern int
dm_pending(
	dm_sessid_t	sid,
	dm_token_t	token,
	dm_timestruct_t	*delay)
{
	return dmi(DM_PENDING, sid, token, delay);
}
Example #2
0
extern int
dm_move_event(
	dm_sessid_t	srcsid,
	dm_token_t	token,
	dm_sessid_t	targetsid,
	dm_token_t	*rtokenp)
{
	return dmi(DM_MOVE_EVENT, srcsid, token, targetsid, rtokenp);
}
Example #3
0
extern int
dm_getall_disp(
	dm_sessid_t	sid,
	size_t		buflen,
	void		*bufp,
	size_t		*rlenp)
{
	return dmi(DM_GETALL_DISP, sid, buflen, bufp, rlenp);
}
Example #4
0
extern int
dm_send_msg(
	dm_sessid_t	targetsid,
	dm_msgtype_t	msgtype,
	size_t		buflen,
	void		*bufp)
{
	return dmi(DM_SEND_MSG, targetsid, msgtype, buflen, bufp);
}
Example #5
0
extern int
dm_create_userevent(
	dm_sessid_t	sid,
	size_t		msglen,
	void		*msgdatap,
	dm_token_t	*tokenp)
{
	return dmi(DM_CREATE_USEREVENT, sid, msglen, msgdatap, tokenp);
}
Example #6
0
extern int
dm_clear_inherit(
	dm_sessid_t	sid,
	void		*hanp,
	size_t		hlen,
	dm_token_t	token,
	dm_attrname_t	*attrnamep)
{
	return dmi(DM_CLEAR_INHERIT, sid, hanp, hlen, token, attrnamep);
}
Example #7
0
extern int
dm_set_disp(
	dm_sessid_t	sid,
	void		*hanp,
	size_t		hlen,
	dm_token_t	token,
	dm_eventset_t	*eventsetp,
	u_int		maxevent)
{
	return dmi(DM_SET_DISP, sid, hanp, hlen, token, eventsetp, maxevent);
}
Example #8
0
extern int
dm_set_inherit(
	dm_sessid_t	sid,
	void		*hanp,
	size_t		hlen,
	dm_token_t	token,
	dm_attrname_t	*attrnamep,
	mode_t		mode)
{
	return dmi(DM_SET_INHERIT, sid, hanp, hlen, token, attrnamep, mode);
}
Example #9
0
extern int
dm_get_events(
	dm_sessid_t	sid,
	u_int		maxmsgs,
	u_int		flags,
	size_t		buflen,
	void		*bufp,
	size_t		*rlenp)
{
	return dmi(DM_GET_EVENTS, sid, maxmsgs, flags, buflen, bufp, rlenp);
}
Example #10
0
extern int
dm_set_eventlist(
	dm_sessid_t	sid,
	void		*hanp,
	size_t		hlen,
	dm_token_t	token,
	dm_eventset_t	*eventsetp,
	u_int		maxevent)
{
	return dmi(DM_SET_EVENTLIST, sid, hanp, hlen, token,
			eventsetp, maxevent);
}
Example #11
0
extern int
dm_respond_event(
	dm_sessid_t	sid,
	dm_token_t	token,
	dm_response_t	response,
	int		reterror,
	size_t		buflen,
	void		*respbufp)
{
	return dmi(DM_RESPOND_EVENT, sid, token, response, reterror,
			buflen, respbufp);
}
Example #12
0
extern int
dm_set_return_on_destroy (
	dm_sessid_t	sid,
	void		*hanp,
	size_t		hlen,
	dm_token_t	token,
	dm_attrname_t	*attrnamep,
	dm_boolean_t	enable)
{
	return dmi(DM_SET_RETURN_ON_DESTROY, sid, hanp, hlen, token,
		attrnamep, enable);
}
Example #13
0
extern int
dm_remove_dmattr (
	dm_sessid_t	sid,
	void		*hanp,
	size_t		hlen,
	dm_token_t	token,
	int		setdtime,
	dm_attrname_t	*attrnamep)
{
	return dmi(DM_REMOVE_DMATTR, sid, hanp, hlen, token, setdtime,
		attrnamep);
}
Example #14
0
extern int
dm_get_eventlist(
	dm_sessid_t	sid,
	void		*hanp,
	size_t		hlen,
	dm_token_t	token,
	u_int		nelem,
	dm_eventset_t	*eventsetp,
	u_int		*nelemp)
{
	return dmi(DM_GET_EVENTLIST, sid, hanp, hlen, token, nelem,
			eventsetp, nelemp);
}
Example #15
0
extern int
dm_getall_dmattr (
	dm_sessid_t	sid,
	void		*hanp,
	size_t		hlen,
	dm_token_t	token,
	size_t		buflen,
	void		*bufp,
	size_t		*rlenp)
{
	return dmi(DM_GETALL_DMATTR, sid, hanp, hlen, token, buflen,
		bufp, rlenp);
}
Example #16
0
extern int
dm_getall_inherit(
	dm_sessid_t	sid,
	void		*hanp,
	size_t		hlen,
	dm_token_t	token,
	u_int		nelem,
	dm_inherit_t	*inheritbufp,
	u_int		*nelemp)
{
	return dmi(DM_GETALL_INHERIT, sid, hanp, hlen, token, nelem,
		inheritbufp, nelemp);
}
Example #17
0
extern int
dm_get_mountinfo(
    dm_sessid_t	sid,
    void		*hanp,
    size_t		hlen,
    dm_token_t	token,
    size_t		buflen,
    void		*bufp,
    size_t		*rlenp)
{
    return dmi(DM_GET_MOUNTINFO, sid, hanp, hlen, token, buflen,
               bufp, rlenp);
}
Example #18
0
extern int
dm_set_dmattr (
	dm_sessid_t	sid,
	void		*hanp,
	size_t		hlen,
	dm_token_t	token,
	dm_attrname_t	*attrnamep,
	int		setdtime,
	size_t		buflen,
	void		*bufp)
{
	return dmi(DM_SET_DMATTR, sid, hanp, hlen, token, attrnamep,
		setdtime, buflen, bufp);
}
    void llsdutil_object::test<9>()
    {
        set_test_name("llsd_matches");

        // for this test, construct a map of all possible LLSD types
        LLSD map;
        map.insert("empty",     LLSD());
        map.insert("Boolean",   LLSD::Boolean());
        map.insert("Integer",   LLSD::Integer(0));
        map.insert("Real",      LLSD::Real(0.0));
        map.insert("String",    LLSD::String("bah"));
        map.insert("NumString", LLSD::String("1"));
        map.insert("UUID",      LLSD::UUID());
        map.insert("Date",      LLSD::Date());
        map.insert("URI",       LLSD::URI());
        map.insert("Binary",    LLSD::Binary());
        map.insert("Map",       LLSD().with("foo", LLSD()));
        // Only an empty array can be constructed on the fly
        LLSD array;
        array.append(LLSD());
        map.insert("Array",     array);

        // These iterators are declared outside our various for loops to avoid
        // fatal MSVC warning: "I used to be broken, but I'm all better now!"
        LLSD::map_const_iterator mi, mend(map.endMap());

        /*-------------------------- llsd_matches --------------------------*/

        // empty prototype matches anything
        for (mi = map.beginMap(); mi != mend; ++mi)
        {
            ensure_equals(std::string("empty matches ") + mi->first, llsd_matches(LLSD(), mi->second), "");
        }

        LLSD proto_array, data_array;
        for (int i = 0; i < 3; ++i)
        {
            proto_array.append(LLSD());
            data_array.append(LLSD());
        }

        // prototype array matches only array
        for (mi = map.beginMap(); mi != mend; ++mi)
        {
            ensure(std::string("array doesn't match ") + mi->first,
                   ! llsd_matches(proto_array, mi->second).empty());
        }

        // data array must be at least as long as prototype array
        proto_array.append(LLSD());
        ensure_equals("data array too short", llsd_matches(proto_array, data_array),
                      "Array size 4 required instead of Array size 3");
        data_array.append(LLSD());
        ensure_equals("data array just right", llsd_matches(proto_array, data_array), "");
        data_array.append(LLSD());
        ensure_equals("data array longer", llsd_matches(proto_array, data_array), "");

        // array element matching
        data_array[0] = LLSD::String();
        ensure_equals("undefined prototype array entry", llsd_matches(proto_array, data_array), "");
        proto_array[0] = LLSD::Binary();
        ensure_equals("scalar prototype array entry", llsd_matches(proto_array, data_array),
                      "[0]: Binary required instead of String");
        data_array[0] = LLSD::Binary();
        ensure_equals("matching prototype array entry", llsd_matches(proto_array, data_array), "");

        // build a coupla maps
        LLSD proto_map, data_map;
        data_map["got"] = LLSD();
        data_map["found"] = LLSD();
        for (LLSD::map_const_iterator dmi(data_map.beginMap()), dmend(data_map.endMap());
             dmi != dmend; ++dmi)
        {
            proto_map[dmi->first] = dmi->second;
        }
        proto_map["foo"] = LLSD();
        proto_map["bar"] = LLSD();

        // prototype map matches only map
        for (mi = map.beginMap(); mi != mend; ++mi)
        {
            ensure(std::string("map doesn't match ") + mi->first,
                   ! llsd_matches(proto_map, mi->second).empty());
        }

        // data map must contain all keys in prototype map
        std::string error(llsd_matches(proto_map, data_map));
        ensure_contains("missing keys", error, "missing keys");
        ensure_contains("missing foo", error, "foo");
        ensure_contains("missing bar", error, "bar");
        ensure_does_not_contain("found found", error, "found");
        ensure_does_not_contain("got got", error, "got");
        data_map["bar"] = LLSD();
        error = llsd_matches(proto_map, data_map);
        ensure_contains("missing foo", error, "foo");
        ensure_does_not_contain("got bar", error, "bar");
        data_map["foo"] = LLSD();
        ensure_equals("data map just right", llsd_matches(proto_map, data_map), "");
        data_map["extra"] = LLSD();
        ensure_equals("data map with extra", llsd_matches(proto_map, data_map), "");

        // map element matching
        data_map["foo"] = LLSD::String();
        ensure_equals("undefined prototype map entry", llsd_matches(proto_map, data_map), "");
        proto_map["foo"] = LLSD::Binary();
        ensure_equals("scalar prototype map entry", llsd_matches(proto_map, data_map),
                      "['foo']: Binary required instead of String");
        data_map["foo"] = LLSD::Binary();
        ensure_equals("matching prototype map entry", llsd_matches(proto_map, data_map), "");

        // String
        {
            static const char* matches[] = { "String", "NumString", "Boolean", "Integer",
                                             "Real", "UUID", "Date", "URI" };
            test_matches("String", map, boost::begin(matches), boost::end(matches));
        }

        // Boolean, Integer, Real
        static const char* numerics[] = { "Boolean", "Integer", "Real" };
        for (const char **ni = boost::begin(numerics), **nend = boost::end(numerics);
             ni != nend; ++ni)
        {
            static const char* matches[] = { "Boolean", "Integer", "Real", "String", "NumString" };
            test_matches(*ni, map, boost::begin(matches), boost::end(matches));
        }

        // UUID
        {
            static const char* matches[] = { "UUID", "String", "NumString" };
            test_matches("UUID", map, boost::begin(matches), boost::end(matches));
        }

        // Date
        {
            static const char* matches[] = { "Date", "String", "NumString" };
            test_matches("Date", map, boost::begin(matches), boost::end(matches));
        }

        // URI
        {
            static const char* matches[] = { "URI", "String", "NumString" };
            test_matches("URI", map, boost::begin(matches), boost::end(matches));
        }

        // Binary
        {
            static const char* matches[] = { "Binary" };
            test_matches("Binary", map, boost::begin(matches), boost::end(matches));
        }

        /*-------------------------- llsd_equals ---------------------------*/

        // Cross-product of each LLSD type with every other
        for (LLSD::map_const_iterator lmi(map.beginMap()), lmend(map.endMap());
             lmi != lmend; ++lmi)
        {
            for (LLSD::map_const_iterator rmi(map.beginMap()), rmend(map.endMap());
                 rmi != rmend; ++rmi)
            {
                // Name this test based on the map keys naming the types of
                // interest, e.g "String::Integer".
                // We expect the values (xmi->second) to be equal if and only
                // if the type names (xmi->first) are equal.
                ensure(STRINGIZE(lmi->first << "::" << rmi->first),
                       bool(lmi->first == rmi->first) ==
                       bool(llsd_equals(lmi->second, rmi->second)));
            }
        }

        // Array cases
        LLSD rarray;
        rarray.append(1.0);
        rarray.append(2);
        rarray.append("3");
        LLSD larray(rarray);
        ensure("llsd_equals(equal arrays)", llsd_equals(larray, rarray));
        rarray[2] = "4";
        ensure("llsd_equals(different [2])", ! llsd_equals(larray, rarray));
        rarray = larray;
        rarray.append(LLSD::Date());
        ensure("llsd_equals(longer right array)", ! llsd_equals(larray, rarray));
        rarray = larray;
        rarray.erase(2);
        ensure("llsd_equals(shorter right array)", ! llsd_equals(larray, rarray));

        // Map cases
        LLSD rmap;
        rmap["San Francisco"] = 65;
        rmap["Phoenix"] = 92;
        rmap["Boston"] = 77;
        LLSD lmap(rmap);
        ensure("llsd_equals(equal maps)", llsd_equals(lmap, rmap));
        rmap["Boston"] = 80;
        ensure("llsd_equals(different [\"Boston\"])", ! llsd_equals(lmap, rmap));
        rmap = lmap;
        rmap["Atlanta"] = 95;
        ensure("llsd_equals(superset right map)", ! llsd_equals(lmap, rmap));
        rmap = lmap;
        lmap["Seattle"] = 72;
        ensure("llsd_equals(superset left map)", ! llsd_equals(lmap, rmap));
    }
Example #20
0
int
main(
	int	argc, 
	char	**argv)
{
	dm_sessid_t	old_sid = -1;
	dm_sessid_t	sid;
	void		*hanp;
	size_t	 	 hlen;
	dm_token_t      token = DM_NO_TOKEN;
	int             Vflag = 0;
	char		*name = "old";
	char		*junk = "test junk";
	int		opt;
	int		i;
	int             kernel_status=-1;
	int             library_status=-1L;
	dm_size_t       retval;
	struct stat     stat_buf;

	if (Progname = strrchr(argv[0], '/')) {
		Progname++;
	} else {
		Progname = argv[0];
	}

	/* Crack and validate the command line options. */

	while ((opt = getopt(argc, argv, "v")) != EOF) {
	  switch (opt) {
	  case 'v':
	    Vflag++;
	    break;
	  case '?':
	    usage();
	  }
	}
	if (optind != argc)
	  usage();
	

	if (geteuid()!=0) {
	  printf("You are running as user #%d.  "
		 "You must be root to run this diagnostic.\n", geteuid());
	  exit(1);
	}

	/*--------------------------------
	 * EXAMINE /usr/include/sys/dmi.h:
	 *--------------------------------
	 */
#ifdef __sgi
#define DMAPI_HDR "/usr/include/sys/dmi.h"

	if (stat(DMAPI_HDR, &stat_buf)==-1){
	  if (errno==ENOENT) { 
	    printf( "You are missing a vital DMAPI file: %s\n", DMAPI_HDR);
	  }
	  else {
	    printf( "ERROR: could not stat %s (%s)\n", DMAPI_HDR, strerror(errno));
	  }
	}
	else {
	  if (stat_buf.st_size <= 15000) {
	    printf("You appear to have an old version of a vital DMAPI file: %s\n", DMAPI_HDR);
	  }
	  else if (Vflag) {
	    printf("(You appear to have the correct version of %s\n", DMAPI_HDR);
	  }
	}
#endif
	
	/*--------------------------
	 * RESOLVE KERNEL PRESENCE:
	 *--------------------------
	 */
	if (dmi(CREATE_DESTROY_OPCODE, old_sid, junk, &sid) >= 0) {
	  printf("ERROR: invalid kernel create/destroy_session call "
		 "succeeded!\n");
	  exit(1);
	}
	else if (errno==ENOPKG) {
	  kernel_status=0;
	}
	else if (errno==EINVAL){
	  if (Vflag) printf("(create/destroy_session call verifies "
			    "that you have DMAPI in kernel)\n");
	}
	else {
	  printf("ERROR: kernel create/destroy_session call produced "
		 "unexpected errno, (%d) %s\n", errno, strerror(errno));
	}
	
	/*----------------------------------
	 * RESOLVE KERNEL STATUS IF PRESENT:
	 *----------------------------------
	 */
	if (kernel_status==-1 &&
	    dmi(SET_DISP_OPCODE, 
		(dm_sessid_t) 0, 
		(void*) 0,
		(size_t) 0,
		(dm_token_t) 0,
		(dm_eventset_t) 0,
		(u_int) 0) >= 0) { 
	  printf("ERROR: invalid kernel set_disp call suceeded!\n");
	}
	else {
	  if (errno==ENOSYS) {
	    if (Vflag) 
	      printf("(kernel set_disp call indicates old kernel)\n");
	    kernel_status=1;
	  }
	  else if (errno==ENOPKG) {
	    if (Vflag) 
	      printf("(kernel set_disp call indicates no kernel)\n");
	    kernel_status=0;
	  }
	  else if (errno==EINVAL) {
	    if (Vflag)
	      printf("(kernel set_disp call indicates new kernel)\n");
	    kernel_status=2;
	  }
	  else {
	    printf("ERROR: kernel set_disp call failed: (%d) %s\n", 
		   errno, strerror(errno));
	    exit(1);
	  }
	}

	/*-------------------------
	 * RESOLVE LIBRARY STATUS:
	 *-------------------------
	 */
	if (dm_init_service(&name) == -1)  {
	  fprintf(stderr, "ERROR: can't inititalize the DMAPI (%s).\n",
		  strerror(errno));
	  library_status=0;
	}
	else if (strcmp(name, DM_VER_STR_CONTENTS)) {
	  if (Vflag) 
	    printf("(dm_init_service suggests that "
		   "you have an old library)\n");
	  library_status=1;
	}
	else {
	  if (Vflag) 
	    printf("(dm_init_service suggests that "
		   "you have a new library)\n");
	  library_status=2;
	}
	
	if (Vflag) printf("(dm_init_service returned %s)\n", name);
	
	/*-------------------------
	 * MAKE A DIAGNOSIS:
	 *-------------------------
	 */

	if (library_status==2 && kernel_status==2){
	  printf("DIAGNOSIS: Tests show a current version of "
		 "DMAPI is installed.\n");
	} 
	else if (library_status==1 && kernel_status==1) {
	  printf("DIAGNOSIS: Tests show that you have an outdated "
		 "installation of DMAPI.\nUpgrades to both kernel and "
		 "library routines will be necessary.\n");
	}
	else if (library_status==0 && kernel_status==0) {
	  printf("DIAGNOSIS: Tests show that NO components of the DMAPI "
		 "are installed!\nUpgrades to both kernel and "
		 "library routines will be necessary.\n");
	}
	else {
	  printf("DIAGNOSIS: Tests show that:\n"
		 "Your DMAPI kernel routines are ");
	  switch (kernel_status) {
	  case 0: printf ("missing (not installed).\n");
	     break;
	  case 1: printf ("outdated.\n");
	     break;
	  case 2: printf ("current.\n ");
	     break;
	  default: printf("[ERROR!].\n");
	  }
	  printf("Your DMAPI library is ");
	  switch (library_status) {
	  case 0: printf ("missing (not installed).\n");
	     break;
	  case 1: printf ("outdated.\n");
	     break;
	  case 2: printf ("current.\n");
	     break;
	  default: printf("[ERROR!].\n");
	  }
	}
#ifndef linux
	if (library_status!=2 || kernel_status!=2){
	  printf("Please install XFS patch 1907 (for IRIX 6.2) or "
		 "patch 2287 (for IRIX 6.4).\n");
	}
#endif
}