From cc73b53e26392a7b96cf8f20dd21c25fae4817b5 Mon Sep 17 00:00:00 2001 From: huanghua Date: Tue, 24 Oct 2006 07:33:24 +0000 Subject: [PATCH] (1) more restriction on fid_is_sane(); (2) use precise symlink length. --- lustre/include/lustre/lustre_idl.h | 14 ++++++++------ lustre/mdt/mdt_handler.c | 7 +++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 923e085..677df05 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -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) \ diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 84d9546..d25a01b 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -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; -- 1.8.3.1