本文整理汇总了C++中sd_err函数的典型用法代码示例。如果您正苦于以下问题:C++ sd_err函数的具体用法?C++ sd_err怎么用?C++ sd_err使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sd_err函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prealloc
/* Preallocate the whole object to get a better filesystem layout. */
int prealloc(int fd, uint32_t size)
{
int ret = xfallocate(fd, 0, 0, size);
if (ret < 0) {
if (errno != ENOSYS && errno != EOPNOTSUPP) {
sd_err("failed to preallocate space, %m");
return ret;
}
return xftruncate(fd, size);
}
return 0;
}
示例2: sd_out_new_until
SD_API struct sd_out *
sd_out_new_until(double time)
{
struct data *data, zero = {0};
if ((data = sd_malloc(sizeof(struct data))) == NULL)
{
sd_err("alloc out until failed.");
return NULL;
}
data->time = time;
data->sd_out = sd_out_defaults;
data->sd_out.data = data;
return &(data->sd_out);
}
示例3: modify_event
int modify_event(int fd, unsigned int new_events)
{
int ret;
struct epoll_event ev;
struct event_info *ei;
ei = lookup_event(fd);
if (!ei) {
sd_err("event info for fd %d not found", fd);
return 1;
}
memset(&ev, 0, sizeof(ev));
ev.events = new_events;
ev.data.ptr = ei;
ret = epoll_ctl(efd, EPOLL_CTL_MOD, fd, &ev);
if (ret) {
sd_err("failed to modify epoll event for fd %d: %m", fd);
return 1;
}
return 0;
}
示例4: sd_write_object
/* Write data to both local object cache (if enabled) and backends */
int sd_write_object(uint64_t oid, char *data, unsigned int datalen,
uint64_t offset, bool create)
{
struct sd_req hdr;
int ret;
if (sys->enable_object_cache && object_is_cached(oid)) {
ret = object_cache_write(oid, data, datalen, offset,
create);
if (ret == SD_RES_NO_CACHE)
goto forward_write;
if (ret != 0) {
sd_err("write cache failed %" PRIx64 " %" PRIx32, oid,
ret);
return ret;
}
}
forward_write:
if (create)
sd_init_req(&hdr, SD_OP_CREATE_AND_WRITE_OBJ);
else
sd_init_req(&hdr, SD_OP_WRITE_OBJ);
hdr.flags = SD_FLAG_CMD_WRITE;
hdr.data_length = datalen;
hdr.obj.oid = oid;
hdr.obj.offset = offset;
ret = exec_local_req(&hdr, data);
if (ret != SD_RES_SUCCESS)
sd_err("failed to write object %" PRIx64 ", %s", oid,
sd_strerror(ret));
return ret;
}
示例5: create_unix_domain_socket
int create_unix_domain_socket(const char *unix_path,
int (*callback)(int, void *), void *data)
{
int fd, ret;
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
pstrcpy(addr.sun_path, sizeof(addr.sun_path), unix_path);
fd = socket(addr.sun_family, SOCK_STREAM, 0);
if (fd < 0) {
sd_err("failed to create socket, %m");
return -1;
}
ret = bind(fd, &addr, sizeof(addr));
if (ret) {
sd_err("failed to bind socket: %m");
goto err;
}
ret = listen(fd, SOMAXCONN);
if (ret) {
sd_err("failed to listen on socket: %m");
goto err;
}
ret = callback(fd, data);
if (ret)
goto err;
return 0;
err:
close(fd);
return -1;
}
示例6: init_journal_arg
static void init_journal_arg(char *arg)
{
const char *d = "dir=", *sz = "size=", *sp = "skip";
int dl = strlen(d), szl = strlen(sz), spl = strlen(sp);
if (!strncmp(d, arg, dl)) {
arg += dl;
snprintf(jpath, sizeof(jpath), "%s", arg);
} else if (!strncmp(sz, arg, szl)) {
arg += szl;
jsize = strtoll(arg, NULL, 10);
if (jsize < MIN_JOURNAL_SIZE || jsize == LLONG_MAX) {
sd_err("invalid size %s, must be bigger than %u(M)",
arg,
MIN_JOURNAL_SIZE);
exit(1);
}
} else if (!strncmp(sp, arg, spl)) {
jskip = true;
} else {
sd_err("invalid paramters %s", arg);
exit(1);
}
}
示例7: sd_discard_object
int sd_discard_object(uint64_t oid)
{
int ret;
struct sd_req hdr;
sd_init_req(&hdr, SD_OP_DISCARD_OBJ);
hdr.obj.oid = oid;
ret = exec_local_req(&hdr, NULL);
if (ret != SD_RES_SUCCESS)
sd_err("Failed to discard data obj %"PRIu64" %s", oid,
sd_strerror(ret));
return ret;
}
示例8: bnode_do_create
static int bnode_do_create(struct kv_bnode *bnode, struct sd_inode *inode,
uint32_t idx)
{
uint32_t vid = inode->vdi_id;
uint64_t oid = vid_to_data_oid(vid, idx);
int ret;
bnode->oid = oid;
ret = sd_write_object(oid, (char *)bnode, sizeof(*bnode), 0, true);
if (ret != SD_RES_SUCCESS) {
sd_err("failed to create object, %" PRIx64, oid);
goto out;
}
INODE_SET_VID(inode, idx, vid);
ret = sd_inode_write_vid(sheep_bnode_writer, inode, idx,
vid, vid, 0, false, false);
if (ret != SD_RES_SUCCESS) {
sd_err("failed to update inode, %" PRIx64,
vid_to_vdi_oid(vid));
goto out;
}
out:
return ret;
}
示例9: sd_rng_new_mt
struct sd_rng *
sd_rng_new_mt(uint32_t seed)
{
struct data *data;
if ((data = sd_malloc(sizeof(struct data))) == NULL)
{
sd_err("alloc rng failed.");
return NULL;
}
data->seed = seed;
data->sd_rng = sd_rng_defaults;
data->sd_rng.data = data;
sd_rng_mt_seed(seed, &data->rks);
return &data->sd_rng;
}
示例10: set_delay_scale
static enum sd_stat set_delay_scale(
struct sd_conn *sd_conn, double new_delay_scale)
{
if (new_delay_scale <= 0.0)
{
sd_err("delay_scale <= 0");
return SD_ERR;
}
struct conn *conn = (struct conn*) sd_conn->data;
double rescaler = conn->delay_scale / new_delay_scale;
for (uint32_t i=0; i<conn->nnz; i++)
conn->delays[i] *= rescaler;
conn->delay_scale = new_delay_scale;
return SD_OK;
}
示例11: send_light_req
/* Light request only contains header, without body content. */
int send_light_req(const struct node_id *nid, struct sd_req *hdr)
{
int ret = dog_exec_req(nid, hdr, NULL);
struct sd_rsp *rsp = (struct sd_rsp *)hdr;
if (ret == -1)
return -1;
if (rsp->result != SD_RES_SUCCESS) {
sd_err("Response's result: %s", sd_strerror(rsp->result));
return -1;
}
return 0;
}
示例12: send_light_req
/* Light request only contains header, without body content. */
int send_light_req(struct sd_req *hdr, const uint8_t *addr, int port)
{
int ret = dog_exec_req(addr, port, hdr, NULL);
struct sd_rsp *rsp = (struct sd_rsp *)hdr;
if (ret == -1)
return -1;
if (rsp->result != SD_RES_SUCCESS) {
sd_err("Response's result: %s", sd_strerror(rsp->result));
return -1;
}
return 0;
}
示例13: sdstd_isr
/* Interrupt handler */
static irqreturn_t
sdstd_isr(int irq, void *dev_id
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
, struct pt_regs *ptregs
#endif
)
{
sdioh_info_t *sd;
struct sdos_info *sdos;
bool ours;
unsigned long flags;
sd = (sdioh_info_t *)dev_id;
sdos = (struct sdos_info *)sd->sdos_info;
if (!sd->card_init_done) {
sd_err(("%s: Hey Bogus intr...not even initted: irq %d\n", __FUNCTION__, irq));
return IRQ_RETVAL(FALSE);
} else {
if (sdstd_3_is_retuning_int_set(sd)) {
/* for 3.0 host, retuning request might come in this path */
/* * disable ISR's */
local_irq_save(flags);
if (sdstd_3_check_and_set_retuning(sd))
tasklet_schedule(&sdos->tuning_tasklet);
/* * enable back ISR's */
local_irq_restore(flags);
/* * disable tuning isr signaling */
sdstd_3_disable_retuning_int(sd);
/* * note: check_client_intr() checks for intmask also to
wakeup. so be careful to use sd->intmask to disable
re-tuning ISR.
*/
}
ours = check_client_intr(sd);
/* For local interrupts, wake the waiting process */
if (ours && sd->got_hcint) {
sd_trace(("INTR->WAKE\n"));
/* sdos = (struct sdos_info *)sd->sdos_info; */
wake_up_interruptible(&sdos->intr_wait_queue);
}
return IRQ_RETVAL(ours);
}
}
示例14: default_remove_object
int default_remove_object(uint64_t oid, uint8_t ec_index)
{
char path[PATH_MAX];
get_store_path(oid, ec_index, path);
if (unlink(path) < 0) {
if (errno == ENOENT)
return SD_RES_NO_OBJ;
sd_err("failed, %s, %m", path);
return SD_RES_EIO;
}
return SD_RES_SUCCESS;
}
示例15: bcmsdh_sdmmc_resume
static int bcmsdh_sdmmc_resume(struct device *pdev)
{
#if defined(OOB_INTR_ONLY)
struct sdio_func *func = dev_to_sdio_func(pdev);
#endif
if (func->num == 2)
sd_err(("%s Enter\n", __FUNCTION__));
dhd_mmc_suspend = FALSE;
#if defined(OOB_INTR_ONLY)
if ((func->num == 2) && dhd_os_check_if_up(bcmsdh_get_drvdata()))
bcmsdh_oob_intr_set(1);
#endif /* (OOB_INTR_ONLY) */
smp_mb();
return 0;
}