Exemplo n.º 1
0
static int
init_conf(void)
{
  Gra2cairoConf = g_malloc(sizeof(*Gra2cairoConf));
  if (Gra2cairoConf == NULL)
    return 1;

  Gra2cairoConf->fontmap = nhash_new();
  if (Gra2cairoConf->fontmap == NULL) {
    g_free(Gra2cairoConf);
    Gra2cairoConf = NULL;
    return 1;
  }

  Gra2cairoConf->fontmap_list_root = NULL;
  Gra2cairoConf->font_num = 0;

  if (loadconfig()) {
    free_fonts(Gra2cairoConf);
    nhash_free(Gra2cairoConf->fontmap);
    g_free(Gra2cairoConf);
    Gra2cairoConf = NULL;
    return 1;
  }

  return 0;
}
Exemplo n.º 2
0
void *
addgra2cairo()
/* addgra2cairoile() returns NULL on error */
{
  int i;

  if (CompatibleFontHash == NULL) {
    CompatibleFontHash = nhash_new();
    if (CompatibleFontHash == NULL) {
      return NULL;
    }
    for (i = 0; i < (int) (sizeof(CompatibleFont) / sizeof(*CompatibleFont)); i++) {
      nhash_set_int(CompatibleFontHash, CompatibleFont[i].old_name, i);
    }
  }

  if (Gra2CairoErrMsgs == NULL) {
    Gra2CairoErrMsgs = g_malloc(sizeof(*Gra2CairoErrMsgs) * CAIRO_STATUS_LAST_STATUS);
    Gra2CairoErrMsgNum = CAIRO_STATUS_LAST_STATUS;

    for (i = 0; i < CAIRO_STATUS_LAST_STATUS; i++) {
      Gra2CairoErrMsgs[i] = g_strdup(cairo_status_to_string(i));
    }
  }

  return addobject(NAME, NULL, PARENT, OVERSION, TBLNUM, gra2cairo, Gra2CairoErrMsgNum, Gra2CairoErrMsgs, NULL, NULL);
}
Exemplo n.º 3
0
void *
addgra2null(void)
/* addgra2null() returns NULL on error */
{
  unsigned int i;

  if (FontDataHash == NULL) {
    FontDataHash = nhash_new();
    if (FontDataHash == NULL) {
      return NULL;
    }
    for (i = 0; i < sizeof(FontData) / sizeof(*FontData); i++) {
      nhash_set_int(FontDataHash, FontData[i].name, i);
    }
  }

  return addobject(NAME,NULL,PARENT,OVERSION,TBLNUM,gra2null,ERRNUM,g2nulerrorlist,NULL,NULL);
}
Exemplo n.º 4
0
int aufs_rmdir(struct inode *dir, struct dentry *dentry)
{
	int err, rmdir_later;
	struct inode *inode, *hidden_dir;
	struct dentry *parent, *wh_dentry, *hidden_dentry, *hidden_parent;
	struct dtime dt;
	aufs_bindex_t bwh, bindex, bstart;
	struct rmdir_whtmp_arg *arg;
	struct aufs_nhash *whlist;

	LKTRTrace("i%lu, %.*s\n", dir->i_ino, DLNPair(dentry));
	IMustLock(dir);
	inode = dentry->d_inode;
	if (unlikely(!inode))
		return -ENOENT; // possible?
	IMustLock(inode);

	whlist = nhash_new(GFP_KERNEL);
	err = PTR_ERR(whlist);
	if (IS_ERR(whlist))
		goto out;

	err = -ENOMEM;
	arg = kmalloc(sizeof(*arg), GFP_KERNEL);
	//arg = NULL;
	if (unlikely(!arg))
		goto out_whlist;

	aufs_read_lock(dentry, AUFS_D_WLOCK);
	parent = dentry->d_parent;
	di_write_lock_parent(parent);
	err = test_empty(dentry, whlist);
	//err = -1;
	if (unlikely(err))
		goto out_arg;

	bstart = dbstart(dentry);
	bwh = dbwh(dentry);
	bindex = -1;
	wh_dentry = lock_hdir_create_wh(dentry, /*isdir*/ 1, &bindex, &dt);
	//wh_dentry = ERR_PTR(-1);
	err = PTR_ERR(wh_dentry);
	if (IS_ERR(wh_dentry))
		goto out_arg;

	hidden_dentry = au_h_dptr(dentry);
	dget(hidden_dentry);
	hidden_parent = hidden_dentry->d_parent;
	hidden_dir = hidden_parent->d_inode;

	rmdir_later = 0;
	if (bindex == bstart) {
		IMustLock(hidden_dir);
		err = renwh_and_rmdir(dentry, bstart, whlist, dir);
		//err = -1;
		if (err > 0) {
			rmdir_later = err;
			err = 0;
		}
	} else {
		DEBUG_ON(!wh_dentry);
		hidden_parent = wh_dentry->d_parent;
		DEBUG_ON(hidden_parent != au_h_dptr_i(parent, bindex));
		hidden_dir = hidden_parent->d_inode;
		IMustLock(hidden_dir);
		err = 0;
	}

	if (!err) {
		au_reset_hinotify(inode, /*flags*/0);
		inode->i_nlink = 0;
		set_dbdiropq(dentry, -1);
		epilog(dir, dentry, bindex);

		if (rmdir_later) {
			kick_rmdir_whtmp(hidden_dentry, whlist, bstart, dir,
					 inode, arg);
			arg = NULL;
		}

		goto out_unlock; /* success */
	}

	/* revert */
	LKTRLabel(revert);
	if (wh_dentry) {
		int rerr;
		rerr = do_revert(err, wh_dentry, dentry, bwh, &dt,
				 need_dlgt(dir->i_sb));
		if (rerr)
			err = rerr;
	}

 out_unlock:
	hdir_unlock(hidden_dir, dir, bindex);
	dput(wh_dentry);
	dput(hidden_dentry);
 out_arg:
	di_write_unlock(parent);
	aufs_read_unlock(dentry, AUFS_D_WLOCK);
	kfree(arg);
 out_whlist:
	nhash_del(whlist);
 out:
	TraceErr(err);
	return err;
}