Example #1
0
/*
 * Convert a dquot list to an ASCII file.
 */
int writeprivs(struct dquot *qlist, int outfd, char *name, int quotatype)
{
	struct dquot *q;
	FILE *fd;

	ftruncate(outfd, 0);
	lseek(outfd, 0, SEEK_SET);
	if (!(fd = fdopen(dup(outfd), "w")))
		die(1, _("Cannot duplicate descriptor of file to write to: %s\n"), strerror(errno));

	fprintf(fd, _("Disk quotas for %s %s (%cid %d):\n"),
		_(type2name(quotatype)), name, *type2name(quotatype), qlist->dq_id);

	fprintf(fd,
		_("  Filesystem                   blocks       soft       hard     inodes     soft     hard\n"));

	for (q = qlist; q; q = q->dq_next) {
		fprintf(fd, "  %-24s %10llu %10llu %10llu %10llu %8llu %8llu\n",
			q->dq_h->qh_quotadev,
			(long long)toqb(q->dq_dqb.dqb_curspace),
			(long long)q->dq_dqb.dqb_bsoftlimit,
			(long long)q->dq_dqb.dqb_bhardlimit,
			(long long)q->dq_dqb.dqb_curinodes,
			(long long)q->dq_dqb.dqb_isoftlimit, (long long)q->dq_dqb.dqb_ihardlimit);
	}
	fclose(fd);
	return 0;
}
Example #2
0
static int syncquotas(int type)
{
	struct quota_handle **handles, *h;
	int i, ret = 0;

	if (flags & FL_ALL) {
		if (sync_one(type, NULL) < 0) {
			errstr(_("%s quota sync failed: %s\n"), _(type2name(type)),
					strerror(errno));
			ret = -1;
		}
		return ret;
	}

	handles = create_handle_list(mntcnt, mnt, type, fmt,
				     IOI_READONLY, MS_LOCALONLY | MS_NO_AUTOFS);

	for (i = 0; handles[i]; i++) {
		h = handles[i];
		if (sync_one(type, h->qh_quotadev)) {
			errstr(_("%s quota sync failed for %s: %s\n"),
				_(type2name(type)), h->qh_quotadev, strerror(errno));
			ret = -1;
		}
	}
	dispose_handle_list(handles);

	return ret;
}
Example #3
0
static std::string type2name_symbol(
  const typet &type,
  const namespacet &ns,
  symbol_numbert &symbol_number)
{
  const irep_idt &identifier=type.get(ID_identifier);

  const symbolt *symbol;

  if(ns.lookup(identifier, symbol))
    return "SYM#"+id2string(identifier)+"#";

  assert(symbol && symbol->is_type);

  if(symbol->type.id()!=ID_struct &&
     symbol->type.id()!=ID_union)
    return type2name(symbol->type, ns, symbol_number);

  std::string result;

  // assign each symbol a number when seen for the first time
  std::pair<symbol_numbert::iterator, bool> entry=
    symbol_number.insert(std::make_pair(
        identifier,
        std::make_pair(symbol_number.size(), true)));

  // new entry, add definition
  if(entry.second)
  {
    result="SYM#"+std::to_string(entry.first->second.first);
    result+="={";
    result+=type2name(symbol->type, ns, symbol_number);
    result+='}';

    entry.first->second.second=false;
  }
#if 0
  // in recursion, print the shorthand only
  else if(entry.first->second.second)
    result="SYM#"+std::to_string(entry.first->second.first);
  // entering recursion
  else
  {
    entry.first->second.second=true;
    result=type2name(symbol->type, ns, symbol_number);
    entry.first->second.second=false;
  }
#else
  // shorthand only as structs/unions are always symbols
  else
// Create a binary tree form for Packs. [lo, hi) (half-open) range
PackNode* PackNode::binary_tree_pack(Compile* C, int lo, int hi) {
  int ct = hi - lo;
  assert(is_power_of_2(ct), "power of 2");
  if (ct == 2) {
    PackNode* pk = PackNode::make(C, in(lo), 2, vect_type()->element_basic_type());
    pk->add_opd(in(lo+1));
    return pk;

  } else {
    int mid = lo + ct/2;
    PackNode* n1 = binary_tree_pack(C, lo,  mid);
    PackNode* n2 = binary_tree_pack(C, mid, hi );

    BasicType bt = n1->vect_type()->element_basic_type();
    assert(bt == n2->vect_type()->element_basic_type(), "should be the same");
    switch (bt) {
    case T_BOOLEAN:
    case T_BYTE:
      return new (C) PackSNode(n1, n2, TypeVect::make(T_SHORT, 2));
    case T_CHAR:
    case T_SHORT:
      return new (C) PackINode(n1, n2, TypeVect::make(T_INT, 2));
    case T_INT:
      return new (C) PackLNode(n1, n2, TypeVect::make(T_LONG, 2));
    case T_LONG:
      return new (C) Pack2LNode(n1, n2, TypeVect::make(T_LONG, 2));
    case T_FLOAT:
      return new (C) PackDNode(n1, n2, TypeVect::make(T_DOUBLE, 2));
    case T_DOUBLE:
      return new (C) Pack2DNode(n1, n2, TypeVect::make(T_DOUBLE, 2));
    }
    fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt)));
  }
  return NULL;
}
Example #5
0
/*
 * Convert a dquot list to an ASCII file of grace times.
 */
int writetimes(struct quota_handle **handles, int outfd)
{
	FILE *fd;
	char itimebuf[MAXTIMELEN], btimebuf[MAXTIMELEN];
	int i;

	if (!handles[0])
		return 0;

	ftruncate(outfd, 0);
	lseek(outfd, 0, SEEK_SET);
	if ((fd = fdopen(dup(outfd), "w")) == NULL)
		die(1, _("Cannot duplicate descriptor of file to edit: %s\n"), strerror(errno));

	fprintf(fd, _("Grace period before enforcing soft limits for %ss:\n"),
		_(type2name(handles[0]->qh_type)));
	fprintf(fd, _("Time units may be: days, hours, minutes, or seconds\n"));
	fprintf(fd, _("  Filesystem             Block grace period     Inode grace period\n"));

	for (i = 0; handles[i]; i++) {
		time2str(handles[i]->qh_info.dqi_bgrace, btimebuf, 0);
		time2str(handles[i]->qh_info.dqi_igrace, itimebuf, 0);
		fprintf(fd, "  %-12s %22s %22s\n", handles[i]->qh_quotadev, btimebuf, itimebuf);
	}

	fclose(fd);
	return 0;
}
    GenericPointerMessage(const std::string& frame_id = "/", Message::Stamp stamp = 0) : Message(type<GenericPointerMessage<Type>>::name(), frame_id, stamp)
    {
        static csapex::DirectMessageConstructorRegistered<connection_types::GenericPointerMessage, Type> reg_c;
        static csapex::DirectMessageSerializerRegistered<connection_types::GenericPointerMessage, Type> reg_s;

        setDescriptiveName(type2name(typeid(Type)));
    }
Example #7
0
// ------------------------------------------------------------------
// ciInstance::field_value_impl
ciConstant ciInstance::field_value_impl(BasicType field_btype, int offset) {
  Handle obj = get_oop();
  assert(!obj.is_null(), "bad oop");
  switch(field_btype) {
    case T_BYTE:    return ciConstant(field_btype, obj->byte_field(offset));
    case T_CHAR:    return ciConstant(field_btype, obj->char_field(offset));
    case T_SHORT:   return ciConstant(field_btype, obj->short_field(offset));
    case T_BOOLEAN: return ciConstant(field_btype, obj->bool_field(offset));
    case T_INT:     return ciConstant(field_btype, obj->int_field(offset));
    case T_FLOAT:   return ciConstant(obj->float_field(offset));
    case T_DOUBLE:  return ciConstant(obj->double_field(offset));
    case T_LONG:    return ciConstant(obj->long_field(offset));
    case T_OBJECT:  // fall through
    case T_ARRAY: {
      oop o = obj->obj_field(offset);

      // A field will be "constant" if it is known always to be
      // a non-null reference to an instance of a particular class,
      // or to a particular array.  This can happen even if the instance
      // or array is not perm.  In such a case, an "unloaded" ciArray
      // or ciInstance is created.  The compiler may be able to use
      // information about the object's class (which is exact) or length.

      if (o == NULL) {
        return ciConstant(field_btype, ciNullObject::make());
      } else {
        return ciConstant(field_btype, CURRENT_ENV->get_object(o));
      }
    }
  }
  fatal("no field value: %s", type2name(field_btype));
  return ciConstant();
}
Example #8
0
/**
 * Print heap as array.
 */
void print_array_int_heap(heap_int_t* heap)
{
	int i;
	printf("Heap: size=%d, allocated=%d, type=%s\n", heap->size, heap->nalloc, type2name(heap->type));
	for (i=0; i<heap->size; i++)
		printf("%d ", heap->data[i]);
	printf("\nHeap end.\n");
}
Example #9
0
// ------------------------------------------------------------------
// ciType::name
//
// Return the name of this type
const char* ciType::name() {
  if (is_primitive_type()) {
    return type2name(basic_type());
  } else {
    assert(is_klass(), "must be");
    return as_klass()->name()->as_utf8();
  }
}
Example #10
0
  Result* get_handler(SEXP call, const ILazySubsets& subsets, const Environment& env) {
    LOG_INFO << "Looking up hybrid handler for call of type " << type2name(call);

    if (TYPEOF(call) == LANGSXP) {
      int depth = Rf_length(call);
      HybridHandlerMap& handlers = get_handlers();
      SEXP fun_symbol = CAR(call);
      if (TYPEOF(fun_symbol) != SYMSXP) {
        LOG_VERBOSE << "Not a function: " << type2name(fun_symbol);
        return 0;
      }

      LOG_VERBOSE << "Searching hybrid handler for function " << CHAR(PRINTNAME(fun_symbol));

      HybridHandlerMap::const_iterator it = handlers.find(fun_symbol);
      if (it == handlers.end()) {
        LOG_VERBOSE << "Not found";
        return 0;
      }

      LOG_INFO << "Using hybrid handler for " << CHAR(PRINTNAME(fun_symbol));

      return it->second(call, subsets, depth - 1);
    } else if (TYPEOF(call) == SYMSXP) {
      SymbolString name = SymbolString(Symbol(call));

      LOG_VERBOSE << "Searching hybrid handler for symbol " << name.get_cstring();

      if (subsets.count(name)) {
        LOG_VERBOSE << "Using hybrid variable handler";
        return variable_handler(subsets, name);
      }
      else {
        SEXP data = env.find(name.get_string());
        // Constants of length != 1 are handled via regular evaluation
        if (Rf_length(data) == 1) {
          LOG_VERBOSE << "Using hybrid constant handler";
          return constant_handler(data);
        }
      }
    } else {
      // TODO: perhaps deal with SYMSXP separately
      if (Rf_length(call) == 1) return constant_handler(call);
    }
    return 0;
  }
Example #11
0
void InstructionPrinter::do_TypeCast(TypeCast* x) {
  output()->print("type_cast(");
  print_value(x->obj());
  output()->print(") ");
  if (x->declared_type()->is_klass())
    print_klass(x->declared_type()->as_klass());
  else
    output()->print(type2name(x->declared_type()->basic_type()));
}
Example #12
0
static void print_attr_detail(stat_attr_t *a, void *arg)
{
	char *rx_u, *tx_u;
	int rxprec, txprec;
	double rx = cancel_down(attr_get_rx(a), a->a_unit, &rx_u, &rxprec);
	double tx = cancel_down(attr_get_tx(a), a->a_unit, &tx_u, &txprec);

	printf("  %-14s %12.*f %s %12.*f %s\n",
	    type2name(a->a_type), rxprec, rx, rx_u, txprec, tx, tx_u);
}
Example #13
0
/*
 *!!! ENABLE
 *!! SYNTAX
 *! \tok{\sc ENAble}
 *! \begin{stack} \tok{ALL} \\ <rdev> \end{stack}
 *!! XATNYS
 *!! AUTH A
 *!! PURPOSE
 *! Enables a real device.
 */
static int cmd_enable(struct virt_sys *sys, char *cmd, int len)
{
	u64 devnum;
	struct device *dev;
	struct console *con;

	SHELL_CMD_AUTH(sys, A);

	if (!strcasecmp(cmd, "ALL")) {
		con_printf(sys->con, "ENABLE ALL not yet implemented!\n");
		return 0;
	}

	cmd = __extract_hex(cmd, &devnum);
	if (IS_ERR(cmd))
		return PTR_ERR(cmd);

	/* device number must be 16-bit */
	if (devnum & ~0xffffUL)
		return -EINVAL;

	dev = find_device_by_ccuu(devnum);
	if (IS_ERR(dev)) {
		con_printf(sys->con, "Device %04llX not found in configuration\n", devnum);
		return 0;
	}

	mutex_lock(&dev->lock);

	if (dev->in_use) {
		con_printf(sys->con, "Device %04llX is already in use\n", devnum);
		goto out_err;
	}

	if (!dev->dev->enable) {
		con_printf(sys->con, "Device type %-4s cannot be enabled\n",
			   type2name(dev->type));
		goto out_err;
	}

	con = dev->dev->enable(dev);
	if (IS_ERR(con)) {
		con_printf(sys->con, "Failed to enable %04llX: %s\n",
			   devnum, errstrings[-PTR_ERR(con)]);
		goto out_err;
	}

	mutex_unlock(&dev->lock);
	return 0;

out_err:
	mutex_unlock(&dev->lock);
	dev_put(dev);
	return 0;
}
Example #14
0
static int remove_quota_files_iterate(struct ocfs2_dir_entry *dirent,
				      uint64_t blocknr, int offset,
				      int blocksize, char *buf,
				      void *priv_data)
{
	struct remove_quota_files_ctxt *ctxt = priv_data;
	char dname[OCFS2_MAX_FILENAME_LEN];
	char wname[OCFS2_MAX_FILENAME_LEN];
	errcode_t ret;
	int tail, i;
	int ret_flags = 0;

	strncpy(dname, dirent->name, dirent->name_len);
	dname[dirent->name_len] = 0;

	/* Check whether entry is quota file of type we want - i.e. matching
	 * aquota.user:[0-9][0-9][0-9][0-9] or aquota.user for type == USRQUOTA
	 * and similarly for type == GRPQUOTA */
	strcpy(wname, "aquota.");
	strcat(wname, type2name(ctxt->type));
	tail = strlen(wname);
	if (strncmp(dname, wname, tail))
		return 0;
	if (dname[tail] == ':') {	/* May be local file? */
		tail++;
		for (i = 0; i < 4; i++)
			if (dname[tail + i] < '0' || dname[tail + i] > '9')
				return 0;
		if (dname[tail + i])
			return 0;
	} else if (dname[tail])		/* May be global file? */
		return 0;

	verbosef(VL_APP, "Deleting quota file %s\n",
		 dname);
	ret = ocfs2_truncate(ctxt->fs, dirent->inode, 0);
	if (ret) {
		tcom_err(ret, "while truncating quota file \"%s\"", dname);
		ret_flags |= OCFS2_DIRENT_ERROR;
		ctxt->err = ret;
		goto out;
	}
	ret = ocfs2_delete_inode(ctxt->fs, dirent->inode);
	if (ret) {
		tcom_err(ret, "while deleting quota file \"%s\"", dname);
		ret_flags |= OCFS2_DIRENT_ERROR;
		ctxt->err = ret;
	} else {
		dirent->inode = 0;
		ret_flags |= OCFS2_DIRENT_CHANGED;
	}
out:
	return ret_flags;
}
Example #15
0
/* Get dquot from kernel */
int vfs_get_dquot(struct dquot *dquot)
{
	struct if_dqblk kdqblk;

	if (quotactl(QCMD(Q_GETQUOTA, dquot->dq_h->qh_type), dquot->dq_h->qh_quotadev, dquot->dq_id, (void *)&kdqblk) < 0) {
		errstr(_("Cannot get quota for %s %d from kernel on %s: %s\n"), type2name(dquot->dq_h->qh_type), dquot->dq_id, dquot->dq_h->qh_quotadev, strerror(errno));
		return -1;
	}
	generic_kern2utildqblk(&dquot->dq_dqb, &kdqblk);
	return 0;
}
Example #16
0
PyObject *
CCNObject_Borrow(enum _pyccn_capsules type, void *pointer)
{
	PyObject *r;

	assert(pointer);
	r = PyCapsule_New(pointer, type2name(type), NULL);
	assert(r);

	return r;
}
Example #17
0
void *
CCNObject_Get(enum _pyccn_capsules type, PyObject *capsule)
{
	void *p;

	assert(CCNObject_IsValid(type, capsule));
	p = PyCapsule_GetPointer(capsule, type2name(type));
	assert(p);

	return p;
}
Example #18
0
/* Get info from kernel to handle */
int vfs_get_info(struct quota_handle *h)
{
	struct if_dqinfo kinfo;

	if (quotactl(QCMD(Q_GETINFO, h->qh_type), h->qh_quotadev, 0, (void *)&kinfo) < 0) {
		errstr(_("Cannot get info for %s quota file from kernel on %s: %s\n"), type2name(h->qh_type), h->qh_quotadev, strerror(errno));
		return -1;
	}
	h->qh_info.dqi_bgrace = kinfo.dqi_bgrace;
	h->qh_info.dqi_igrace = kinfo.dqi_igrace;
	return 0;
}
Example #19
0
/* Set dquot in kernel */
int vfs_set_dquot(struct dquot *dquot, int flags)
{
	struct if_dqblk kdqblk;

	generic_util2kerndqblk(&kdqblk, &dquot->dq_dqb);
	kdqblk.dqb_valid = flags;
	if (quotactl(QCMD(Q_SETQUOTA, dquot->dq_h->qh_type), dquot->dq_h->qh_quotadev, dquot->dq_id, (void *)&kdqblk) < 0) {
		errstr(_("Cannot set quota for %s %d from kernel on %s: %s\n"), type2name(dquot->dq_h->qh_type), dquot->dq_id, dquot->dq_h->qh_quotadev, strerror(errno));
		return -1;
	}
	return 0;
}
Example #20
0
int
CCNObject_ReqType(enum _pyccn_capsules type, PyObject *capsule)
{
	int r;
	const char *t = type2name(type);

	r = PyCapsule_IsValid(capsule, t);
	if (!r)
		PyErr_Format(PyExc_TypeError, "Argument needs to be of %s type", t);

	return r;
}
Example #21
0
static void
draw_attr_detail(intf_attr_t *attr, void *arg)
{
	int *t = (int *) arg;

	if (0 == *t) {
		NEXT_ROW;
		putl(" %-12s%11llu %11llu",
			type2name(attr->a_type), attr->a_rx, attr->a_tx);

		if (!attr->a_rx_enabled) {
			move(row, 21);
			addstr("N/A");
		}

		if (!attr->a_tx_enabled) {
			move(row, 33);
			addstr("N/A");
		}

		move(row, 44);
		*t = 1;
	} else {
		putl("%-12s%11llu %11llu",
			type2name(attr->a_type), attr->a_rx, attr->a_tx);
		
		if (!attr->a_rx_enabled) {
			move(row, 64);
			addstr("N/A");
		}
		
		if (!attr->a_tx_enabled) {
			move(row, 76);
			addstr("N/A");
		}

		move(row, 0);
		*t = 0;
	}
}
Example #22
0
/*
 * Write grace times of user to file
 */
int writeindividualtimes(struct dquot *qlist, int outfd, char *name, int quotatype)
{
	struct dquot *q;
	FILE *fd;
	time_t now;
	char btimestr[MAXTIMELEN], itimestr[MAXTIMELEN];

	ftruncate(outfd, 0);
	lseek(outfd, 0, SEEK_SET);
	if (!(fd = fdopen(dup(outfd), "w")))
		die(1, _("Cannot duplicate descriptor of file to write to: %s\n"), strerror(errno));

	fprintf(fd, _("Times to enforce softlimit for %s %s (%cid %d):\n"),
		_(type2name(quotatype)), name, *type2name(quotatype), qlist->dq_id);
	fprintf(fd, _("Time units may be: days, hours, minutes, or seconds\n"));
	fprintf(fd,
		_("  Filesystem                         block grace               inode grace\n"));

	time(&now);
	for (q = qlist; q; q = q->dq_next) {
		if (!q->dq_dqb.dqb_btime)
			strcpy(btimestr, _("unset"));
		else if (q->dq_dqb.dqb_btime <= now)
			strcpy(btimestr, _("0seconds"));
		else
			sprintf(btimestr, _("%useconds"), (unsigned)(q->dq_dqb.dqb_btime - now));
		if (!q->dq_dqb.dqb_itime)
			strcpy(itimestr, _("unset"));
		else if (q->dq_dqb.dqb_itime <= now)
			strcpy(itimestr, _("0seconds"));
		else
			sprintf(itimestr, _("%useconds"), (unsigned)(q->dq_dqb.dqb_itime - now));

		fprintf(fd, "  %-24s %22s %22s\n", q->dq_h->qh_quotadev, btimestr, itimestr);
	}
	fclose(fd);
	return 0;
}
Example #23
0
/* Set info in kernel from handle */
int vfs_set_info(struct quota_handle *h, int flags)
{
	struct if_dqinfo kinfo;

	kinfo.dqi_bgrace = h->qh_info.dqi_bgrace;
	kinfo.dqi_igrace = h->qh_info.dqi_igrace;
	kinfo.dqi_valid = flags;

	if (quotactl(QCMD(Q_SETINFO, h->qh_type), h->qh_quotadev, 0, (void *)&kinfo) < 0) {
		errstr(_("Cannot set info for %s quota file from kernel on %s: %s\n"), type2name(h->qh_type), h->qh_quotadev, strerror(errno));
		return -1;
	}
	return 0;
}
Example #24
0
/**
 * Print heap on levels.
 */
void print_tree_int_heap(heap_int_t* heap)
{
	int h, i, j;

	printf("Heap: size=%d, allocated=%d, type=%s\n", heap->size, heap->nalloc, type2name(heap->type));

	i = 0;
	for (h=0; h<=mylog2(heap->size); h++) {
		for (j=0; j<(1<<h) && i<heap->size; j++, i++)
			printf("%d ", heap->data[i]);
		printf("\n");
	}
	printf("Heap end.\n");
}
Example #25
0
PyObject *
CCNObject_New(enum _pyccn_capsules type, void *pointer)
{
	PyObject *capsule;
	int r;

	assert(pointer);
	capsule = PyCapsule_New(pointer, type2name(type), pyccn_Capsule_Destructor);
	if (!capsule)
		return NULL;

	switch (type) {
	case CONTENT_OBJECT:
	{
		struct content_object_data *context;

		context = calloc(1, sizeof(*context));
		JUMP_IF_NULL_MEM(context, error);

		r = PyCapsule_SetContext(capsule, context);
		if (r < 0) {
			free(context);
			goto error;
		}
		break;
	}
	case INTEREST:
	{
		struct interest_data *context;

		context = calloc(1, sizeof(*context));
		JUMP_IF_NULL_MEM(context, error);

		r = PyCapsule_SetContext(capsule, context);
		if (r < 0) {
			free(context);
			goto error;
		}
		break;
	}
	default:
		break;
	}

	return capsule;

error:
	Py_XDECREF(capsule);
	return NULL;
}
// Return initial Pack node. Additional operands added with add_opd() calls.
PackNode* PackNode::make(Compile* C, Node* s, uint vlen, BasicType bt) {
  const TypeVect* vt = TypeVect::make(bt, vlen);
  switch (bt) {
  case T_BOOLEAN:
  case T_BYTE:
    return new (C) PackBNode(s, vt);
  case T_CHAR:
  case T_SHORT:
    return new (C) PackSNode(s, vt);
  case T_INT:
    return new (C) PackINode(s, vt);
  case T_LONG:
    return new (C) PackLNode(s, vt);
  case T_FLOAT:
    return new (C) PackFNode(s, vt);
  case T_DOUBLE:
    return new (C) PackDNode(s, vt);
  }
  fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt)));
  return NULL;
}
// Scalar promotion
VectorNode* VectorNode::scalar2vector(Compile* C, Node* s, uint vlen, const Type* opd_t) {
  BasicType bt = opd_t->array_element_basic_type();
  const TypeVect* vt = opd_t->singleton() ? TypeVect::make(opd_t, vlen)
                                          : TypeVect::make(bt, vlen);
  switch (bt) {
  case T_BOOLEAN:
  case T_BYTE:
    return new (C) ReplicateBNode(s, vt);
  case T_CHAR:
  case T_SHORT:
    return new (C) ReplicateSNode(s, vt);
  case T_INT:
    return new (C) ReplicateINode(s, vt);
  case T_LONG:
    return new (C) ReplicateLNode(s, vt);
  case T_FLOAT:
    return new (C) ReplicateFNode(s, vt);
  case T_DOUBLE:
    return new (C) ReplicateDNode(s, vt);
  }
  fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt)));
  return NULL;
}
// Extract a scalar element of vector.
Node* ExtractNode::make(Compile* C, Node* v, uint position, BasicType bt) {
  assert((int)position < Matcher::max_vector_size(bt), "pos in range");
  ConINode* pos = ConINode::make(C, (int)position);
  switch (bt) {
  case T_BOOLEAN:
    return new (C) ExtractUBNode(v, pos);
  case T_BYTE:
    return new (C) ExtractBNode(v, pos);
  case T_CHAR:
    return new (C) ExtractCNode(v, pos);
  case T_SHORT:
    return new (C) ExtractSNode(v, pos);
  case T_INT:
    return new (C) ExtractINode(v, pos);
  case T_LONG:
    return new (C) ExtractLNode(v, pos);
  case T_FLOAT:
    return new (C) ExtractFNode(v, pos);
  case T_DOUBLE:
    return new (C) ExtractDNode(v, pos);
  }
  fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt)));
  return NULL;
}
void BytecodePrinter::print_attributes(int bci, outputStream* st) {
  // Show attributes of pre-rewritten codes
  Bytecodes::Code code = Bytecodes::java_code(raw_code());
  // If the code doesn't have any fields there's nothing to print.
  // note this is ==1 because the tableswitch and lookupswitch are
  // zero size (for some reason) and we want to print stuff out for them.
  if (Bytecodes::length_for(code) == 1) {
    st->cr();
    return;
  }

  switch(code) {
    // Java specific bytecodes only matter.
    case Bytecodes::_bipush:
      st->print_cr(" " INT32_FORMAT, get_byte());
      break;
    case Bytecodes::_sipush:
      st->print_cr(" " INT32_FORMAT, get_short());
      break;
    case Bytecodes::_ldc:
      if (Bytecodes::uses_cp_cache(raw_code())) {
        print_constant(get_index_u1_cpcache(), st);
      } else {
        print_constant(get_index_u1(), st);
      }
      break;

    case Bytecodes::_ldc_w:
    case Bytecodes::_ldc2_w:
      if (Bytecodes::uses_cp_cache(raw_code())) {
        print_constant(get_index_u2_cpcache(), st);
      } else {
        print_constant(get_index_u2(), st);
      }
      break;

    case Bytecodes::_iload:
    case Bytecodes::_lload:
    case Bytecodes::_fload:
    case Bytecodes::_dload:
    case Bytecodes::_aload:
    case Bytecodes::_istore:
    case Bytecodes::_lstore:
    case Bytecodes::_fstore:
    case Bytecodes::_dstore:
    case Bytecodes::_astore:
      st->print_cr(" #%d", get_index_special());
      break;

    case Bytecodes::_iinc:
      { int index = get_index_special();
        jint offset = is_wide() ? get_short(): get_byte();
        st->print_cr(" #%d " INT32_FORMAT, index, offset);
      }
      break;

    case Bytecodes::_newarray: {
        BasicType atype = (BasicType)get_index_u1();
        const char* str = type2name(atype);
        if (str == NULL || atype == T_OBJECT || atype == T_ARRAY) {
          assert(false, "Unidentified basic type");
        }
        st->print_cr(" %s", str);
      }
      break;
    case Bytecodes::_anewarray: {
        int klass_index = get_index_u2();
        ConstantPool* constants = method()->constants();
        Symbol* name = constants->klass_name_at(klass_index);
        st->print_cr(" %s ", name->as_C_string());
      }
      break;
    case Bytecodes::_multianewarray: {
        int klass_index = get_index_u2();
        int nof_dims = get_index_u1();
        ConstantPool* constants = method()->constants();
        Symbol* name = constants->klass_name_at(klass_index);
        st->print_cr(" %s %d", name->as_C_string(), nof_dims);
      }
      break;

    case Bytecodes::_ifeq:
    case Bytecodes::_ifnull:
    case Bytecodes::_iflt:
    case Bytecodes::_ifle:
    case Bytecodes::_ifne:
    case Bytecodes::_ifnonnull:
    case Bytecodes::_ifgt:
    case Bytecodes::_ifge:
    case Bytecodes::_if_icmpeq:
    case Bytecodes::_if_icmpne:
    case Bytecodes::_if_icmplt:
    case Bytecodes::_if_icmpgt:
    case Bytecodes::_if_icmple:
    case Bytecodes::_if_icmpge:
    case Bytecodes::_if_acmpeq:
    case Bytecodes::_if_acmpne:
    case Bytecodes::_goto:
    case Bytecodes::_jsr:
      st->print_cr(" %d", bci + get_short());
      break;

    case Bytecodes::_goto_w:
    case Bytecodes::_jsr_w:
      st->print_cr(" %d", bci + get_int());
      break;

    case Bytecodes::_ret: st->print_cr(" %d", get_index_special()); break;

    case Bytecodes::_tableswitch:
      { align();
        int  default_dest = bci + get_int();
        int  lo           = get_int();
        int  hi           = get_int();
        int  len          = hi - lo + 1;
        jint* dest        = NEW_RESOURCE_ARRAY(jint, len);
        for (int i = 0; i < len; i++) {
          dest[i] = bci + get_int();
        }
        st->print(" %d " INT32_FORMAT " " INT32_FORMAT " ",
                      default_dest, lo, hi);
        int first = true;
        for (int ll = lo; ll <= hi; ll++, first = false)  {
          int idx = ll - lo;
          const char *format = first ? " %d:" INT32_FORMAT " (delta: %d)" :
                                       ", %d:" INT32_FORMAT " (delta: %d)";
          st->print(format, ll, dest[idx], dest[idx]-bci);
        }
        st->cr();
      }
      break;
    case Bytecodes::_lookupswitch:
      { align();
        int  default_dest = bci + get_int();
        int  len          = get_int();
        jint* key         = NEW_RESOURCE_ARRAY(jint, len);
        jint* dest        = NEW_RESOURCE_ARRAY(jint, len);
        for (int i = 0; i < len; i++) {
          key [i] = get_int();
          dest[i] = bci + get_int();
        };
        st->print(" %d %d ", default_dest, len);
        bool first = true;
        for (int ll = 0; ll < len; ll++, first = false)  {
          const char *format = first ? " " INT32_FORMAT ":" INT32_FORMAT :
                                       ", " INT32_FORMAT ":" INT32_FORMAT ;
          st->print(format, key[ll], dest[ll]);
        }
        st->cr();
      }
      break;

    case Bytecodes::_putstatic:
    case Bytecodes::_getstatic:
    case Bytecodes::_putfield:
    case Bytecodes::_getfield:
      print_field_or_method(get_index_u2_cpcache(), st);
      break;

    case Bytecodes::_invokevirtual:
    case Bytecodes::_invokespecial:
    case Bytecodes::_invokestatic:
      print_field_or_method(get_index_u2_cpcache(), st);
      break;

    case Bytecodes::_invokeinterface:
      { int i = get_index_u2_cpcache();
        int n = get_index_u1();
        get_byte();            // ignore zero byte
        print_field_or_method(i, st);
      }
      break;

    case Bytecodes::_invokedynamic:
      print_field_or_method(get_index_u4(), st);
      break;

    case Bytecodes::_new:
    case Bytecodes::_checkcast:
    case Bytecodes::_instanceof:
      { int i = get_index_u2();
        ConstantPool* constants = method()->constants();
        Symbol* name = constants->klass_name_at(i);
        st->print_cr(" %d <%s>", i, name->as_C_string());
      }
      break;

    case Bytecodes::_wide:
      // length is zero not one, but printed with no more info.
      break;

    default:
      ShouldNotReachHere();
      break;
  }
}
static int update_sync_interval(ocfs2_filesys *fs, int type,
				unsigned long syncms)
{
	errcode_t err;
	struct tools_progress *prog;
	int feature = (type == USRQUOTA) ? OCFS2_FEATURE_RO_COMPAT_USRQUOTA :
					   OCFS2_FEATURE_RO_COMPAT_GRPQUOTA;
	struct ocfs2_global_disk_dqinfo *qinfo;

	if (!OCFS2_HAS_RO_COMPAT_FEATURE(OCFS2_RAW_SB(fs->fs_super), feature)) {
		errorf("The %s quota is not enabled on device \"%s\"\n",
		       type2name(type), fs->fs_devname);
		return 1;
	}
	err = ocfs2_init_fs_quota_info(fs, type);
	if (err) {
		tcom_err(err, "while looking up %s quota file on device "
			 "\"%s\"", type2name(type), fs->fs_devname);
		return 1;
	}
	err = ocfs2_read_global_quota_info(fs, type);
	if (err) {
		tcom_err(err, "while reading %s quota info on device \"%s\"",
			 type2name(type), fs->fs_devname);
		return 1;
	}
	qinfo = &fs->qinfo[type].qi_info;
	if (qinfo->dqi_syncms == syncms) {
		verbosef(VL_APP,
			 "Device \"%s\" already has interval %lu set; "
			 "nothing to do\n", fs->fs_devname, syncms);
		return 0;
	}

	if (!tools_interact("Change quota syncing interval on device \"%s\" "
			    "from %lu to %lu? ", fs->fs_devname,
			    (unsigned long)qinfo->dqi_syncms, syncms))
		return 0;

	prog = tools_progress_start("Setting syncing interval", "interval", 1);
	if (!prog) {
		tcom_err(err, "while initializing the progress display");
		return 1;
	}

	tunefs_block_signals();
	qinfo->dqi_syncms = syncms;
	err = ocfs2_write_global_quota_info(fs, type);
	tunefs_unblock_signals();

	tools_progress_step(prog, 1);
	tools_progress_stop(prog);

	if (err) {
		tcom_err(err,
			 "- unable to update %s quota syncing interval on "
			 "device \"%s\"", type2name(type), fs->fs_devname);
		return 1;
	}

	return 0;
}