本文整理汇总了C++中INODE_PKEY函数的典型用法代码示例。如果您正苦于以下问题:C++ INODE_PKEY函数的具体用法?C++ INODE_PKEY怎么用?C++ INODE_PKEY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INODE_PKEY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displace_large_file
static inline void displace_large_file(reiserfs_blocknr_hint_t *hint)
{
if ( TEST_OPTION(displace_based_on_dirid, hint->th->t_super))
hint->search_start = hint->beg + keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_dir_id), 4) % (hint->end - hint->beg);
else
hint->search_start = hint->beg + keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_objectid), 4) % (hint->end - hint->beg);
}
示例2: reiserfs_find_entry
static int reiserfs_find_entry (struct inode * dir, const char * name, int namelen, struct path * path_to_entry, struct reiserfs_dir_entry * de)
{
struct key key_to_search;
int repeat;
int retval;
if (!dir || !dir->i_sb)
return POSITION_NOT_FOUND;
if ((unsigned int)namelen > REISERFS_MAX_NAME_LEN (dir->i_sb->s_blocksize))
return POSITION_NOT_FOUND;
/* there are no entries having the same third component of key, so
fourth key component is not used */
copy_key (&key_to_search, INODE_PKEY (dir));
key_to_search.k_offset = get_third_component (name, namelen);
key_to_search.k_uniqueness = DIRENTRY_UNIQUENESS;
while (1) {
/* search for a directory item using the formed key */
if (search_by_key (dir->i_sb, &key_to_search, path_to_entry, &repeat, DISK_LEAF_NODE_LEVEL, READ_BLOCKS) == ITEM_NOT_FOUND) {
/* take previous item */
#ifdef REISERFS_CHECK
if (!PATH_LAST_POSITION (path_to_entry))
reiserfs_panic (dir->i_sb, "vs-7010: reiserfs_find_entry: search_by_key returned bad position == 0");
#endif /* REISERFS_CHECK */
PATH_LAST_POSITION (path_to_entry) --;
}
de->de_bh = PATH_PLAST_BUFFER (path_to_entry);
de->de_item_num = PATH_LAST_POSITION (path_to_entry);
de->de_ih = B_N_PITEM_HEAD (de->de_bh, de->de_item_num);
de->de_deh = B_I_DEH (de->de_bh, de->de_ih);
#ifdef REISERFS_CHECK
if (!I_IS_DIRECTORY_ITEM (de->de_ih) || COMP_SHORT_KEYS (&(de->de_ih->ih_key), INODE_PKEY (dir)))
reiserfs_panic (dir->i_sb, "vs-7020: reiserfs_find_entry: item must be an item of the same directory item as inode");
#endif /* REISERFS_CHECK */
/* we do not check whether bin_search_in_dir_item found the given key, even if so, we still have
to compare names */
bin_search_in_dir_item (de->de_ih, de->de_deh, &key_to_search, &(de->de_entry_num));
/* compare names for all entries having given hash value */
retval = linear_search_in_dir_item (&key_to_search, de, name, namelen);
if (retval != GOTO_PREVIOUS_ITEM)
/* there is no need to scan directory anymore. Given entry found or does not exist */
return retval;
/* there is left neighboring item of this directory and given entry can be there */
key_to_search.k_offset = de->de_ih->ih_key.k_offset - 1;
pathrelse (path_to_entry);
} /* while (1) */
}
示例3: hash_formatted_node
static inline void hash_formatted_node(reiserfs_blocknr_hint_t *hint)
{
char * hash_in;
if (!hint->inode)
hash_in = (char*)&hint->key.k_dir_id;
else if ( TEST_OPTION(displace_based_on_dirid, hint->th->t_super))
hash_in = (char *)(&INODE_PKEY(hint->inode)->k_dir_id);
else
hash_in = (char *)(&INODE_PKEY(hint->inode)->k_objectid);
hint->search_start = hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg);
}
示例4: open_xa_root
static struct dentry *open_xa_dir(const struct inode *inode, int flags)
{
struct dentry *xaroot, *xadir;
char namebuf[17];
xaroot = open_xa_root(inode->i_sb, flags);
if (IS_ERR(xaroot))
return xaroot;
snprintf(namebuf, sizeof(namebuf), "%X.%X",
le32_to_cpu(INODE_PKEY(inode)->k_objectid),
inode->i_generation);
mutex_lock_nested(&xaroot->d_inode->i_mutex, I_MUTEX_XATTR);
xadir = lookup_one_len(namebuf, xaroot, strlen(namebuf));
if (!IS_ERR(xadir) && !xadir->d_inode) {
int err = -ENODATA;
if (xattr_may_create(flags))
err = xattr_mkdir(xaroot->d_inode, xadir, 0700);
if (err) {
dput(xadir);
xadir = ERR_PTR(err);
}
}
mutex_unlock(&xaroot->d_inode->i_mutex);
dput(xaroot);
return xadir;
}
示例5: reiserfs_choose_packing
/*
* the packing is returned in disk byte order
*/
u32 reiserfs_choose_packing(struct inode *dir) {
u32 packing;
if (TEST_OPTION(packing_groups, dir->i_sb)) {
u32 parent_dir = le32_to_cpu(INODE_PKEY(dir)->k_dir_id);
/*
* some versions of reiserfsck expect packing locality 1 to be
* special
*/
if (parent_dir == 1 || block_group_used(dir->i_sb,parent_dir))
packing = INODE_PKEY(dir)->k_objectid;
else
packing = INODE_PKEY(dir)->k_dir_id;
} else
packing = INODE_PKEY(dir)->k_objectid;
return packing;
}
示例6: is_privroot_deh
static inline bool is_privroot_deh(struct dentry *dir,
struct reiserfs_de_head *deh)
{
struct dentry *privroot = REISERFS_SB(dir->d_sb)->priv_root;
return (dir == dir->d_parent && privroot->d_inode &&
deh->deh_objectid == INODE_PKEY(privroot->d_inode)->k_objectid);
}
示例7: reiserfs_link
int reiserfs_link (struct dentry * old_dentry, struct inode * dir, struct dentry * dentry)
{
struct inode *inode = old_dentry->d_inode;
struct path path_to_entry;
struct reiserfs_dir_entry de;
int error;
int windex ;
struct reiserfs_transaction_handle th ;
int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3;
init_path (&path_to_entry);
/* object must not be directory */
if (S_ISDIR(inode->i_mode)) {
return -EPERM;
}
/* file has too many links */
if (inode->i_nlink >= REISERFS_LINK_MAX) {
return -EMLINK;
}
journal_begin(&th, dir->i_sb, jbegin_count) ;
windex = push_journal_writer("reiserfs_link") ;
reiserfs_update_inode_transaction(inode) ;
reiserfs_update_inode_transaction(dir) ;
de.de_gen_number_bit_string = 0;
if (reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path_to_entry, &de) == POSITION_FOUND) {
pathrelse (&path_to_entry);
pop_journal_writer(windex) ;
journal_end(&th, dir->i_sb, jbegin_count) ;
return -EEXIST;
}
pathrelse (&path_to_entry);
/* free preserve list if we should */
/* maybe_free_preserve_list (dir->i_sb);*/
/* create new entry */
error = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len, INODE_PKEY (inode), &de, 1);
if (error) {
pop_journal_writer(windex) ;
journal_end(&th, dir->i_sb, jbegin_count) ;
return error;
}
inode->i_nlink++;
inode->i_ctime = CURRENT_TIME;
if_in_ram_update_sd (&th, inode);
if_in_ram_update_sd (&th, dir);
inode->i_count++;
d_instantiate(dentry, inode);
pop_journal_writer(windex) ;
journal_end(&th, dir->i_sb, jbegin_count) ;
return 0;
}
示例8: new_inode_init
/* utility function that does setup for reiserfs_new_inode.
** dquot_initialize needs lots of credits so it's better to have it
** outside of a transaction, so we had to pull some bits of
** reiserfs_new_inode out into this func.
*/
static int new_inode_init(struct inode *inode, struct inode *dir, umode_t mode)
{
/* Make inode invalid - just in case we are going to drop it before
* the initialization happens */
INODE_PKEY(inode)->k_objectid = 0;
/* the quota init calls have to know who to charge the quota to, so
** we have to set uid and gid here
*/
inode_init_owner(inode, dir, mode);
dquot_initialize(inode);
return 0;
}
示例9: old_way
static inline int old_way (reiserfs_blocknr_hint_t * hint)
{
b_blocknr_t border;
if (hint->formatted_node || hint->inode == NULL) {
return 0;
}
border = hint->beg + le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id) % (hint->end - hint->beg);
if (border > hint->search_start)
hint->search_start = border;
return 1;
}
示例10: INITIALIZE_PATH
static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd)
{
int retval;
struct inode *inode = NULL;
struct reiserfs_dir_entry de;
INITIALIZE_PATH(path_to_entry);
if (REISERFS_MAX_NAME(dir->i_sb->s_blocksize) < dentry->d_name.len)
return ERR_PTR(-ENAMETOOLONG);
reiserfs_write_lock(dir->i_sb);
de.de_gen_number_bit_string = NULL;
retval =
reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
&path_to_entry, &de);
pathrelse(&path_to_entry);
if (retval == NAME_FOUND) {
/* Hide the .reiserfs_priv directory */
if (reiserfs_xattrs(dir->i_sb) &&
!old_format_only(dir->i_sb) &&
REISERFS_SB(dir->i_sb)->priv_root &&
REISERFS_SB(dir->i_sb)->priv_root->d_inode &&
de.de_objectid ==
le32_to_cpu(INODE_PKEY
(REISERFS_SB(dir->i_sb)->priv_root->d_inode)->
k_objectid)) {
reiserfs_write_unlock(dir->i_sb);
return ERR_PTR(-EACCES);
}
inode =
reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
if (!inode || IS_ERR(inode)) {
reiserfs_write_unlock(dir->i_sb);
return ERR_PTR(-EACCES);
}
/* Propogate the priv_object flag so we know we're in the priv tree */
if (is_reiserfs_priv_object(dir))
reiserfs_mark_inode_private(inode);
}
reiserfs_write_unlock(dir->i_sb);
if (retval == IO_ERROR) {
return ERR_PTR(-EIO);
}
return d_splice_alias(inode, dentry);
}
示例11: oid_groups
/*
* Relocation based on oid, hashing them into a given bitmap block
* files. Formatted nodes are unaffected, a seperate policy covers them
*/
static void
oid_groups (reiserfs_blocknr_hint_t *hint)
{
if (hint->inode) {
unsigned long hash;
__u32 oid;
__u32 dirid;
int bm;
dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id);
/* keep the root dir and it's first set of subdirs close to
* the start of the disk
*/
if (dirid <= 2)
hash = (hint->inode->i_sb->s_blocksize << 3);
else {
oid = le32_to_cpu(INODE_PKEY(hint->inode)->k_objectid);
bm = bmap_hash_id(hint->inode->i_sb, oid);
hash = bm * (hint->inode->i_sb->s_blocksize << 3);
}
hint->search_start = hash;
}
}
示例12: old_hashed_relocation
static inline int old_hashed_relocation (reiserfs_blocknr_hint_t * hint)
{
b_blocknr_t border;
u32 hash_in;
if (hint->formatted_node || hint->inode == NULL) {
return 0;
}
hash_in = le32_to_cpu((INODE_PKEY(hint->inode))->k_dir_id);
border = hint->beg + (u32) keyed_hash(((char *) (&hash_in)), 4) % (hint->end - hint->beg - 1);
if (border > hint->search_start)
hint->search_start = border;
return 1;
}
示例13: reiserfs_create
int reiserfs_create (struct inode * dir, struct dentry *dentry, int mode)
{
int error;
struct inode * inode;
struct reiserfs_dir_entry de;
int windex ;
int jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 ;
struct reiserfs_transaction_handle th ;
int err;
if (!dir)
return -ENOENT;
inode = get_empty_inode() ;
if (!inode) {
return -ENOSPC ;
}
journal_begin(&th, dir->i_sb, jbegin_count) ;
th.t_caller = "create" ;
windex = push_journal_writer("reiserfs_create") ;
inode = reiserfs_new_inode (&th, dir, mode, 0, dentry, inode, &err);
if (!inode) {
pop_journal_writer(windex) ;
journal_end(&th, dir->i_sb, jbegin_count) ;
return err;
}
reiserfs_update_inode_transaction(inode) ;
reiserfs_update_inode_transaction(dir) ;
inode->i_op = &reiserfs_file_inode_operations;
inode->i_mode = mode;
error = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len, INODE_PKEY (inode), &de, 1);
if (error) {
inode->i_nlink--;
if_in_ram_update_sd (&th, inode);
pop_journal_writer(windex) ;
journal_end(&th, dir->i_sb, jbegin_count) ;
iput (inode);
return error;
}
if_in_ram_update_sd (&th, dir);
d_instantiate(dentry, inode);
pop_journal_writer(windex) ;
journal_end(&th, dir->i_sb, jbegin_count) ;
return 0;
}
示例14: dirid_groups
/*
* Relocation based on dirid, hashing them into a given bitmap block
* files. Formatted nodes are unaffected, a seperate policy covers them
*/
static void
dirid_groups (reiserfs_blocknr_hint_t *hint)
{
unsigned long hash;
__u32 dirid = 0;
int bm = 0;
struct super_block *sb = hint->th->t_super;
if (hint->inode)
dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id);
else if (hint->formatted_node)
dirid = hint->key.k_dir_id;
if (dirid) {
bm = bmap_hash_id(sb, dirid);
hash = bm * (sb->s_blocksize << 3);
/* give a portion of the block group to metadata */
if (hint->inode)
hash += sb->s_blocksize/2;
hint->search_start = hash;
}
}
示例15: new_inode_init
/* utility function that does setup for reiserfs_new_inode.
** dquot_initialize needs lots of credits so it's better to have it
** outside of a transaction, so we had to pull some bits of
** reiserfs_new_inode out into this func.
*/
static int new_inode_init(struct inode *inode, struct inode *dir, int mode)
{
/* the quota init calls have to know who to charge the quota to, so
** we have to set uid and gid here
*/
inode->i_uid = current_fsuid();
inode->i_mode = mode;
/* Make inode invalid - just in case we are going to drop it before
* the initialization happens */
INODE_PKEY(inode)->k_objectid = 0;
if (dir->i_mode & S_ISGID) {
inode->i_gid = dir->i_gid;
if (S_ISDIR(mode))
inode->i_mode |= S_ISGID;
} else {
inode->i_gid = current_fsgid();
}
dquot_initialize(inode);
return 0;
}