Whamcloud - gitweb
(1) more restriction on fid_is_sane();
authorhuanghua <huanghua>
Tue, 24 Oct 2006 07:33:24 +0000 (07:33 +0000)
committerhuanghua <huanghua>
Tue, 24 Oct 2006 07:33:24 +0000 (07:33 +0000)
(2) use precise symlink length.

lustre/include/lustre/lustre_idl.h
lustre/mdt/mdt_handler.c

index 923e085..677df05 100644 (file)
@@ -234,11 +234,18 @@ static inline void fid_zero(struct lu_fid *fid)
         memset(fid, 0, sizeof(*fid));
 }
 
+static inline int fid_is_igif(const struct lu_fid *fid)
+{
+        return fid_seq(fid) == LUSTRE_ROOT_FID_SEQ;
+}
+
 static inline int fid_is_sane(const struct lu_fid *fid)
 {
         return
                 fid != NULL &&
-                fid_seq_is_sane(fid_seq(fid)) && fid_oid(fid) != 0;
+                ((fid_seq_is_sane(fid_seq(fid)) && fid_oid(fid) != 0 
+                                                && fid_ver(fid) == 0) ||
+                fid_is_igif(fid));
 }
 
 static inline int fid_is_zero(const struct lu_fid *fid)
@@ -246,11 +253,6 @@ static inline int fid_is_zero(const struct lu_fid *fid)
         return fid_seq(fid) == 0 && fid_oid(fid) == 0;
 }
 
-static inline int fid_is_igif(const struct lu_fid *fid)
-{
-        return fid_seq(fid) == LUSTRE_ROOT_FID_SEQ;
-}
-
 #define DFID "[0x%16.16"LPF64"x/0x%8.8x:0x%8.8x]"
 
 #define PFID(fid)     \
index 84d9546..d25a01b 100644 (file)
@@ -476,17 +476,16 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
                 }
         } else if (S_ISLNK(la->la_mode) &&
                           reqbody->valid & OBD_MD_LINKNAME) {
-                /* FIXME: Is this buffer long enough? */
                 buffer->lb_buf = ma->ma_lmm;
-                buffer->lb_len = ma->ma_lmm_size;
+                buffer->lb_len = reqbody->eadatasize;
                 rc = mo_readlink(env, next, buffer);
                 if (rc <= 0) {
                         CERROR("readlink failed: %d\n", rc);
                         rc = -EFAULT;
                 } else {
                         repbody->valid |= OBD_MD_LINKNAME;
-                        repbody->eadatasize = rc + 1;
-                        ((char*)ma->ma_lmm)[rc] = 0; /* NULL terminate */
+                        repbody->eadatasize = rc;
+                        ((char*)ma->ma_lmm)[rc - 1] = 0; /* NULL terminate */
                         CDEBUG(D_INODE, "symlink dest %s, len = %d\n",
                                         (char*)ma->ma_lmm, rc);
                         rc = 0;