# define lm_compare_owner fl_compare_owner
#endif
+/*
+ * After 3.1, kernel's nameidata.intent.open.flags is different
+ * with lustre's lookup_intent.it_flags, as lustre's it_flags'
+ * lower bits equal to FMODE_xxx while kernel doesn't transliterate
+ * lower bits of nameidata.intent.open.flags to FMODE_xxx.
+ * */
+#include <linux/version.h>
+static inline int ll_namei_to_lookup_intent_flag(int flag)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
+ flag = (flag & ~O_ACCMODE) | OPEN_FMODE(flag);
+#endif
+ return flag;
+}
+
#endif /* _COMPAT25_H */
struct lookup_intent *ll_convert_intent(struct open_intent *oit,
int lookup_flags)
{
- struct lookup_intent *it;
-
- OBD_ALLOC(it, sizeof(*it));
- if (!it)
- return ERR_PTR(-ENOMEM);
-
- if (lookup_flags & LOOKUP_OPEN) {
- it->it_op = IT_OPEN;
- if (lookup_flags & LOOKUP_CREATE)
- it->it_op |= IT_CREAT;
- it->it_create_mode = (oit->create_mode & S_IALLUGO) | S_IFREG;
- it->it_flags = oit->flags;
- } else {
- it->it_op = IT_GETATTR;
- }
+ struct lookup_intent *it;
+
+ OBD_ALLOC(it, sizeof(*it));
+ if (!it)
+ return ERR_PTR(-ENOMEM);
+
+ if (lookup_flags & LOOKUP_OPEN) {
+ it->it_op = IT_OPEN;
+ if (lookup_flags & LOOKUP_CREATE)
+ it->it_op |= IT_CREAT;
+ it->it_create_mode = (oit->create_mode & S_IALLUGO) | S_IFREG;
+ it->it_flags = ll_namei_to_lookup_intent_flag(oit->flags);
+ } else {
+ it->it_op = IT_GETATTR;
+ }
- return it;
+ return it;
}
static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,