#include <linux/time.h>
#include <linux/obd.h>
-#include <linux/obd_sim.h>
+#include <linux/obd_ext2.h>
#include <linux/obd_snap.h>
/* #include <linux/obd_fc.h> */
#include <linux/obd_raid1.h>
#include <linux/obd_rpc.h>
-#define OBD_PSDEV_MAJOR 120
+#define OBD_PSDEV_MAJOR 186
#define MAX_OBD_DEVICES 8
#define MAX_MULTI 16
int (*o_set_info)(struct obd_conn *, int keylen, void *key, int vallen, void *val);
int (*o_migrate)(struct obd_conn *, obdattr *src, obdattr *dst);
int (*o_copy)(struct obd_conn *dev, obdattr *source, obdattr *target);
- int (*o_iocontrol)(int cmd, int len, void *karg, void *uarg);
+ int (*o_iocontrol)(int cmd, struct obd_conn *, int len, void *karg, void *uarg);
+ int (*o_iterate)(struct obd_conn *, int (*)(objid, void *), objid, void *);
};
-#define OBP(dev,op) dev->obd_type->typ_ops->o_ ## op
+#define OBT(dev) dev->obd_type->typ_ops
+#define OBP(dev,op) dev->obd_type->typ_ops->o_ ## op
int obd_register_type(struct obd_ops *ops, char *nm);
int obd_unregister_type(char *nm);
* ioctl commands
*/
struct oic_generic {
+ int att_connid;
int att_typelen;
void *att_type;
int att_datalen;
{
obdattr *res = NULL;
OBD_ALLOC(res, obdattr *, sizeof(*res));
+ memset(res, 0, sizeof (*res));
return res;
}
obdattr *res = NULL;
OBD_ALLOC(res, obdattr *, sizeof(*res));
- if ( !res )
+ if ( !res ) {
+ EXIT;
return NULL;
+ }
memset(res, 0, sizeof(*res));
res->i_ino = id;
if (conn->oc_dev->obd_type->typ_ops->o_getattr(conn, res)) {
OBD_FREE(res, sizeof(*res));
+ EXIT;
return NULL;
}
-
+ EXIT;
+ return res;
+}
+
+#define OBD_MD_NO (1UL) /* negates meaning of all flags */
+#define OBD_MD_ALL (OBD_MD_NO) /* passing NO with no other flags == ALL */
+#define OBD_MD_FLMODE (1UL<<1)
+#define OBD_MD_FLUID (1UL<<2)
+#define OBD_MD_FLGID (1UL<<3)
+#define OBD_MD_FLSIZE (1UL<<4)
+#define OBD_MD_FLATIME (1UL<<5)
+#define OBD_MD_FLMTIME (1UL<<6)
+#define OBD_MD_FLCTIME (1UL<<7)
+#define OBD_MD_FLFLAGS (1UL<<8)
+#define OBD_MD_FLBLOCKS (1UL<<9)
+#define OBD_MD_FLOBDMD (1UL<<10)
+
+
+static __inline__ void obdo_cpy_md(obdattr *dst, obdattr *src, int mask)
+{
+ /* If the OBD_MD_NO flag is set, then we copy all EXCEPT those
+ * fields given by the flags. The default is to copy the field
+ * given by the flags.
+ */
+ if (mask & OBD_MD_NO)
+ mask = ~mask;
+
+ CDEBUG(D_INODE, "flags %x\n", mask);
+ if ( mask & OBD_MD_FLMODE )
+ dst->i_mode = src->i_mode;
+ if ( mask & OBD_MD_FLUID )
+ dst->i_uid = src->i_uid;
+ if ( mask & OBD_MD_FLGID )
+ dst->i_gid = src->i_gid;
+ if ( mask & OBD_MD_FLSIZE )
+ dst->i_size = src->i_size;
+ if ( mask & OBD_MD_FLATIME )
+ dst->i_atime = src->i_atime;
+ if ( mask & OBD_MD_FLMTIME )
+ dst->i_mtime = src->i_mtime;
+ if ( mask & OBD_MD_FLCTIME )
+ dst->i_ctime = src->i_ctime;
+ if ( mask & OBD_MD_FLFLAGS )
+ dst->i_flags = src->i_flags;
+ /* allocation of space */
+ if ( mask & OBD_MD_FLBLOCKS )
+ dst->i_blocks = src->i_blocks;
+ if ( mask & OBD_MD_FLOBDMD && src->i_blocks == 0 ) {
+ CDEBUG(D_IOCTL, "copying inline data: ino %ld\n", dst->i_ino);
+ memcpy(&dst->u.ext2_i.i_data, &src->u.ext2_i.i_data,
+ sizeof(src->u.ext2_i.i_data));
+ } else {
+ CDEBUG(D_INODE, "XXXX cpy_obdmd: ino %ld iblocks not 0!\n",
+ src->i_ino);
+ }
+}
+
+
+static __inline__ int obdo_cmp_md(obdattr *dst, obdattr *src, int mask)
+{
+ int res = 1;
+
+ /* If the OBD_MD_NO flag is set, then we copy all EXCEPT those
+ * fields given by the flags. The default is to copy the field
+ * given by the flags.
+ */
+ if (mask & OBD_MD_NO)
+ mask = ~mask;
+
+ if ( mask & OBD_MD_FLMODE )
+ res = (res && (dst->i_mode == src->i_mode));
+ if ( mask & OBD_MD_FLUID )
+ res = (res && (dst->i_uid == src->i_uid));
+ if ( mask & OBD_MD_FLGID )
+ res = (res && (dst->i_gid == src->i_gid));
+ if ( mask & OBD_MD_FLSIZE )
+ res = (res && (dst->i_size == src->i_size));
+ if ( mask & OBD_MD_FLATIME )
+ res = (res && (dst->i_atime == src->i_atime));
+ if ( mask & OBD_MD_FLMTIME )
+ res = (res && (dst->i_mtime == src->i_mtime));
+ if ( mask & OBD_MD_FLCTIME )
+ res = (res && (dst->i_ctime == src->i_ctime));
+ if ( mask & OBD_MD_FLFLAGS )
+ res = (res && (dst->i_flags == src->i_flags));
+ /* allocation of space */
+ if ( mask & OBD_MD_FLBLOCKS )
+ res = (res && (dst->i_blocks == src->i_blocks));
return res;
}
-/* #define obd_cpy_obdo(a,b) memcpy(a, b, sizeof(*a)) */
-static __inline__ void obd_cpy_appmd(obdattr *a, obdattr *b)
+static __inline__ void obd_cpy_appmd(obdattr *dst, obdattr *src)
{
- a->i_mode = b->i_mode;
- a->i_uid = b->i_uid;
- a->i_gid = b->i_gid;
- a->i_size = b->i_size;
- a->i_atime = b->i_atime;
- a->i_mtime = b->i_mtime;
- a->i_ctime = b->i_ctime;
- a->i_flags = b->i_flags;
+ dst->i_mode = src->i_mode;
+ dst->i_uid = src->i_uid;
+ dst->i_gid = src->i_gid;
+ dst->i_size = src->i_size;
+ dst->i_atime = src->i_atime;
+ dst->i_mtime = src->i_mtime;
+ dst->i_ctime = src->i_ctime;
+ dst->i_flags = src->i_flags;
/* allocation of space */
- a->i_blocks = b->i_blocks;
+ dst->i_blocks = src->i_blocks;
}
#endif /* __LINUX_CLASS_OBD_H */