.moo_attr_get = cml_attr_get,
.moo_attr_set = cml_attr_set,
.moo_xattr_get = cml_xattr_get,
- .moo_readlink = cml_readlink,
.moo_xattr_list = cml_xattr_list,
.moo_xattr_set = cml_xattr_set,
.moo_xattr_del = cml_xattr_del,
.moo_ref_del = cml_ref_del,
.moo_open = cml_open,
.moo_close = cml_close,
- .moo_readpage = cml_readpage
+ .moo_readpage = cml_readpage,
+ .moo_readlink = cml_readlink
};
/* md_dir operations */
.moo_attr_get = cmr_attr_get,
.moo_attr_set = cmr_attr_set,
.moo_xattr_get = cmr_xattr_get,
- .moo_readlink = cmr_readlink,
.moo_xattr_set = cmr_xattr_set,
.moo_xattr_list = cmr_xattr_list,
.moo_xattr_del = cmr_xattr_del,
.moo_ref_del = cmr_ref_del,
.moo_open = cmr_open,
.moo_close = cmr_close,
- .moo_readpage = cmr_readpage
+ .moo_readpage = cmr_readpage,
+ .moo_readlink = cmr_readlink
};
/* remote part of md_dir operations */
struct dt_object *dt, void *buf, int buf_len);
/*
* Create new object on this device.
- * @target_name is the symbolic target.
*
* precondition: !lu_object_exists(ctxt, &dt->do_lu);
* postcondition: ergo(result == 0, lu_object_exists(ctxt, &dt->do_lu));
*/
int (*do_create)(const struct lu_context *ctxt, struct dt_object *dt,
- struct lu_attr *attr, const char *target_name,
- struct thandle *th);
+ struct lu_attr *attr, struct thandle *th);
/*
* Announce that this object is going to be used as an index. This
* operation check that object supports indexing operations and
int (*do_readpage)(const struct lu_context *ctxt,
struct dt_object *dt, const struct lu_rdpg *rdpg);
- int (*do_readlink)(const struct lu_context *ctxt,
- struct dt_object *dt,
- void *buf, int buf_len);
};
/*
int (*moo_xattr_del)(const struct lu_context *ctxt,
struct md_object *obj, const char *name);
+ int (*moo_readpage)(const struct lu_context *, struct md_object *,
+ const struct lu_rdpg *);
int (*moo_readlink)(const struct lu_context *ctxt,
struct md_object *obj,
void *buf, int buf_len);
struct md_attr *);
int (*moo_open)(const struct lu_context *, struct md_object *);
int (*moo_close)(const struct lu_context *, struct md_object *);
-
- int (*moo_readpage)(const struct lu_context *, struct md_object *,
- const struct lu_rdpg *);
};
/*
{
struct mdd_object *mdd_obj = md2mdd_obj(obj);
struct dt_object *next;
- int rc;
+ loff_t pos = 0;
+ int rc;
ENTRY;
LASSERT(lu_object_exists(ctxt, &obj->mo_lu));
next = mdd_object_child(mdd_obj);
- rc = next->do_ops->do_readlink(ctxt, next, buf, buf_len);
-
+ rc = next->do_body_ops->dbo_read(ctxt, next, buf, buf_len, &pos);
RETURN(rc);
}
static int mdd_xattr_list(const struct lu_context *ctxt, struct md_object *obj,
static int __mdd_object_create(const struct lu_context *ctxt,
struct mdd_object *obj, struct md_attr *ma,
- const char *target_name,
struct thandle *handle)
{
struct dt_object *next;
if (!lu_object_exists(ctxt, mdd2lu_obj(obj))) {
next = mdd_object_child(obj);
- rc = next->do_ops->do_create(ctxt, next, attr,
- target_name, handle);
+ rc = next->do_ops->do_create(ctxt, next, attr, handle);
} else
rc = -EEXIST;
if (IS_ERR(handle))
RETURN(PTR_ERR(handle));
- rc = __mdd_object_create(ctxt, md2mdd_obj(obj), attr, NULL, handle);
+ rc = __mdd_object_create(ctxt, md2mdd_obj(obj), attr, handle);
mdd_trans_stop(ctxt, mdd, handle);
* Maybe we should do the same. For now: creation-first.
*/
- rc = __mdd_object_create(ctxt, son, ma, target_name, handle);
+ rc = __mdd_object_create(ctxt, son, ma, handle);
if (rc)
GOTO(cleanup, rc);
inserted = 1;
rc = mdd_lov_set_md(ctxt, pobj, child, lmm, lmm_size, attr->la_mode);
+ if (rc)
+ GOTO(cleanup, rc);
+
+ if (S_ISLNK(attr->la_mode)) {
+ struct dt_object *dt = mdd_object_child(son);
+ loff_t pos = 0;
+ int sym_len = strlen(target_name);
+ rc = dt->do_body_ops->dbo_write(ctxt, dt, target_name,
+ sym_len, &pos, handle);
+ if (rc == sym_len)
+ rc = 0;
+ else
+ rc = -EFAULT;
+ }
+
if (rc == 0)
rc = mdd_attr_get(ctxt, child, ma);
else
.moo_attr_get = mdd_attr_get,
.moo_attr_set = mdd_attr_set,
.moo_xattr_get = mdd_xattr_get,
- .moo_readlink = mdd_readlink,
.moo_xattr_set = mdd_xattr_set,
.moo_xattr_list = mdd_xattr_list,
.moo_xattr_del = mdd_xattr_del,
.moo_ref_del = mdd_ref_del,
.moo_open = mdd_open,
.moo_close = mdd_close,
- .moo_readpage = mdd_readpage
+ .moo_readpage = mdd_readpage,
+ .moo_readlink = mdd_readlink
};
static struct obd_ops mdd_obd_device_ops = {
}
static int osd_mkfile(struct osd_thread_info *info, struct osd_object *obj,
- umode_t mode, const char *target_name, struct thandle *th)
+ umode_t mode, struct thandle *th)
{
int result;
struct osd_device *osd = osd_obj2dev(obj);
dentry = d_alloc(osd->od_obj_area, &info->oti_str);
if (dentry != NULL) {
- if (S_ISLNK(mode))
- result = dir->i_op->symlink(dir, dentry, target_name);
- else
- result = dir->i_op->create(dir, dentry, mode, NULL);
+ result = dir->i_op->create(dir, dentry, mode, NULL);
if (result == 0) {
LASSERT(dentry->d_inode != NULL);
obj->oo_inode = dentry->d_inode;
};
static int osd_mkdir(struct osd_thread_info *info, struct osd_object *obj,
- struct lu_attr *attr, const char *target_name,
- struct thandle *th)
+ struct lu_attr *attr, struct thandle *th)
{
int result;
struct osd_thandle *oth;
LASSERT(S_ISDIR(attr->la_mode));
result = osd_mkfile(info, obj,
S_IFDIR | (attr->la_mode & (S_IRWXUGO|S_ISVTX)),
- target_name, th);
+ th);
if (result == 0) {
LASSERT(obj->oo_inode != NULL);
/*
}
static int osd_mkreg(struct osd_thread_info *info, struct osd_object *obj,
- struct lu_attr *attr, const char *target_name,
- struct thandle *th)
+ struct lu_attr *attr, struct thandle *th)
{
LASSERT(S_ISREG(attr->la_mode));
return osd_mkfile(info, obj,
S_IFREG | (attr->la_mode & (S_IRWXUGO|S_ISVTX)),
- target_name, th);
+ th);
}
static int osd_mksym(struct osd_thread_info *info, struct osd_object *obj,
- struct lu_attr *attr, const char *target_name,
- struct thandle *th)
+ struct lu_attr *attr, struct thandle *th)
{
LASSERT(S_ISLNK(attr->la_mode));
- LASSERT(target_name);
- LASSERT(target_name[0] != 0);
- CDEBUG(D_INODE, "I am going to symlink: "DFID3" to %s\n",
- PFID3(lu_object_fid(&obj->oo_dt.do_lu)), target_name);
- return osd_mkfile(info, obj, S_IFLNK, target_name, th);
+ return osd_mkfile(info, obj,
+ S_IFLNK | (attr->la_mode & (S_IRWXUGO|S_ISVTX)),
+ th);
}
static int osd_mknod(struct osd_thread_info *info, struct osd_object *obj,
- struct lu_attr *attr, const char *target_name,
- struct thandle *th)
+ struct lu_attr *attr, struct thandle *th)
{
return -EOPNOTSUPP;
}
typedef int (*osd_obj_type_f)(struct osd_thread_info *, struct osd_object *,
- struct lu_attr *, const char *target_name,
- struct thandle *);
+ struct lu_attr *, struct thandle *);
static osd_obj_type_f osd_create_type_f(__u32 mode)
{
}
static int osd_object_create(const struct lu_context *ctx, struct dt_object *dt,
- struct lu_attr *attr, const char *target_name,
- struct thandle *th)
+ struct lu_attr *attr, struct thandle *th)
{
const struct lu_fid *fid = lu_object_fid(&dt->do_lu);
struct osd_object *obj = osd_dt_obj(dt);
result = osd_create_pre(info, obj, attr, th);
if (result == 0) {
result = osd_create_type_f(attr->la_mode & S_IFMT)(info, obj,
- attr,
- target_name,
- th);
+ attr, th);
if (result == 0)
result = osd_create_post(info, obj, attr, th);
}
return rc;
}
-static int osd_readlink(const struct lu_context *ctxt, struct dt_object *dt,
- void *buf, int size)
-{
- struct inode *inode = osd_dt_obj(dt)->oo_inode;
- struct osd_thread_info *info = lu_context_key_get(ctxt, &osd_key);
- struct dentry *dentry = &info->oti_dentry;
- struct file *file;
- mm_segment_t seg;
- int rc;
-
- LASSERT(lu_object_exists(ctxt, &dt->do_lu));
- LASSERT(inode->i_op != NULL && inode->i_op->readlink != NULL);
- LASSERT(buf != NULL);
- dentry->d_inode = inode;
-
- file = osd_rw_init(ctxt, inode, &seg);
- rc = inode->i_op->readlink(dentry, buf, size);
- osd_rw_fini(&seg);
- return rc;
-
-}
-
static struct dt_object_operations osd_obj_ops = {
.do_lock = osd_object_lock,
.do_unlock = osd_object_unlock,
.do_ref_add = osd_object_ref_add,
.do_ref_del = osd_object_ref_del,
.do_xattr_get = osd_xattr_get,
- .do_readlink = osd_readlink,
.do_xattr_set = osd_xattr_set,
.do_xattr_del = osd_xattr_del,
.do_xattr_list = osd_xattr_list,
- .do_readpage = osd_readpage
+ .do_readpage = osd_readpage,
};
/*