示例#1
0
PUBLIC	void	test_sp_lookup()

{
  errstat	err;
  capset	new_capset;


  (void)strcpy(testname, "test_sp_lookup()");
  if (verbose)  printf("\n----  %s  ----\n", testname);

  /* Look up an entry with a very long name in the default directory. */
  err = sp_lookup(SP_DEFAULT, long_name, &new_capset);
  if (test_good(err, "1a")) {
    check_capsets("1a", &aux_capset, &new_capset);
    cs_free(&new_capset);
  }

  /* Look up an entry in a regular directory with minimal rights. */
  err = sp_lookup(&rgt_capsets[READ], def_name, &new_capset);
  if (test_good(err, "1b")) {
    check_capsets("1b", &rgt_capsets[DEF], &new_capset);
    cs_free(&new_capset);
  }

}  /* test_sp_lookup() */
示例#2
0
int
get_disk_server_cap()
{
    capability *	tmp;
    SP_DIR *		dd;
    struct sp_direct *	dp;
    capset		dir;
    capset		vd_cap;

    /* Wait until virtual disk is initialized */
    disk_wait();

    /*
     * go through all the directory entries and look for a virtual disk with a
     * valid bullet file system
     */
    if (sp_lookup(SP_DEFAULT, "/", &dir) != STD_OK ||
						(dd = sp_opendir("/")) == 0)
	bpanic("get_disk_server_cap: can't open kernel directory");

    while ((dp = sp_readdir(dd)) != 0)
#ifdef COLDSTART
	if (strncmp(dp->d_name, "vdisk:8", 7) == 0)     /* a virtual ramdisk! */
#else
	if (strncmp(dp->d_name, "vdisk:", 6) == 0)      /* a virtual disk! */
#endif
	{
	    if (sp_lookup(&dir, dp->d_name, &vd_cap) != STD_OK)
		bpanic("Lookup of capability %s failed", dp->d_name);

	    tmp = &vd_cap.cs_suite[0].s_object;
	    /* Read block 0 into Superblock. */
	    if (disk_rw(DS_READ, &tmp->cap_priv, D_PHYS_SHIFT, (disk_addr) 0,
				(disk_addr) 1, (bufptr) &DiskSuper) != STD_OK)
	    {
		bwarn("Bullet Server WARNING: Cannot access %s", dp->d_name);
		continue;
	    }

	    /* If it is a valid superblock it is saved and we can go on */
	    if (valid_superblk(&DiskSuper, &Superblock))
	    {
		message("Valid File System on %s",dp->d_name);
		sp_closedir(dd);
		Diskcap = *tmp;
		return 1;
	    }
	}

    /*
    ** If we get here then none of the directory entries in the kernel had a
    ** valid bullet file system
    */
    sp_closedir(dd);
    bwarn("No valid Bullet File System.");
    return 0;
}
示例#3
0
spkey_t symbol_lookup_db_mem(const void *s, const int slen, struct sptree *spt)
{
	register spkey_t key;
	register struct syment *se;
	struct spblk *spl;

	if (s == NULL)
		return 0;

	key = crc32n(s, slen);

	/* Ok, time for the hard work.  Lets see if we have this key
	   in the symtab splay tree */

	spl = sp_lookup(key, spt);
	if (spl != NULL) {
		/* Got it !  Now see that we really have it, and
		   not only have a hash collision */

		se = (struct syment *)spl->data;
		do {
			if (se->namelen == slen &&
			    memcmp(se->name, s, slen) == 0) {
				/* Really found it! */
				return (spkey_t)se;
			}
			se = se->next;
		} while (se != NULL);
	}
	return 0;
}
示例#4
0
PUBLIC	void	test_sp_discard()
/* This should be the final test because it can mess up the test directory
 * structure severely.
 */

{
  errstat	err;
  bool		ok;
  capset	tmp_capset, disc_capset;


  (void)strcpy(testname, "test_sp_discard()");
  if (verbose)  printf("\n----  %s  ----\n", testname);

  /* Discard an empty directory with minimal rights. */

  /* Create a new directory. */
  err = sp_create(SP_DEFAULT, def_colnames, &tmp_capset);
  if (test_good(err, "1a, sp_create()")) {

    /* Append and look-up to get a restricted capset. */
    err = sp_append(SP_DEFAULT, aux_name, &tmp_capset, 1, rgt_masks[DEL]);
    if (ok = test_good(err, "1a, sp_append()")) {
      err = sp_lookup(SP_DEFAULT, aux_name, &disc_capset);
      if (ok = test_good(err, "1a, sp_lookup()")) {
	/* Try to discard the restricted empty capset. */
        err = sp_discard(&disc_capset);
	ok = test_good(err, "1a");
	/* Free the space for the capset. */
        cs_free(&disc_capset);
      }

      /* Delete the entry for the original capset. */
      err = sp_delete(SP_DEFAULT, aux_name);
      (void)test_good(err, "1a, sp_delete()");
    }

    if (!ok) {
      /* Destroy the directory using the unrestricted capset. */
      err = sp_discard(&tmp_capset);
      (void)test_good(err, "1a, sp_discard()");
    }
    cs_free(&tmp_capset);
  }

}  /* test_sp_discard() */
示例#5
0
spkey_t symbol_db_mem(const void *s, int slen, struct sptree *spt)
{
	register spkey_t key;
	register struct syment *se, *pe;
	struct spblk *spl;

	if (s == NULL)
		return 0;

	key = crc32n(s,slen);

	/* Ok, time for the hard work.  Lets see if we have this key
	   in the symtab splay tree */

	pe = NULL;
	spl = sp_lookup(key, spt);
	if (spl != NULL) {
		/* Got it !  Now see that we really have it, and
		   not only have a hash collision */

		se = (struct syment *)spl->data;
		do {
			if (se->namelen == slen &&
			    memcmp(se->name, s, slen) == 0) {
				/* Really found it! */
				return (spkey_t)se;
			}
			pe = se;
			se = se->next;
		} while (se != NULL);
	}
	se = (struct syment *)hmalloc(sizeof (struct syment) + slen);
	memcpy((void*)se->name, s, slen);
	((char*)se->name)[slen] = 0;
	se->namelen = slen;
	se->next    = NULL;
	if (pe != NULL)
		pe->next = se;
	else {
		spl = sp_install(key, spt);
		spl->data = (void *)se;
	}
	return (spkey_t)se;
}
示例#6
0
void symbol_free_db_mem(const void *s, int slen, struct sptree *spt)
{
	register spkey_t key;
	register struct syment *se, *pe;
	struct spblk *spl;
	
	if (s == NULL || spt == NULL)
		return;
	
	key = crc32n(s, slen);
	
	/* Ok, time for the hard work.  Lets see if we have this key
	   in the symtab splay tree (we can't use cache here!) */
	
	pe = NULL;
	spl = sp_lookup(key, spt);
	if (spl != NULL) {
		/* Got it !  Now see that we really have it, and
		   not only have a hash collision */

		se = (struct syment *)spl->data;
		do {
		  if (se->namelen == slen &&
		      memcmp(se->name, s, slen) == 0) {
		    /* Really found it! */
		    if (pe != NULL)
		      pe->next = se->next;
		    else
		      spl->data = (void*) se->next;
		    hfree(se);
		    break;
		  }
		  pe = se;
		  se = se->next;
		} while (se != NULL);
	}

	if (spl != NULL && spl->data == NULL)
		sp_delete(spl, spt);
}