+/*
+ * Index operations.
+ */
+
+/*
+ * XXX This is temporary solution: inode operations are used until iam is
+ * ready.
+ */
+static int osd_index_lookup(struct lu_context *ctxt, struct dt_object *dt,
+ struct dt_rec *rec, const struct dt_key *key)
+{
+ struct osd_object *obj = osd_dt_obj(dt);
+ struct osd_device *osd = osd_obj2dev(obj);
+ struct inode *dir;
+
+ int result;
+
+ /*
+ * XXX temporary solution.
+ */
+ struct dentry *dentry;
+ struct qstr str = {
+ .name = (const char *)key,
+ .len = strlen((const char *)key)
+ };
+
+ LASSERT(osd_has_index(obj));
+ LASSERT(osd->od_obj_area != NULL);
+
+ dir = obj->oo_inode;
+ LASSERT(dir->i_op != NULL && dir->i_op->lookup != NULL);
+
+ dentry = d_alloc(NULL, &str);
+ if (dentry != NULL) {
+ struct dentry *d;
+
+ /*
+ * XXX passing NULL for nameidata should work for
+ * ext3/ldiskfs.
+ */
+ d = dir->i_op->lookup(dir, dentry, NULL);
+ if (d == NULL) {
+ /*
+ * normal case, result is in @dentry.
+ */
+ if (dentry->d_inode != NULL) {
+ struct lu_fid *fid = (struct lu_fid *)rec;
+ /*
+ * Build fid from inode.
+ */
+ fid->f_seq = 0; /* XXX hard-coded */
+ fid->f_oid = dentry->d_inode->i_ino;
+ fid->f_ver = dentry->d_inode->i_generation;
+ result = 0;
+ } else
+ result = -ENOENT;
+ } else {
+ /* What? Disconnected alias? Ppheeeww... */
+ CERROR("Aliasing where not expected\n");
+ result = -EIO;
+ dput(d);
+ }
+ dput(dentry);
+ } else
+ result = -ENOMEM;
+ return result;
+}
+