/*
* Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
*
* Trivial changes by Alan Cox to remove EHASHCOLLISION for compatibility
*
* Trivial Changes:
* Rights granted to Hans Reiser to redistribute under other terms providing
* he accepts all liability including but not limited to patent, fitness
* for purpose, and direct or indirect claims arising from failure to perform.
*
* NO WARRANTY
*/
#include <linux/time.h>
#include <linux/bitops.h>
#include <linux/slab.h>
#include "reiserfs.h"
#include "acl.h"
#include "xattr.h"
#include <linux/quotaops.h>
#define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) set_nlink(i, 1); }
#define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
/*
* directory item contains array of entry headers. This performs
* binary search through that array
*/
static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off)
{
struct item_head *ih = de->de_ih;
struct reiserfs_de_head *deh = de->de_deh;
int rbound, lbound, j;
lbound = 0;
rbound = ih_entry_count(ih) - 1;
for (j = (rbound + lbound) / 2; lbound <= rbound;
j = (rbound + lbound) / 2) {
if (off < deh_offset(deh + j)) {
rbound = j - 1;
continue;
}
if (off > deh_offset(deh + j)) {
lbound = j + 1;
continue;
}
/* this is not name found, but matched third key component */
de->de_entry_num = j;
return NAME_FOUND;
}
de->de_entry_num = lbound;
return NAME_NOT_FOUND;
}
/*
* comment? maybe something like set de to point to what the path points to?
*/
static inline void set_de_item_location(struct reiserfs_dir_entry *de,
struct treepath *path)
{
de->de_bh = get_last_bh(path);
de->de_ih = tp_item_head(path);
de->de_deh = B_I_DEH(de->de_bh, de->de_ih);
de->de_item_num = PATH_LAST_POSITION(path);
}
/*
* de_bh, de_ih, de_deh (points to first element of array), de_item_num is set
*/
inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de)
{
struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num;
|