本文整理汇总了C++中cpu_key_k_offset函数的典型用法代码示例。如果您正苦于以下问题:C++ cpu_key_k_offset函数的具体用法?C++ cpu_key_k_offset怎么用?C++ cpu_key_k_offset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cpu_key_k_offset函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: comp_keys
/* k1 is pointer to on-disk structure which is stored in little-endian
form. k2 is pointer to cpu variable.
Compare keys using all 4 key fields.
Returns: -1 if key1 < key2 0
if key1 = key2 1 if key1 > key2 */
static inline int comp_keys(const struct reiserfs_key *le_key,
const struct cpu_key *cpu_key)
{
int retval;
retval = comp_short_keys(le_key, cpu_key);
if (retval)
return retval;
if (le_key_k_offset(le_key_version(le_key), le_key) <
cpu_key_k_offset(cpu_key))
return -1;
if (le_key_k_offset(le_key_version(le_key), le_key) >
cpu_key_k_offset(cpu_key))
return 1;
if (cpu_key->key_length == 3)
return 0;
/* this part is needed only when tail conversion is in progress */
if (le_key_k_type(le_key_version(le_key), le_key) <
cpu_key_k_type(cpu_key))
return -1;
if (le_key_k_type(le_key_version(le_key), le_key) >
cpu_key_k_type(cpu_key))
return 1;
return 0;
}
开发者ID:pemargo,项目名称:asuswrt-merlin,代码行数:34,代码来源:stree.c
示例2: comp_keys
/*
* k1 is pointer to on-disk structure which is stored in little-endian
* form. k2 is pointer to cpu variable. Compare keys using all 4 key
* fields.
* Returns: -1 if key1 < key2, 0 if key1 = key2 or 1 if key1 > key2
*/
/*inline*/ int
comp_keys(const struct key *le_key, const struct cpu_key *cpu_key)
{
int retval;
retval = comp_short_keys(le_key, cpu_key);
if (retval)
return retval;
if (le_key_k_offset(le_key_version(le_key), le_key) <
cpu_key_k_offset(cpu_key))
return (-1);
if (le_key_k_offset(le_key_version(le_key), le_key) >
cpu_key_k_offset(cpu_key))
return (1);
if (cpu_key->key_length == 3)
return (0);
/* This part is needed only when tail conversion is in progress */
if (le_key_k_type(le_key_version(le_key), le_key) <
cpu_key_k_type(cpu_key))
return (-1);
if (le_key_k_type(le_key_version(le_key), le_key) >
cpu_key_k_type(cpu_key))
return (1);
return (0);
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:36,代码来源:reiserfs_stree.c
示例3: reiserfs_cpu_offset
static char * reiserfs_cpu_offset (struct cpu_key * key)
{
if (cpu_key_k_type(key) == TYPE_DIRENTRY)
sprintf (off_buf, "%Lu(%Lu)",
(unsigned long long)GET_HASH_VALUE (cpu_key_k_offset (key)),
(unsigned long long)GET_GENERATION_NUMBER (cpu_key_k_offset (key)));
else
sprintf (off_buf, "0x%Lx", (unsigned long long)cpu_key_k_offset (key));
return off_buf;
}
开发者ID:fgeraci,项目名称:cs518-sched,代码行数:10,代码来源:prints.c
示例4: search_by_entry_key
/* The function is NOT SCHEDULE-SAFE! */
int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
struct treepath *path, struct reiserfs_dir_entry *de)
{
int retval;
retval = search_item(sb, key, path);
switch (retval) {
case ITEM_NOT_FOUND:
if (!PATH_LAST_POSITION(path)) {
reiserfs_error(sb, "vs-7000", "search_by_key "
"returned item position == 0");
pathrelse(path);
return IO_ERROR;
}
PATH_LAST_POSITION(path)--;
case ITEM_FOUND:
break;
case IO_ERROR:
return retval;
default:
pathrelse(path);
reiserfs_error(sb, "vs-7002", "no path to here");
return IO_ERROR;
}
set_de_item_location(de, path);
#ifdef CONFIG_REISERFS_CHECK
if (!is_direntry_le_ih(de->de_ih) ||
COMP_SHORT_KEYS(&de->de_ih->ih_key, key)) {
print_block(de->de_bh, 0, -1, -1);
reiserfs_panic(sb, "vs-7005", "found item %h is not directory "
"item or does not belong to the same directory "
"as key %K", de->de_ih, key);
}
#endif /* CONFIG_REISERFS_CHECK */
/*
* binary search in directory item by third component of the
* key. sets de->de_entry_num of de
*/
retval = bin_search_in_dir_item(de, cpu_key_k_offset(key));
path->pos_in_item = de->de_entry_num;
if (retval != NAME_NOT_FOUND) {
/*
* ugly, but rename needs de_bh, de_deh, de_name,
* de_namelen, de_objectid set
*/
set_de_name_and_namelen(de);
set_de_object_key(de);
}
return retval;
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:57,代码来源:namei.c
示例5: search_by_entry_key
/*
* We assign a key to each directory item, and place multiple entries in
* a single directory item. A directory item has a key equal to the key
* of the first directory entry in it.
*
* This function first calls search_by_key, then, if item whose first
* entry matches is not found it looks for the entry inside directory
* item found by search_by_key. Fills the path to the entry, and to the
* entry position in the item
*/
int
search_by_entry_key(struct reiserfs_sb_info *sbi,
const struct cpu_key *key, struct path *path,
struct reiserfs_dir_entry *de)
{
int retval;
reiserfs_log(LOG_DEBUG, "searching in (objectid=%d,dirid=%d)\n",
key->on_disk_key.k_objectid, key->on_disk_key.k_dir_id);
retval = search_item(sbi, key, path);
switch (retval) {
case ITEM_NOT_FOUND:
if (!PATH_LAST_POSITION(path)) {
reiserfs_log(LOG_DEBUG,
"search_by_key returned item position == 0");
pathrelse(path);
return (IO_ERROR);
}
PATH_LAST_POSITION(path)--;
reiserfs_log(LOG_DEBUG, "search_by_key did not found it\n");
break;
case ITEM_FOUND:
reiserfs_log(LOG_DEBUG, "search_by_key found it\n");
break;
case IO_ERROR:
return (retval);
default:
pathrelse(path);
reiserfs_log(LOG_DEBUG, "no path to here");
return (IO_ERROR);
}
reiserfs_log(LOG_DEBUG, "set item location\n");
set_de_item_location(de, path);
/*
* Binary search in directory item by third component of the
* key. Sets de->de_entry_num of de
*/
reiserfs_log(LOG_DEBUG, "bin_search_in_dir_item\n");
retval = bin_search_in_dir_item(de, cpu_key_k_offset(key));
path->pos_in_item = de->de_entry_num;
if (retval != NAME_NOT_FOUND) {
/*
* Ugly, but rename needs de_bp, de_deh, de_name, de_namelen,
* de_objectid set
*/
set_de_name_and_namelen(de);
set_de_object_key(de);
reiserfs_log(LOG_DEBUG, "set (objectid=%d,dirid=%d)\n",
de->de_objectid, de->de_dir_id);
}
return (retval);
}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:65,代码来源:reiserfs_namei.c
示例6: reiserfs_readdir
static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldir)
{
struct inode *inode = filp->f_dentry->d_inode;
struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
INITIALIZE_PATH (path_to_entry);
struct buffer_head * bh;
int item_num, entry_num;
const struct key * rkey;
struct item_head * ih, tmp_ih;
int search_res;
char * local_buf;
loff_t next_pos;
char small_buf[32] ; /* avoid kmalloc if we can */
struct reiserfs_dir_entry de;
reiserfs_check_lock_depth("readdir") ;
/* form key for search the next directory entry using f_pos field of
file structure */
make_cpu_key (&pos_key, inode, (filp->f_pos) ? (filp->f_pos) : DOT_OFFSET,
TYPE_DIRENTRY, 3);
next_pos = cpu_key_k_offset (&pos_key);
/* reiserfs_warning ("reiserfs_readdir 1: f_pos = %Ld\n", filp->f_pos);*/
while (1) {
research:
/* search the directory item, containing entry with specified key */
search_res = search_by_entry_key (inode->i_sb, &pos_key, &path_to_entry, &de);
if (search_res == IO_ERROR) {
// FIXME: we could just skip part of directory which could
// not be read
return -EIO;
}
entry_num = de.de_entry_num;
bh = de.de_bh;
item_num = de.de_item_num;
ih = de.de_ih;
store_ih (&tmp_ih, ih);
/* we must have found item, that is item of this directory, */
RFALSE( COMP_SHORT_KEYS (&(ih->ih_key), &pos_key),
"vs-9000: found item %h does not match to dir we readdir %K",
ih, &pos_key);
RFALSE( item_num > B_NR_ITEMS (bh) - 1,
"vs-9005 item_num == %d, item amount == %d",
item_num, B_NR_ITEMS (bh));
/* and entry must be not more than number of entries in the item */
RFALSE( I_ENTRY_COUNT (ih) < entry_num,
"vs-9010: entry number is too big %d (%d)",
entry_num, I_ENTRY_COUNT (ih));
if (search_res == POSITION_FOUND || entry_num < I_ENTRY_COUNT (ih)) {
/* go through all entries in the directory item beginning from the entry, that has been found */
struct reiserfs_de_head * deh = B_I_DEH (bh, ih) + entry_num;
for (; entry_num < I_ENTRY_COUNT (ih); entry_num ++, deh ++) {
int d_reclen;
char * d_name;
off_t d_off;
ino_t d_ino;
if (!de_visible (deh))
/* it is hidden entry */
continue;
d_reclen = entry_length (bh, ih, entry_num);
d_name = B_I_DEH_ENTRY_FILE_NAME (bh, ih, deh);
if (!d_name[d_reclen - 1])
d_reclen = strlen (d_name);
if (d_reclen > REISERFS_MAX_NAME_LEN(inode->i_sb->s_blocksize)){
/* too big to send back to VFS */
continue ;
}
d_off = deh_offset (deh);
filp->f_pos = d_off ;
d_ino = deh_objectid (deh);
if (d_reclen <= 32) {
local_buf = small_buf ;
} else {
local_buf = reiserfs_kmalloc(d_reclen, GFP_NOFS, inode->i_sb) ;
if (!local_buf) {
pathrelse (&path_to_entry);
return -ENOMEM ;
}
if (item_moved (&tmp_ih, &path_to_entry)) {
reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
goto research;
}
}
// Note, that we copy name to user space via temporary
// buffer (local_buf) because filldir will block if
// user space buffer is swapped out. At that time
// entry can move to somewhere else
memcpy (local_buf, d_name, d_reclen);
if (filldir (dirent, local_buf, d_reclen, d_off, d_ino,
DT_UNKNOWN) < 0) {
if (local_buf != small_buf) {
//.........这里部分代码省略.........
开发者ID:niubl,项目名称:camera_project,代码行数:101,代码来源:dir.c
示例7: search_for_position_by_key
/* The function is NOT SCHEDULE-SAFE! */
int
search_for_position_by_key(struct reiserfs_sb_info *p_s_sbi,
const struct cpu_key *p_cpu_key, /* Key to search (cpu variable) */
struct path *p_s_search_path) /* Filled up by this function. */
{
int retval, n_blk_size;
off_t item_offset, offset;
struct item_head *p_le_ih; /* Pointer to on-disk structure */
struct reiserfs_dir_entry de;
/* If searching for directory entry. */
if (is_direntry_cpu_key(p_cpu_key))
return (search_by_entry_key(p_s_sbi, p_cpu_key,
p_s_search_path, &de));
/* If not searching for directory entry. */
/* If item is found. */
retval = search_item(p_s_sbi, p_cpu_key, p_s_search_path);
if (retval == IO_ERROR)
return (retval);
if (retval == ITEM_FOUND) {
if (ih_item_len(B_N_PITEM_HEAD(
PATH_PLAST_BUFFER(p_s_search_path),
PATH_LAST_POSITION(p_s_search_path))) == 0) {
reiserfs_log(LOG_WARNING, "item length equals zero\n");
}
pos_in_item(p_s_search_path) = 0;
return (POSITION_FOUND);
}
if (PATH_LAST_POSITION(p_s_search_path) == 0) {
reiserfs_log(LOG_WARNING, "position equals zero\n");
}
/* Item is not found. Set path to the previous item. */
p_le_ih = B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_search_path),
--PATH_LAST_POSITION(p_s_search_path));
n_blk_size = p_s_sbi->s_blocksize;
if (comp_short_keys(&(p_le_ih->ih_key), p_cpu_key)) {
return (FILE_NOT_FOUND);
}
item_offset = le_ih_k_offset(p_le_ih);
offset = cpu_key_k_offset(p_cpu_key);
/* Needed byte is contained in the item pointed to by the path.*/
if (item_offset <= offset &&
item_offset + op_bytes_number(p_le_ih, n_blk_size) > offset) {
pos_in_item(p_s_search_path) = offset - item_offset;
if (is_indirect_le_ih(p_le_ih)) {
pos_in_item(p_s_search_path) /= n_blk_size;
}
return (POSITION_FOUND);
}
/* Needed byte is not contained in the item pointed to by the
* path. Set pos_in_item out of the item. */
if (is_indirect_le_ih(p_le_ih))
pos_in_item(p_s_search_path) =
ih_item_len(p_le_ih) / UNFM_P_SIZE;
else
pos_in_item(p_s_search_path) =
ih_item_len(p_le_ih);
return (POSITION_NOT_FOUND);
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:70,代码来源:reiserfs_stree.c
示例8: reiserfs_add_entry
static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
struct inode *dir, const char *name, int namelen,
struct inode *inode, int visible)
{
struct cpu_key entry_key;
struct reiserfs_de_head *deh;
INITIALIZE_PATH(path);
struct reiserfs_dir_entry de;
DECLARE_BITMAP(bit_string, MAX_GENERATION_NUMBER + 1);
int gen_number;
char small_buf[32 + DEH_SIZE]; /* 48 bytes now and we avoid kmalloc
if we create file with short name */
char *buffer;
int buflen, paste_size;
int retval;
BUG_ON(!th->t_trans_id);
/* cannot allow items to be added into a busy deleted directory */
if (!namelen)
return -EINVAL;
if (namelen > REISERFS_MAX_NAME(dir->i_sb->s_blocksize))
return -ENAMETOOLONG;
/* each entry has unique key. compose it */
make_cpu_key(&entry_key, dir,
get_third_component(dir->i_sb, name, namelen),
TYPE_DIRENTRY, 3);
/* get memory for composing the entry */
buflen = DEH_SIZE + ROUND_UP(namelen);
if (buflen > sizeof(small_buf)) {
buffer = kmalloc(buflen, GFP_NOFS);
if (!buffer)
return -ENOMEM;
} else
buffer = small_buf;
paste_size =
(get_inode_sd_version(dir) ==
STAT_DATA_V1) ? (DEH_SIZE + namelen) : buflen;
/* fill buffer : directory entry head, name[, dir objectid | , stat data | ,stat data, dir objectid ] */
deh = (struct reiserfs_de_head *)buffer;
deh->deh_location = 0; /* JDM Endian safe if 0 */
put_deh_offset(deh, cpu_key_k_offset(&entry_key));
deh->deh_state = 0; /* JDM Endian safe if 0 */
/* put key (ino analog) to de */
deh->deh_dir_id = INODE_PKEY(inode)->k_dir_id; /* safe: k_dir_id is le */
deh->deh_objectid = INODE_PKEY(inode)->k_objectid; /* safe: k_objectid is le */
/* copy name */
memcpy((char *)(deh + 1), name, namelen);
/* padd by 0s to the 4 byte boundary */
padd_item((char *)(deh + 1), ROUND_UP(namelen), namelen);
/* entry is ready to be pasted into tree, set 'visibility' and 'stat data in entry' attributes */
mark_de_without_sd(deh);
visible ? mark_de_visible(deh) : mark_de_hidden(deh);
/* find the proper place for the new entry */
memset(bit_string, 0, sizeof(bit_string));
de.de_gen_number_bit_string = bit_string;
retval = reiserfs_find_entry(dir, name, namelen, &path, &de);
if (retval != NAME_NOT_FOUND) {
if (buffer != small_buf)
kfree(buffer);
pathrelse(&path);
if (retval == IO_ERROR) {
return -EIO;
}
if (retval != NAME_FOUND) {
reiserfs_error(dir->i_sb, "zam-7002",
"reiserfs_find_entry() returned "
"unexpected value (%d)", retval);
}
return -EEXIST;
}
gen_number =
find_first_zero_bit(bit_string,
MAX_GENERATION_NUMBER + 1);
if (gen_number > MAX_GENERATION_NUMBER) {
/* there is no free generation number */
reiserfs_warning(dir->i_sb, "reiserfs-7010",
"Congratulations! we have got hash function "
"screwed up");
if (buffer != small_buf)
kfree(buffer);
pathrelse(&path);
return -EBUSY;
}
/* adjust offset of directory enrty */
put_deh_offset(deh, SET_GENERATION_NUMBER(deh_offset(deh), gen_number));
set_cpu_key_k_offset(&entry_key, deh_offset(deh));
//.........这里部分代码省略.........
开发者ID:adyjl,项目名称:DORIMANX_LG_STOCK_LP_KERNEL,代码行数:101,代码来源:namei.c
示例9: linear_search_in_dir_item
static int linear_search_in_dir_item(struct cpu_key *key,
struct reiserfs_dir_entry *de,
const char *name, int namelen)
{
struct reiserfs_de_head *deh = de->de_deh;
int retval;
int i;
i = de->de_entry_num;
if (i == I_ENTRY_COUNT(de->de_ih) ||
GET_HASH_VALUE(deh_offset(deh + i)) !=
GET_HASH_VALUE(cpu_key_k_offset(key))) {
i--;
}
RFALSE(de->de_deh != B_I_DEH(de->de_bh, de->de_ih),
"vs-7010: array of entry headers not found");
deh += i;
for (; i >= 0; i--, deh--) {
if (GET_HASH_VALUE(deh_offset(deh)) !=
GET_HASH_VALUE(cpu_key_k_offset(key))) {
// hash value does not match, no need to check whole name
return NAME_NOT_FOUND;
}
/* mark, that this generation number is used */
if (de->de_gen_number_bit_string)
set_bit(GET_GENERATION_NUMBER(deh_offset(deh)),
de->de_gen_number_bit_string);
// calculate pointer to name and namelen
de->de_entry_num = i;
set_de_name_and_namelen(de);
if ((retval =
reiserfs_match(de, name, namelen)) != NAME_NOT_FOUND) {
// de's de_name, de_namelen, de_recordlen are set. Fill the rest:
// key of pointed object
set_de_object_key(de);
store_de_entry_key(de);
// retval can be NAME_FOUND or NAME_FOUND_INVISIBLE
return retval;
}
}
if (GET_GENERATION_NUMBER(le_ih_k_offset(de->de_ih)) == 0)
/* we have reached left most entry in the node. In common we
have to go to the left neighbor, but if generation counter
is 0 already, we know for sure, that there is no name with
the same hash value */
// FIXME: this work correctly only because hash value can not
// be 0. Btw, in case of Yura's hash it is probably possible,
// so, this is a bug
return NAME_NOT_FOUND;
RFALSE(de->de_item_num,
"vs-7015: two diritems of the same directory in one node?");
return GOTO_PREVIOUS_ITEM;
}
开发者ID:adyjl,项目名称:DORIMANX_LG_STOCK_LP_KERNEL,代码行数:66,代码来源:namei.c
示例10: linear_search_in_dir_item
/*
* de's de_bh, de_ih, de_deh, de_item_num, de_entry_num are set already
* Used when hash collisions exist
*/
static int
linear_search_in_dir_item(struct cpu_key *key, struct reiserfs_dir_entry *de,
const char *name, int namelen)
{
int i;
int retval;
struct reiserfs_de_head * deh = de->de_deh;
i = de->de_entry_num;
if (i == I_ENTRY_COUNT(de->de_ih) ||
GET_HASH_VALUE(deh_offset(deh + i)) !=
GET_HASH_VALUE(cpu_key_k_offset(key))) {
i--;
}
/*RFALSE( de->de_deh != B_I_DEH (de->de_bh, de->de_ih),
"vs-7010: array of entry headers not found");*/
deh += i;
for (; i >= 0; i--, deh--) {
if (GET_HASH_VALUE(deh_offset(deh)) !=
GET_HASH_VALUE(cpu_key_k_offset(key))) {
/*
* Hash value does not match, no need to check
* whole name
*/
reiserfs_log(LOG_DEBUG, "name `%s' not found\n", name);
return (NAME_NOT_FOUND);
}
/* Mark that this generation number is used */
if (de->de_gen_number_bit_string)
set_bit(GET_GENERATION_NUMBER(deh_offset(deh)),
(unsigned long *)de->de_gen_number_bit_string);
/* Calculate pointer to name and namelen */
de->de_entry_num = i;
set_de_name_and_namelen(de);
if ((retval = reiserfs_match(de, name, namelen)) !=
NAME_NOT_FOUND) {
/*
* de's de_name, de_namelen, de_recordlen are set.
* Fill the rest:
*/
/* key of pointed object */
set_de_object_key(de);
store_de_entry_key(de);
/* retval can be NAME_FOUND or NAME_FOUND_INVISIBLE */
reiserfs_log(LOG_DEBUG,
"reiserfs_match answered `%d'\n",
retval);
return (retval);
}
}
if (GET_GENERATION_NUMBER(le_ih_k_offset(de->de_ih)) == 0)
/*
* We have reached left most entry in the node. In common
* we have to go to the left neighbor, but if generation
* counter is 0 already, we know for sure, that there is
* no name with the same hash value
*/
/* FIXME: this work correctly only because hash value can
* not be 0. Btw, in case of Yura's hash it is probably
* possible, so, this is a bug
*/
return (NAME_NOT_FOUND);
/*RFALSE(de->de_item_num,
"vs-7015: two diritems of the same directory in one node?");*/
return (GOTO_PREVIOUS_ITEM);
}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:81,代码来源:reiserfs_namei.c
示例11: reiserfs_readdir
int
reiserfs_readdir(struct vop_readdir_args /* {
struct vnode *a_vp;
struct uio *a_uio;
struct ucred *a_cred;
int *a_eofflag;
int *a_ncookies;
u_long **a_cookies;
} */*ap)
{
int error = 0;
struct dirent dstdp;
struct uio *uio = ap->a_uio;
off_t next_pos;
struct buf *bp;
struct item_head *ih;
struct cpu_key pos_key;
const struct key *rkey;
struct reiserfs_node *ip;
struct reiserfs_dir_entry de;
INITIALIZE_PATH(path_to_entry);
int entry_num, item_num, search_res;
/* The NFS part */
int ncookies = 0;
u_long *cookies = NULL;
/*
* Form key for search the next directory entry using f_pos field of
* file structure
*/
ip = VTOI(ap->a_vp);
make_cpu_key(&pos_key,
ip, uio->uio_offset ? uio->uio_offset : DOT_OFFSET,
TYPE_DIRENTRY, 3);
next_pos = cpu_key_k_offset(&pos_key);
reiserfs_log(LOG_DEBUG, "listing entries for "
"(objectid=%d, dirid=%d)\n",
pos_key.on_disk_key.k_objectid, pos_key.on_disk_key.k_dir_id);
reiserfs_log(LOG_DEBUG, "uio_offset = %jd, uio_resid = %d\n",
(intmax_t)uio->uio_offset, uio->uio_resid);
if (ap->a_ncookies && ap->a_cookies) {
cookies = (u_long *)malloc(
uio->uio_resid / 16 * sizeof(u_long),
M_REISERFSCOOKIES, M_WAITOK);
}
while (1) {
//research:
/*
* Search the directory item, containing entry with
* specified key
*/
reiserfs_log(LOG_DEBUG, "search directory to read\n");
search_res = search_by_entry_key(ip->i_reiserfs, &pos_key,
&path_to_entry, &de);
if (search_res == IO_ERROR) {
error = EIO;
goto out;
}
entry_num = de.de_entry_num;
item_num = de.de_item_num;
bp = de.de_bp;
ih = de.de_ih;
if (search_res == POSITION_FOUND ||
entry_num < I_ENTRY_COUNT(ih)) {
/*
* Go through all entries in the directory item
* beginning from the entry, that has been found.
*/
struct reiserfs_de_head *deh = B_I_DEH(bp, ih) +
entry_num;
if (ap->a_ncookies == NULL) {
cookies = NULL;
} else {
//ncookies =
}
reiserfs_log(LOG_DEBUG,
"walking through directory entries\n");
for (; entry_num < I_ENTRY_COUNT(ih);
entry_num++, deh++) {
int d_namlen;
char *d_name;
off_t d_off;
ino_t d_ino;
if (!de_visible(deh)) {
/* It is hidden entry */
continue;
}
d_namlen = entry_length(bp, ih, entry_num);
d_name = B_I_DEH_ENTRY_FILE_NAME(bp, ih, deh);
//.........这里部分代码省略.........
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:101,代码来源:reiserfs_namei.c
示例12: reiserfs_readdir_dentry
int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
filldir_t filldir, loff_t *pos)
{
struct inode *inode = dentry->d_inode;
struct cpu_key pos_key;
INITIALIZE_PATH(path_to_entry);
struct buffer_head *bh;
int item_num, entry_num;
const struct reiserfs_key *rkey;
struct item_head *ih, tmp_ih;
int search_res;
char *local_buf;
loff_t next_pos;
char small_buf[32];
struct reiserfs_dir_entry de;
int ret = 0;
reiserfs_write_lock(inode->i_sb);
reiserfs_check_lock_depth(inode->i_sb, "readdir");
make_cpu_key(&pos_key, inode, *pos ?: DOT_OFFSET, TYPE_DIRENTRY, 3);
next_pos = cpu_key_k_offset(&pos_key);
path_to_entry.reada = PATH_READA;
while (1) {
research:
search_res =
search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry,
&de);
if (search_res == IO_ERROR) {
ret = -EIO;
goto out;
}
entry_num = de.de_entry_num;
bh = de.de_bh;
item_num = de.de_item_num;
ih = de.de_ih;
store_ih(&tmp_ih, ih);
RFALSE(COMP_SHORT_KEYS(&(ih->ih_key), &pos_key),
"vs-9000: found item %h does not match to dir we readdir %K",
ih, &pos_key);
RFALSE(item_num > B_NR_ITEMS(bh) - 1,
"vs-9005 item_num == %d, item amount == %d",
item_num, B_NR_ITEMS(bh));
RFALSE(I_ENTRY_COUNT(ih) < entry_num,
"vs-9010: entry number is too big %d (%d)",
entry_num, I_ENTRY_COUNT(ih));
if (search_res == POSITION_FOUND
|| entry_num < I_ENTRY_COUNT(ih)) {
struct reiserfs_de_head *deh =
B_I_DEH(bh, ih) + entry_num;
for (; entry_num < I_ENTRY_COUNT(ih);
entry_num++, deh++) {
int d_reclen;
char *d_name;
off_t d_off;
ino_t d_ino;
if (!de_visible(deh))
continue;
d_reclen = entry_length(bh, ih, entry_num);
d_name = B_I_DEH_ENTRY_FILE_NAME(bh, ih, deh);
if (d_reclen <= 0 ||
d_name + d_reclen > bh->b_data + bh->b_size) {
pathrelse(&path_to_entry);
ret = -EIO;
goto out;
}
if (!d_name[d_reclen - 1])
d_reclen = strlen(d_name);
if (d_reclen >
REISERFS_MAX_NAME(inode->i_sb->
s_blocksize)) {
continue;
}
if (is_privroot_deh(dentry, deh))
continue;
d_off = deh_offset(deh);
*pos = d_off;
d_ino = deh_objectid(deh);
if (d_reclen <= 32) {
//.........这里部分代码省略.........
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:101,代码来源:dir.c
示例13: indirect_decrement_key
// decrease offset, if it becomes 0, change type to stat data
static void indirect_decrement_key(struct cpu_key *key)
{
cpu_key_k_offset_dec(key);
if (cpu_key_k_offset(key) == 0)
set_cpu_key_k_type(key, TYPE_STAT_DATA);
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:7,代码来源:item_ops.c
示例14: reiserfs_readdir_dentry
int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
filldir_t filldir, loff_t *pos)
{
struct inode *inode = dentry->d_inode;
struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
INITIALIZE_PATH(path_to_entry);
struct buffer_head *bh;
int item_num, entry_num;
const struct reiserfs_key *rkey;
struct item_head *ih, tmp_ih;
int search_res;
char *local_buf;
loff_t next_pos;
char small_buf[32]; /* avoid kmalloc if we can */
struct reiserfs_dir_entry de;
int ret = 0;
reiserfs_write_lock(inode->i_sb);
reiserfs_check_lock_depth(inode->i_sb, "readdir");
/* form key for search the next directory entry using f_pos field of
file structure */
make_cpu_key(&pos_key, inode, *pos ?: DOT_OFFSET, TYPE_DIRENTRY, 3);
next_pos = cpu_key_k_offset(&pos_key);
path_to_entry.reada = PATH_READA;
while (1) {
research:
/* search the directory item, containing entry with specified key */
search_res =
search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry,
&de);
if (search_res == IO_ERROR) {
// FIXME: we could just skip part of directory which could
// not be read
ret = -EIO;
goto out;
}
entry_num = de.de_entry_num;
bh = de.de_bh;
item_num = de.de_item_num;
ih = de.de_ih;
store_ih(&tmp_ih, ih);
/* we must have found item, that is item of this directory, */
RFALSE(COMP_SHORT_KEYS(&(ih->ih_key), &pos_key),
"vs-9000: found item %h does not match to dir we readdir %K",
ih, &pos_key);
RFALSE(item_num > B_NR_ITEMS(bh) - 1,
"vs-9005 item_num == %d, item amount == %d",
item_num, B_NR_ITEMS(bh));
/* and entry must be not more than number of entries in the item */
RFALSE(I_ENTRY_COUNT(ih) < entry_num,
"vs-9010: entry number is too big %d (%d)",
entry_num, I_ENTRY_COUNT(ih));
if (search_res == POSITION_FOUND
|| entry_num < I_ENTRY_COUNT(ih)) {
/* go through all entries in the directory item beginning from the entry, that has been found */
struct reiserfs_de_head *deh =
B_I_DEH(bh, ih) + entry_num;
for (; entry_num < I_ENTRY_COUNT(ih);
entry_num++, deh++) {
int d_reclen;
char *d_name;
off_t d_off;
ino_t d_ino;
loff_t cur_pos = deh_offset(deh);
if (!de_visible(deh))
/* it is hidden entry */
continue;
d_reclen = entry_length(bh, ih, entry_num);
d_name = B_I_DEH_ENTRY_FILE_NAME(bh, ih, deh);
if (d_reclen <= 0 ||
d_name + d_reclen > bh->b_data + bh->b_size) {
/* There is corrupted data in entry,
* We'd better stop here */
pathrelse(&path_to_entry);
ret = -EIO;
goto out;
}
if (!d_name[d_reclen - 1])
d_reclen = strlen(d_name);
if (d_reclen >
REISERFS_MAX_NAME(inode->i_sb->
s_blocksize)) {
/* too big to send back to VFS */
continue;
}
/* Ignore the .reiserfs_priv entry */
if (is_privroot_deh(dentry, deh))
continue;
//.........这里部分代码省略.........
开发者ID:AICP,项目名称:kernel_moto_shamu,代码行数:101,代码来源:dir.c
注:本文中的cpu_key_k_offset函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论