本文整理汇总了C++中ERR_PTR函数的典型用法代码示例。如果您正苦于以下问题:C++ ERR_PTR函数的具体用法?C++ ERR_PTR怎么用?C++ ERR_PTR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ERR_PTR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snd_soc_of_parse_card_name
static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card)
{
struct device *dev = card->dev;
struct snd_soc_dai_link *link;
struct device_node *np, *codec, *cpu, *node = dev->of_node;
struct apq8016_sbc_data *data;
int ret, num_links;
ret = snd_soc_of_parse_card_name(card, "qcom,model");
if (ret) {
dev_err(dev, "Error parsing card name: %d\n", ret);
return ERR_PTR(ret);
}
/* DAPM routes */
if (of_property_read_bool(node, "qcom,audio-routing")) {
ret = snd_soc_of_parse_audio_routing(card,
"qcom,audio-routing");
if (ret)
return ERR_PTR(ret);
}
/* Populate links */
num_links = of_get_child_count(node);
/* Allocate the private data and the DAI link array */
data = devm_kzalloc(dev, sizeof(*data) + sizeof(*link) * num_links,
GFP_KERNEL);
if (!data)
return ERR_PTR(-ENOMEM);
card->dai_link = &data->dai_link[0];
card->num_links = num_links;
link = data->dai_link;
for_each_child_of_node(node, np) {
cpu = of_get_child_by_name(np, "cpu");
codec = of_get_child_by_name(np, "codec");
if (!cpu || !codec) {
dev_err(dev, "Can't find cpu/codec DT node\n");
return ERR_PTR(-EINVAL);
}
link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0);
if (!link->cpu_of_node) {
dev_err(card->dev, "error getting cpu phandle\n");
return ERR_PTR(-EINVAL);
}
ret = snd_soc_of_get_dai_name(cpu, &link->cpu_dai_name);
if (ret) {
dev_err(card->dev, "error getting cpu dai name\n");
return ERR_PTR(ret);
}
ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
if (ret < 0) {
dev_err(card->dev, "error getting codec dai name\n");
return ERR_PTR(ret);
}
link->platform_of_node = link->cpu_of_node;
ret = of_property_read_string(np, "link-name", &link->name);
if (ret) {
dev_err(card->dev, "error getting codec dai_link name\n");
return ERR_PTR(ret);
}
link->stream_name = link->name;
link->init = apq8016_sbc_dai_init;
link++;
}
示例2: new_inode_page
struct page *init_inode_metadata(struct inode *inode, struct inode *dir,
const struct qstr *name, struct page *dpage)
{
struct page *page;
int err;
if (is_inode_flag_set(F2FS_I(inode), FI_NEW_INODE)) {
page = new_inode_page(inode);
if (IS_ERR(page))
return page;
if (S_ISDIR(inode->i_mode)) {
err = make_empty_dir(inode, dir, page);
if (err)
goto error;
}
err = f2fs_init_acl(inode, dir, page, dpage);
if (err)
goto put_error;
err = f2fs_init_security(inode, dir, name, page);
if (err)
goto put_error;
} else {
page = get_node_page(F2FS_I_SB(dir), inode->i_ino);
if (IS_ERR(page))
return page;
set_cold_node(inode, page);
}
if (name)
init_dent_inode(name, page);
/*
* This file should be checkpointed during fsync.
* We lost i_pino from now on.
*/
if (is_inode_flag_set(F2FS_I(inode), FI_INC_LINK)) {
file_lost_pino(inode);
/*
* If link the tmpfile to alias through linkat path,
* we should remove this inode from orphan list.
*/
if (inode->i_nlink == 0)
remove_orphan_inode(F2FS_I_SB(dir), inode->i_ino);
inc_nlink(inode);
}
return page;
put_error:
f2fs_put_page(page, 1);
error:
/* once the failed inode becomes a bad inode, i_mode is S_IFREG */
truncate_inode_pages(&inode->i_data, 0);
truncate_blocks(inode, 0, false);
remove_dirty_dir_inode(inode);
remove_inode_page(inode);
return ERR_PTR(err);
}
示例3: vnlayer_decode_fh
/* Common file handle decoding for both parent and dentry */
static struct dentry *
vnlayer_decode_fh(
SUPER_T *sb,
struct fid *fh,
int len, /* counted in units of 4-bytes */
int fhtype,
int is_parent)
{
MDKI_FID_T *lfidp;
DENT_T *dp;
int error, fidlen;
SUPER_T *realsb;
unsigned realsb_hash;
fidlen = fhtype >> 1;
if (fidlen == 0) {
return ERR_PTR(-EINVAL);
}
if (len * 4 < MDKI_FID_LEN_WITH_HASH(fidlen)) {
MDKI_VFS_LOG(VFS_LOG_ESTALE,
"%s: FH too small to be a MVFS FH\n",
__FUNCTION__);
return ERR_PTR(-EINVAL);
}
lfidp = KMEM_ALLOC(MDKI_FID_ALLOC_LEN(fidlen), KM_SLEEP);
if (lfidp == NULL) {
return ERR_PTR(-ENOMEM);
}
if (is_parent) {
error = vnlayer_unpack_fh((__u32 *)fh, len, fhtype, fidlen,
NULL, lfidp);
} else {
error = vnlayer_unpack_fh((__u32 *)fh, len, fhtype, fidlen,
lfidp, NULL);
}
if (error == 0) {
realsb_hash = MDKI_FID_SB_HASH(fh, fidlen);
/*
* Search in the VOB mount list for the super_block we encoded.
* If the result is not NULL, the superblock was locked with
* lock_super and should be unlocked.
*/
realsb = (SUPER_T *) mvfs_find_mount(vnlayer_eval_mount,
&realsb_hash);
if (realsb != NULL) {
/*
* It found a matching VOB mount to this hash, we will leave to
* vnlayer_get_dentry decides wether we can trust this FID,
* it should be able to smell any staleness.
*/
dp = vnlayer_get_dentry(realsb, lfidp);
unlock_super(realsb);
if (IS_ERR(dp)) {
MDKI_VFS_LOG(VFS_LOG_ESTALE,
"%s: pid %d vnlayer_get_dentry returned error %ld\n",
__FUNCTION__, current->pid, PTR_ERR(dp));
}
} else {
dp = ERR_PTR(-EINVAL);
MDKI_VFS_LOG(VFS_LOG_ESTALE, "%s SB not found, hash=%08x\n",
__FUNCTION__, realsb_hash);
}
} else {
dp = ERR_PTR(error);
}
KMEM_FREE(lfidp, MDKI_FID_ALLOC_LEN(fidlen));
return dp;
}
示例4: dev_info
struct q6v5_data __devinit *pil_q6v5_init(struct platform_device *pdev)
{
struct q6v5_data *drv;
struct resource *res;
struct pil_desc *desc;
int ret;
#ifdef CONFIG_MACH_LGE
if (!strcmp(pdev->name, "mss"))
dev_info(&pdev->dev, "pil_q6v5_init, %s \n", pdev->name);
#endif
drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
if (!drv)
return ERR_PTR(-ENOMEM);
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "qdsp6_base");
drv->reg_base = devm_request_and_ioremap(&pdev->dev, res);
if (!drv->reg_base)
return ERR_PTR(-ENOMEM);
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "halt_base");
drv->axi_halt_base = devm_ioremap(&pdev->dev, res->start,
resource_size(res));
if (!drv->axi_halt_base)
return ERR_PTR(-ENOMEM);
desc = &drv->desc;
ret = of_property_read_string(pdev->dev.of_node, "qcom,firmware-name",
&desc->name);
if (ret)
return ERR_PTR(ret);
drv->xo = devm_clk_get(&pdev->dev, "xo");
if (IS_ERR(drv->xo))
return ERR_CAST(drv->xo);
drv->vreg_cx = devm_regulator_get(&pdev->dev, "vdd_cx");
if (IS_ERR(drv->vreg_cx))
return ERR_CAST(drv->vreg_cx);
drv->vreg_pll = devm_regulator_get(&pdev->dev, "vdd_pll");
if (!IS_ERR(drv->vreg_pll)) {
int voltage;
ret = of_property_read_u32(pdev->dev.of_node, "qcom,vdd_pll",
&voltage);
if (ret) {
dev_err(&pdev->dev, "Failed to find vdd_pll voltage.\n");
return ERR_PTR(ret);
}
ret = regulator_set_voltage(drv->vreg_pll, voltage, voltage);
if (ret) {
dev_err(&pdev->dev, "Failed to request vdd_pll voltage.\n");
return ERR_PTR(ret);
}
ret = regulator_set_optimum_mode(drv->vreg_pll, 10000);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to set vdd_pll mode.\n");
return ERR_PTR(ret);
}
} else {
drv->vreg_pll = NULL;
}
desc->dev = &pdev->dev;
return drv;
}
示例5: crypt
//.........这里部分代码省略.........
{
struct crypto_cipher *cipher;
struct crypto_instance *inst = (void *)tfm->__crt_alg;
struct crypto_spawn *spawn = crypto_instance_ctx(inst);
struct priv *ctx = crypto_tfm_ctx(tfm);
u32 *flags = &tfm->crt_flags;
cipher = crypto_spawn_cipher(spawn);
if (IS_ERR(cipher))
return PTR_ERR(cipher);
if (crypto_cipher_blocksize(cipher) != XTS_BLOCK_SIZE) {
*flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
crypto_free_cipher(cipher);
return -EINVAL;
}
ctx->child = cipher;
cipher = crypto_spawn_cipher(spawn);
if (IS_ERR(cipher)) {
crypto_free_cipher(ctx->child);
return PTR_ERR(cipher);
}
/* */
if (crypto_cipher_blocksize(cipher) != XTS_BLOCK_SIZE) {
crypto_free_cipher(cipher);
crypto_free_cipher(ctx->child);
*flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
return -EINVAL;
}
ctx->tweak = cipher;
return 0;
}
static void exit_tfm(struct crypto_tfm *tfm)
{
struct priv *ctx = crypto_tfm_ctx(tfm);
crypto_free_cipher(ctx->child);
crypto_free_cipher(ctx->tweak);
}
static struct crypto_instance *alloc(struct rtattr **tb)
{
struct crypto_instance *inst;
struct crypto_alg *alg;
int err;
err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER);
if (err)
return ERR_PTR(err);
alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER,
CRYPTO_ALG_TYPE_MASK);
if (IS_ERR(alg))
return ERR_CAST(alg);
inst = crypto_alloc_instance("xts", alg);
if (IS_ERR(inst))
goto out_put_alg;
inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER;
inst->alg.cra_priority = alg->cra_priority;
inst->alg.cra_blocksize = alg->cra_blocksize;
if (alg->cra_alignmask < 7)
inst->alg.cra_alignmask = 7;
else
inst->alg.cra_alignmask = alg->cra_alignmask;
inst->alg.cra_type = &crypto_blkcipher_type;
inst->alg.cra_blkcipher.ivsize = alg->cra_blocksize;
inst->alg.cra_blkcipher.min_keysize =
2 * alg->cra_cipher.cia_min_keysize;
inst->alg.cra_blkcipher.max_keysize =
2 * alg->cra_cipher.cia_max_keysize;
inst->alg.cra_ctxsize = sizeof(struct priv);
inst->alg.cra_init = init_tfm;
inst->alg.cra_exit = exit_tfm;
inst->alg.cra_blkcipher.setkey = setkey;
inst->alg.cra_blkcipher.encrypt = encrypt;
inst->alg.cra_blkcipher.decrypt = decrypt;
out_put_alg:
crypto_mod_put(alg);
return inst;
}
static void free(struct crypto_instance *inst)
{
crypto_drop_spawn(crypto_instance_ctx(inst));
kfree(inst);
}
示例6: talpa__d_path
//.........这里部分代码省略.........
if (dentry->d_op && dentry->d_op->d_dname)
{
path = d_path(&pathPath, buffer, buflen);
if ( unlikely( IS_ERR(path) != 0 ) )
{
critical("talpa__d_path: d_path returned an error: %ld",PTR_ERR(path));
path = NULL;
}
if ( NULL != path )
{
return path;
}
}
#endif /* TALPA_D_DNAME_DIRECT_DPATH */
# if defined TALPA_DPATH_SLES11
path = kernel_d_path(&pathPath, &rootPath, buffer, buflen, 0);
# elif defined TALPA_DPATH_PATH
path = kernel_d_path(&pathPath, &rootPath, buffer, buflen);
# elif defined TALPA_DPATH_SUSE103
path = kernel_d_path(dentry, vfsmnt, root, rootmnt, buffer, buflen, 0);
# else
path = kernel_d_path(dentry, vfsmnt, root, rootmnt, buffer, buflen);
# endif
#else
/* Call our own version */
path = __talpa_d_path(dentry, vfsmnt, root, rootmnt, buffer, buflen);
#endif
#if defined HOLD_DCACHE_LOCK_WHILE_CALLING_D_PATH
spin_unlock(&dcache_lock);
#endif
if ( unlikely( IS_ERR(path) != 0 ) )
{
critical("talpa__d_path: kernel__d_path returned an error: %ld",PTR_ERR(path));
path = NULL;
}
else if ( unlikely( NULL == path ) )
{
#ifdef TALPA_D_DNAME_DIRECT_DPATH
/* only use this as a fall-back, it will only return the relative path from a chroot
* Use this in cases where kernel_d_path fails to return a valid path for bind mounts
* in newer kernel in a systemd environment */
path = d_path(&pathPath, buffer, buflen);
if ( unlikely( IS_ERR(path) != 0 ) )
{
critical("talpa__d_path: kernel_d_path returned an error: %ld",PTR_ERR(path));
path = NULL;
}
dbg(" dpath=%s",path);
if (dentry->d_op && dentry->d_op->d_dname)
{
err("dpath=%s - dentry has d_op and d_dname=%p",path,dentry->d_op->d_dname);
}
#endif
if ( NULL == path )
{
if (!IS_ROOT(dentry) && d_unhashed(dentry)) {
dbg("talpa__d_path: kernel_d_path returned NULL for deleted file");
dbg(" basename=%s",dentry->d_name.name);
}
else
{
info("talpa__d_path: kernel_d_path returned NULL for non-deleted file");
info(" basename=%s",dentry->d_name.name);
}
}
else
{
if (!IS_ROOT(dentry) && d_unhashed(dentry))
{
dbg(" talpa__d_path: kernel_d_path returned NULL but d_path returned path %s for deleted file",path);
}
else
{
#ifdef TALPA_MNT_NAMESPACE
if (NULL != getNamespaceInfo(vfsmnt) && (!S_ISDIR(dentry->d_inode->i_mode)))
{
/* we're in a namespace/container, append '(namespace)' to the path */
int pathlen=strlen(path);
if (pathlen + 13 > buflen)
{
return ERR_PTR(-ENAMETOOLONG);
}
memmove(buffer, path, pathlen);
path = buffer;
memcpy(buffer + pathlen, " (namespace)", 13);
}
#endif
/* the systemd / containers / bind mount case. */
dbg(" talpa__d_path: kernel_d_path returned NULL but d_path returned path %s for non-deleted file",path);
}
}
}
return path;
}
示例7: AFS_FS_I
/*
* look up an entry in a directory
*/
static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd)
{
struct afs_vnode *vnode;
struct afs_fid fid;
struct inode *inode;
struct key *key;
int ret;
vnode = AFS_FS_I(dir);
_enter("{%x:%u},%p{%s},",
vnode->fid.vid, vnode->fid.vnode, dentry, dentry->d_name.name);
ASSERTCMP(dentry->d_inode, ==, NULL);
if (dentry->d_name.len >= AFSNAMEMAX) {
_leave(" = -ENAMETOOLONG");
return ERR_PTR(-ENAMETOOLONG);
}
if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) {
_leave(" = -ESTALE");
return ERR_PTR(-ESTALE);
}
key = afs_request_key(vnode->volume->cell);
if (IS_ERR(key)) {
_leave(" = %ld [key]", PTR_ERR(key));
return ERR_CAST(key);
}
ret = afs_validate(vnode, key);
if (ret < 0) {
key_put(key);
_leave(" = %d [val]", ret);
return ERR_PTR(ret);
}
ret = afs_do_lookup(dir, dentry, &fid, key);
if (ret < 0) {
inode = afs_try_auto_mntpt(ret, dentry, dir, key, &fid);
if (!IS_ERR(inode)) {
key_put(key);
goto success;
}
ret = PTR_ERR(inode);
key_put(key);
if (ret == -ENOENT) {
d_add(dentry, NULL);
_leave(" = NULL [negative]");
return NULL;
}
_leave(" = %d [do]", ret);
return ERR_PTR(ret);
}
dentry->d_fsdata = (void *)(unsigned long) vnode->status.data_version;
/* instantiate the dentry */
inode = afs_iget(dir->i_sb, key, &fid, NULL, NULL);
key_put(key);
if (IS_ERR(inode)) {
_leave(" = %ld", PTR_ERR(inode));
return ERR_CAST(inode);
}
success:
d_add(dentry, inode);
_leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%u }",
fid.vnode,
fid.unique,
dentry->d_inode->i_ino,
dentry->d_inode->i_generation);
return NULL;
}
示例8: sizeof
//.........这里部分代码省略.........
LOGW("%s: read %s failed, %[email protected]%x\n", __func__,
dheader->name, dheader->used, dheader->offset);
}
}
return oops;
}
int ipanic(struct notifier_block *this, unsigned long event, void *ptr)
{
struct ipanic_data_header *dheader;
struct kmsg_dumper dumper;
ipanic_atf_log_rec_t atf_log = {ATF_LOG_SIZE, 0, 0};
int dt;
int errno;
struct ipanic_header *ipanic_hdr = ipanic_header();
#if 0//
return NOTIFY_DONE;
#endif
aee_rr_rec_fiq_step(AEE_FIQ_STEP_KE_IPANIC_START);
bust_spinlocks(1);
spin_lock_irq(&ipanic_lock);
aee_disable_api();
if (!ipanic_data_is_valid(IPANIC_DT_KERNEL_LOG)) {
ipanic_klog_region(&dumper);
errno = ipanic_data_to_sd(IPANIC_DT_KERNEL_LOG, &dumper);
if (errno == -1)
aee_nested_printf("$");
}
ipanic_klog_region(&dumper);
errno = ipanic_data_to_sd(IPANIC_DT_OOPS_LOG, &dumper);
if (errno == -1)
aee_nested_printf("$");
ipanic_data_to_sd(IPANIC_DT_CURRENT_TSK, 0);
/* kick wdt after save the most critical infos */
ipanic_kick_wdt();
ipanic_data_to_sd(IPANIC_DT_MAIN_LOG, (void *)1);
ipanic_data_to_sd(IPANIC_DT_SYSTEM_LOG, (void *)4);
ipanic_data_to_sd(IPANIC_DT_EVENTS_LOG, (void *)2);
ipanic_data_to_sd(IPANIC_DT_RADIO_LOG, (void *)3);
aee_wdt_dump_info();
ipanic_klog_region(&dumper);
ipanic_data_to_sd(IPANIC_DT_WDT_LOG, &dumper);
#ifdef CONFIG_MTK_WQ_DEBUG
mt_dump_wq_debugger();
#endif
ipanic_klog_region(&dumper);
ipanic_data_to_sd(IPANIC_DT_WQ_LOG, &dumper);
ipanic_data_to_sd(IPANIC_DT_MMPROFILE, 0);
ipanic_data_to_sd(IPANIC_DT_ATF_LOG, &atf_log);
errno = ipanic_header_to_sd(0);
if (!IS_ERR(ERR_PTR(errno)))
mrdump_mini_ipanic_done();
ipanic_klog_region(&dumper);
ipanic_data_to_sd(IPANIC_DT_LAST_LOG, &dumper);
LOGD("ipanic done^_^");
for (dt = IPANIC_DT_HEADER + 1; dt < IPANIC_DT_RESERVED31; dt++) {
dheader = &ipanic_hdr->data_hdr[dt];
if (dheader->valid) {
LOGD("%s[%[email protected]%x],", dheader->name, dheader->used, dheader->offset);
}
}
LOGD("^_^\n");
aee_rr_rec_fiq_step(AEE_FIQ_STEP_KE_IPANIC_DONE);
return NOTIFY_DONE;
}
void ipanic_recursive_ke(struct pt_regs *regs, struct pt_regs *excp_regs, int cpu)
{
int errno;
struct kmsg_dumper dumper;
aee_nested_printf("minidump\n");
bust_spinlocks(1);
flush_cache_all();
#ifdef __aarch64__
cpu_cache_off();
#else
cpu_proc_fin();
#endif
mrdump_mini_ke_cpu_regs(excp_regs);
mrdump_mini_per_cpu_regs(cpu, regs);
flush_cache_all();
ipanic_mrdump_mini(AEE_REBOOT_MODE_NESTED_EXCEPTION, "Nested Panic");
ipanic_data_to_sd(IPANIC_DT_CURRENT_TSK, 0);
ipanic_kick_wdt();
ipanic_klog_region(&dumper);
ipanic_data_to_sd(IPANIC_DT_KERNEL_LOG, &dumper);
errno = ipanic_header_to_sd(0);
if (!IS_ERR(ERR_PTR(errno)))
mrdump_mini_ipanic_done();
if (ipanic_dt_active(IPANIC_DT_RAM_DUMP)) {
aee_nested_printf("RAMDUMP.\n");
__mrdump_create_oops_dump(AEE_REBOOT_MODE_NESTED_EXCEPTION, excp_regs,
"Nested Panic");
}
bust_spinlocks(0);
}
示例9: f2fs_inode_by_name
struct dentry *f2fs_get_parent(struct dentry *child)
{
struct qstr dotdot = {.len = 2, .name = ".."};
unsigned long ino = f2fs_inode_by_name(child->d_inode, &dotdot);
if (!ino)
return ERR_PTR(-ENOENT);
return d_obtain_alias(f2fs_iget(child->d_inode->i_sb, ino));
}
static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd)
{
struct inode *inode = NULL;
struct f2fs_dir_entry *de;
struct page *page;
if (dentry->d_name.len > F2FS_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG);
de = f2fs_find_entry(dir, &dentry->d_name, &page, nd ? nd->flags : 0);
if (de) {
nid_t ino = le32_to_cpu(de->ino);
f2fs_dentry_kunmap(dir, page);
f2fs_put_page(page, 0);
inode = f2fs_iget(dir->i_sb, ino);
if (IS_ERR(inode))
return ERR_CAST(inode);
}
return d_splice_alias(inode, dentry);
}
static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
struct inode *inode = dentry->d_inode;
struct f2fs_dir_entry *de;
struct page *page;
int err = -ENOENT;
trace_f2fs_unlink_enter(dir, dentry);
f2fs_balance_fs(sbi);
de = f2fs_find_entry(dir, &dentry->d_name, &page, 0);
if (!de)
goto fail;
f2fs_lock_op(sbi);
err = acquire_orphan_inode(sbi);
if (err) {
f2fs_unlock_op(sbi);
f2fs_dentry_kunmap(dir, page);
f2fs_put_page(page, 0);
goto fail;
}
f2fs_delete_entry(de, page, dir, inode);
f2fs_unlock_op(sbi);
/* In order to evict this inode, we set it dirty */
mark_inode_dirty(inode);
fail:
trace_f2fs_unlink_exit(inode, err);
return err;
}
static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
const char *symname)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
struct inode *inode;
size_t symlen = strlen(symname) + 1;
int err;
f2fs_balance_fs(sbi);
inode = f2fs_new_inode(dir, S_IFLNK | S_IRWXUGO);
if (IS_ERR(inode))
return PTR_ERR(inode);
inode->i_op = &f2fs_symlink_inode_operations;
inode->i_mapping->a_ops = &f2fs_dblock_aops;
f2fs_lock_op(sbi);
err = f2fs_add_link(dentry, inode);
if (err)
goto out;
f2fs_unlock_op(sbi);
err = page_symlink(inode, symname, symlen);
alloc_nid_done(sbi, inode->i_ino);
d_instantiate(dentry, inode);
unlock_new_inode(inode);
return err;
out:
handle_failed_inode(inode);
return err;
}
//.........这里部分代码省略.........
示例10: vnode_shadow_iop_follow_link
int
#endif
vnode_shadow_iop_follow_link(
DENT_T *dentry, /* entry we are trying to resolve */
struct nameidata *nd /* Contains parent dentry */
)
{
int err = 0;
int len = PATH_MAX;
char *buff;
mm_segment_t old_fs; /* Because we provide a kernel buffer. */
INODE_T *real_inode;
DENT_T *real_dentry;
VNODE_T *cvp;
/* this function must consume a reference on base */
/* We only path_release on error. */
err = 0;
real_dentry = REALDENTRY_LOCKED(dentry, &cvp);
if (real_dentry == NULL) {
err = -ENOENT;
MDKI_PATH_RELEASE(nd);
goto out_nolock;
}
VNODE_DGET(real_dentry); /* protect inode */
if (real_dentry->d_inode == NULL) {
/* delete race */
err = -ENOENT;
MDKI_PATH_RELEASE(nd);
goto out;
}
real_inode = real_dentry->d_inode;
/* If there are no underlying symlink functions, we are done */
if (real_inode->i_op && real_inode->i_op->readlink &&
real_inode->i_op->follow_link)
{
buff = KMEM_ALLOC(len, KM_SLEEP);
if (!buff) {
MDKI_PATH_RELEASE(nd);
err = -ENOMEM;
goto out;
}
/* We're providing a kernel buffer to copy into, so let everyone know. */
old_fs = get_fs();
set_fs(KERNEL_DS);
err = vnode_shadow_iop_readlink(dentry, buff, len);
set_fs(old_fs);
if (err < 0) {
KMEM_FREE(buff, len);
MDKI_PATH_RELEASE(nd);
goto out;
}
/* done with dentry */
/* Make sure string is null terminated */
buff[err] = 0;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
err = vfs_follow_link(nd, buff);
KMEM_FREE(buff,len);
#else
VNODE_DPUT(real_dentry);
REALDENTRY_UNLOCK(dentry, cvp);
nd_set_link(nd, buff);
return(buff); /* vnop_iop_put_link() will free this buf. */
#endif
}
out:
VNODE_DPUT(real_dentry);
REALDENTRY_UNLOCK(dentry, cvp);
out_nolock:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
return ERR_PTR(err);
#else
return(err);
#endif
}
示例11: int
static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
struct file *f,
int (*open)(struct inode *, struct file *),
const struct cred *cred)
{
static const struct file_operations empty_fops = {};
struct inode *inode;
int error;
f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK |
FMODE_PREAD | FMODE_PWRITE;
if (unlikely(f->f_flags & O_PATH))
f->f_mode = FMODE_PATH;
inode = dentry->d_inode;
if (f->f_mode & FMODE_WRITE) {
error = __get_file_write_access(inode, mnt);
if (error)
goto cleanup_file;
if (!special_file(inode->i_mode))
file_take_write(f);
}
f->f_mapping = inode->i_mapping;
f->f_path.dentry = dentry;
f->f_path.mnt = mnt;
f->f_pos = 0;
file_sb_list_add(f, inode->i_sb);
if (unlikely(f->f_mode & FMODE_PATH)) {
f->f_op = &empty_fops;
return f;
}
f->f_op = fops_get(inode->i_fop);
error = security_dentry_open(f, cred);
if (error)
goto cleanup_all;
if (!open && f->f_op)
open = f->f_op->open;
if (open) {
error = open(inode, f);
if (error)
goto cleanup_all;
}
if ((f->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
i_readcount_inc(inode);
f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping);
/* NB: we're sure to have correct a_ops only after f_op->open */
if (f->f_flags & O_DIRECT) {
if (!f->f_mapping->a_ops ||
((!f->f_mapping->a_ops->direct_IO) &&
(!f->f_mapping->a_ops->get_xip_mem))) {
fput(f);
f = ERR_PTR(-EINVAL);
}
}
return f;
cleanup_all:
fops_put(f->f_op);
if (f->f_mode & FMODE_WRITE) {
put_write_access(inode);
if (!special_file(inode->i_mode)) {
/*
* We don't consider this a real
* mnt_want/drop_write() pair
* because it all happenend right
* here, so just reset the state.
*/
file_reset_write(f);
mnt_drop_write(mnt);
}
}
file_sb_list_del(f);
f->f_path.dentry = NULL;
f->f_path.mnt = NULL;
cleanup_file:
put_filp(f);
dput(dentry);
mntput(mnt);
return ERR_PTR(error);
}
示例12: adreno_drawctxt_create
/**
* adreno_drawctxt_create - create a new adreno draw context
* @dev_priv: the owner of the context
* @flags: flags for the context (passed from user space)
*
* Create and return a new draw context for the 3D core.
*/
struct kgsl_context *
adreno_drawctxt_create(struct kgsl_device_private *dev_priv,
uint32_t *flags)
{
struct adreno_context *drawctxt;
struct kgsl_device *device = dev_priv->device;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
int ret;
unsigned long local;
local = *flags & (KGSL_CONTEXT_PREAMBLE |
KGSL_CONTEXT_NO_GMEM_ALLOC |
KGSL_CONTEXT_PER_CONTEXT_TS |
KGSL_CONTEXT_USER_GENERATED_TS |
KGSL_CONTEXT_NO_FAULT_TOLERANCE |
KGSL_CONTEXT_CTX_SWITCH |
KGSL_CONTEXT_PRIORITY_MASK |
KGSL_CONTEXT_TYPE_MASK |
KGSL_CONTEXT_PWR_CONSTRAINT |
KGSL_CONTEXT_IFH_NOP |
KGSL_CONTEXT_SECURE);
/* Check for errors before trying to initialize */
/* We no longer support legacy context switching */
if ((local & KGSL_CONTEXT_PREAMBLE) == 0 ||
(local & KGSL_CONTEXT_NO_GMEM_ALLOC) == 0) {
KGSL_DEV_ERR_ONCE(device,
"legacy context switch not supported\n");
return ERR_PTR(-EINVAL);
}
/* Make sure that our target can support secure contexts if requested */
if (!kgsl_mmu_is_secured(&dev_priv->device->mmu) &&
(local & KGSL_CONTEXT_SECURE)) {
KGSL_DEV_ERR_ONCE(device, "Secure context not supported\n");
return ERR_PTR(-EOPNOTSUPP);
}
drawctxt = kzalloc(sizeof(struct adreno_context), GFP_KERNEL);
if (drawctxt == NULL)
return ERR_PTR(-ENOMEM);
ret = kgsl_context_init(dev_priv, &drawctxt->base);
if (ret != 0) {
kfree(drawctxt);
return ERR_PTR(ret);
}
drawctxt->timestamp = 0;
drawctxt->base.flags = local;
/* Always enable per-context timestamps */
drawctxt->base.flags |= KGSL_CONTEXT_PER_CONTEXT_TS;
drawctxt->type = (drawctxt->base.flags & KGSL_CONTEXT_TYPE_MASK)
>> KGSL_CONTEXT_TYPE_SHIFT;
spin_lock_init(&drawctxt->lock);
init_waitqueue_head(&drawctxt->wq);
init_waitqueue_head(&drawctxt->waiting);
/* Set the context priority */
_set_context_priority(drawctxt);
/* set the context ringbuffer */
drawctxt->rb = adreno_ctx_get_rb(adreno_dev, drawctxt);
/*
* Set up the plist node for the dispatcher. Insert the node into the
* drawctxt pending list based on priority.
*/
plist_node_init(&drawctxt->pending, drawctxt->base.priority);
kgsl_sharedmem_writel(device, &device->memstore,
KGSL_MEMSTORE_OFFSET(drawctxt->base.id, soptimestamp),
0);
kgsl_sharedmem_writel(device, &device->memstore,
KGSL_MEMSTORE_OFFSET(drawctxt->base.id, eoptimestamp),
0);
adreno_context_debugfs_init(ADRENO_DEVICE(device), drawctxt);
/* copy back whatever flags we dediced were valid */
*flags = drawctxt->base.flags;
return &drawctxt->base;
}
示例13: hfs_bmap_alloc
static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd)
{
struct hfs_btree *tree;
struct hfs_bnode *node, *new_node, *next_node;
struct hfs_bnode_desc node_desc;
int num_recs, new_rec_off, new_off, old_rec_off;
int data_start, data_end, size;
tree = fd->tree;
node = fd->bnode;
new_node = hfs_bmap_alloc(tree);
if (IS_ERR(new_node))
return new_node;
hfs_bnode_get(node);
hfs_dbg(BNODE_MOD, "split_nodes: %d - %d - %d\n",
node->this, new_node->this, node->next);
new_node->next = node->next;
new_node->prev = node->this;
new_node->parent = node->parent;
new_node->type = node->type;
new_node->height = node->height;
if (node->next)
next_node = hfs_bnode_find(tree, node->next);
else
next_node = NULL;
if (IS_ERR(next_node)) {
hfs_bnode_put(node);
hfs_bnode_put(new_node);
return next_node;
}
size = tree->node_size / 2 - node->num_recs * 2 - 14;
old_rec_off = tree->node_size - 4;
num_recs = 1;
for (;;) {
data_start = hfs_bnode_read_u16(node, old_rec_off);
if (data_start > size)
break;
old_rec_off -= 2;
if (++num_recs < node->num_recs)
continue;
/* panic? */
hfs_bnode_put(node);
hfs_bnode_put(new_node);
if (next_node)
hfs_bnode_put(next_node);
return ERR_PTR(-ENOSPC);
}
if (fd->record + 1 < num_recs) {
/* new record is in the lower half,
* so leave some more space there
*/
old_rec_off += 2;
num_recs--;
data_start = hfs_bnode_read_u16(node, old_rec_off);
} else {
hfs_bnode_put(node);
hfs_bnode_get(new_node);
fd->bnode = new_node;
fd->record -= num_recs;
fd->keyoffset -= data_start - 14;
fd->entryoffset -= data_start - 14;
}
new_node->num_recs = node->num_recs - num_recs;
node->num_recs = num_recs;
new_rec_off = tree->node_size - 2;
new_off = 14;
size = data_start - new_off;
num_recs = new_node->num_recs;
data_end = data_start;
while (num_recs) {
hfs_bnode_write_u16(new_node, new_rec_off, new_off);
old_rec_off -= 2;
new_rec_off -= 2;
data_end = hfs_bnode_read_u16(node, old_rec_off);
new_off = data_end - size;
num_recs--;
}
hfs_bnode_write_u16(new_node, new_rec_off, new_off);
hfs_bnode_copy(new_node, 14, node, data_start, data_end - data_start);
/* update new bnode header */
node_desc.next = cpu_to_be32(new_node->next);
node_desc.prev = cpu_to_be32(new_node->prev);
node_desc.type = new_node->type;
node_desc.height = new_node->height;
node_desc.num_recs = cpu_to_be16(new_node->num_recs);
node_desc.reserved = 0;
hfs_bnode_write(new_node, &node_desc, 0, sizeof(node_desc));
/* update previous bnode header */
node->next = new_node->this;
hfs_bnode_read(node, &node_desc, 0, sizeof(node_desc));
node_desc.next = cpu_to_be32(node->next);
node_desc.num_recs = cpu_to_be16(node->num_recs);
hfs_bnode_write(node, &node_desc, 0, sizeof(node_desc));
//.........这里部分代码省略.........
示例14: hpfs_lock
struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
{
const unsigned char *name = dentry->d_name.name;
unsigned len = dentry->d_name.len;
struct quad_buffer_head qbh;
struct hpfs_dirent *de;
ino_t ino;
int err;
struct inode *result = NULL;
struct hpfs_inode_info *hpfs_result;
hpfs_lock(dir->i_sb);
if ((err = hpfs_chk_name(name, &len))) {
if (err == -ENAMETOOLONG) {
hpfs_unlock(dir->i_sb);
return ERR_PTR(-ENAMETOOLONG);
}
goto end_add;
}
/*
* '.' and '..' will never be passed here.
*/
de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, NULL, &qbh);
/*
* This is not really a bailout, just means file not found.
*/
if (!de) goto end;
/*
* Get inode number, what we're after.
*/
ino = le32_to_cpu(de->fnode);
/*
* Go find or make an inode.
*/
result = iget_locked(dir->i_sb, ino);
if (!result) {
hpfs_error(dir->i_sb, "hpfs_lookup: can't get inode");
goto bail1;
}
if (result->i_state & I_NEW) {
hpfs_init_inode(result);
if (de->directory)
hpfs_read_inode(result);
else if (le32_to_cpu(de->ea_size) && hpfs_sb(dir->i_sb)->sb_eas)
hpfs_read_inode(result);
else {
result->i_mode |= S_IFREG;
result->i_mode &= ~0111;
result->i_op = &hpfs_file_iops;
result->i_fop = &hpfs_file_ops;
set_nlink(result, 1);
}
unlock_new_inode(result);
}
hpfs_result = hpfs_i(result);
if (!de->directory) hpfs_result->i_parent_dir = dir->i_ino;
if (de->has_acl || de->has_xtd_perm) if (!(dir->i_sb->s_flags & MS_RDONLY)) {
hpfs_error(result->i_sb, "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures");
goto bail1;
}
/*
* Fill in the info from the directory if this is a newly created
* inode.
*/
if (!result->i_ctime.tv_sec) {
if (!(result->i_ctime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->creation_date))))
result->i_ctime.tv_sec = 1;
result->i_ctime.tv_nsec = 0;
result->i_mtime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->write_date));
result->i_mtime.tv_nsec = 0;
result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(de->read_date));
result->i_atime.tv_nsec = 0;
hpfs_result->i_ea_size = le32_to_cpu(de->ea_size);
if (!hpfs_result->i_ea_mode && de->read_only)
result->i_mode &= ~0222;
if (!de->directory) {
if (result->i_size == -1) {
result->i_size = le32_to_cpu(de->file_size);
result->i_data.a_ops = &hpfs_aops;
hpfs_i(result)->mmu_private = result->i_size;
/*
* i_blocks should count the fnode and any anodes.
* We count 1 for the fnode and don't bother about
* anodes -- the disk heads are on the directory band
* and we want them to stay there.
*/
result->i_blocks = 1 + ((result->i_size + 511) >> 9);
}
}
//.........这里部分代码省略.........
示例15: ll_get_name
static int ll_get_name(struct dentry *dentry, char *name,
struct dentry *child)
{
struct inode *dir = d_inode(dentry);
int rc;
struct ll_getname_data lgd = {
.lgd_name = name,
.lgd_fid = ll_i2info(d_inode(child))->lli_fid,
.ctx.actor = ll_nfs_get_name_filldir,
};
if (!dir || !S_ISDIR(dir->i_mode)) {
rc = -ENOTDIR;
goto out;
}
if (!dir->i_fop) {
rc = -EINVAL;
goto out;
}
mutex_lock(&dir->i_mutex);
rc = ll_dir_read(dir, &lgd.ctx);
mutex_unlock(&dir->i_mutex);
if (!rc && !lgd.lgd_found)
rc = -ENOENT;
out:
return rc;
}
static struct dentry *ll_fh_to_dentry(struct super_block *sb, struct fid *fid,
int fh_len, int fh_type)
{
struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid;
if (fh_type != LUSTRE_NFS_FID)
return ERR_PTR(-EPROTO);
return ll_iget_for_nfs(sb, &nfs_fid->lnf_child, &nfs_fid->lnf_parent);
}
static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid,
int fh_len, int fh_type)
{
struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid;
if (fh_type != LUSTRE_NFS_FID)
return ERR_PTR(-EPROTO);
return ll_iget_for_nfs(sb, &nfs_fid->lnf_parent, NULL);
}
static struct dentry *ll_get_parent(struct dentry *dchild)
{
struct ptlrpc_request *req = NULL;
struct inode *dir = d_inode(dchild);
struct ll_sb_info *sbi;
struct dentry *result = NULL;
struct mdt_body *body;
static char dotdot[] = "..";
struct md_op_data *op_data;
int rc;
int lmmsize;
LASSERT(dir && S_ISDIR(dir->i_mode));
sbi = ll_s2sbi(dir->i_sb);
CDEBUG(D_INFO, "getting parent for (%lu,"DFID")\n",
dir->i_ino, PFID(ll_inode2fid(dir)));
rc = ll_get_default_mdsize(sbi, &lmmsize);
if (rc != 0)
return ERR_PTR(rc);
op_data = ll_prep_md_op_data(NULL, dir, NULL, dotdot,
strlen(dotdot), lmmsize,
LUSTRE_OPC_ANY, NULL);
if (IS_ERR(op_data))
return (void *)op_data;
rc = md_getattr_name(sbi->ll_md_exp, op_data, &req);
ll_finish_md_op_data(op_data);
if (rc) {
CERROR("failure %d inode %lu get parent\n", rc, dir->i_ino);
return ERR_PTR(rc);
}
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
LASSERT(body->valid & OBD_MD_FLID);
CDEBUG(D_INFO, "parent for "DFID" is "DFID"\n",
PFID(ll_inode2fid(dir)), PFID(&body->fid1));
result = ll_iget_for_nfs(dir->i_sb, &body->fid1, NULL);
ptlrpc_req_finished(req);
return result;
}
struct export_operations lustre_export_operations = {
//.........这里部分代码省略.........