int dt_record_write(const struct lu_env *env, struct dt_object *dt,
const struct lu_buf *buf, loff_t *pos, struct thandle *th);
typedef int (*dt_index_page_build_t)(const struct lu_env *env,
- union lu_page *lp, int nob,
+ union lu_page *lp, size_t nob,
const struct dt_it_ops *iops,
struct dt_it *it, __u32 attr, void *arg);
int dt_index_walk(const struct lu_env *env, struct dt_object *obj,
}
static int mdd_dir_page_build(const struct lu_env *env, union lu_page *lp,
- int nob, const struct dt_it_ops *iops,
+ size_t nob, const struct dt_it_ops *iops,
struct dt_it *it, __u32 attr, void *arg)
{
struct lu_dirpage *dp = &lp->lp_dir;
struct lu_fid fid;
int first = 1;
+ if (nob < sizeof(*dp))
+ return -EINVAL;
+
memset(area, 0, sizeof (*dp));
area += sizeof (*dp);
nob -= sizeof (*dp);
ent = area;
do {
int len;
- int recsize;
+ size_t recsize;
len = iops->key_size(env, it);
* \param arg - is a pointer to the idx_info structure
*/
static int dt_index_page_build(const struct lu_env *env, union lu_page *lp,
- int nob, const struct dt_it_ops *iops,
+ size_t nob, const struct dt_it_ops *iops,
struct dt_it *it, __u32 attr, void *arg)
{
struct idx_info *ii = (struct idx_info *)arg;
struct lu_idxpage *lip = &lp->lp_idx;
char *entry;
- int rc, size;
+ size_t size;
+ int rc;
ENTRY;
+ if (nob < LIP_HDR_SIZE)
+ return -EINVAL;
+
/* initialize the header of the new container */
memset(lip, 0, LIP_HDR_SIZE);
lip->lip_magic = LIP_MAGIC;
{
struct dt_it *it;
const struct dt_it_ops *iops;
- unsigned int pageidx, nob, nlupgs = 0;
+ size_t pageidx, nob, nlupgs = 0;
int rc;
ENTRY;
LASSERT(obj->do_index_ops != NULL);
nob = rdpg->rp_count;
- if (nob <= 0)
+ if (nob == 0)
RETURN(-EFAULT);
/* Iterate through index and fill containers from @rdpg */
/* fill lu pages */
for (i = 0; i < LU_PAGE_COUNT; i++, lp++, nob -= LU_PAGE_SIZE) {
- rc = filler(env, lp, min_t(int, nob, LU_PAGE_SIZE),
+ rc = filler(env, lp, min_t(size_t, nob, LU_PAGE_SIZE),
iops, it, rdpg->rp_attrs, arg);
if (rc < 0)
break;
iops->fini(env, it);
if (rc >= 0)
- rc = min_t(unsigned int, nlupgs * LU_PAGE_SIZE, rdpg->rp_count);
+ rc = min_t(size_t, nlupgs * LU_PAGE_SIZE, rdpg->rp_count);
RETURN(rc);
}