X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-zfs%2Fosd_xattr.c;h=169772885e77118e4db8a8a292454020eb4d1f27;hb=5a758a40de3b6b4e0aeb082195f61d86536233d2;hp=b20a2aaa60b1d568eef0b498f71b03c192aa69eb;hpb=9dacbee7fe35e7dac5637c8ad5c62ece41d3c8ed;p=fs%2Flustre-release.git diff --git a/lustre/osd-zfs/osd_xattr.c b/lustre/osd-zfs/osd_xattr.c index b20a2aa..1697728 100644 --- a/lustre/osd-zfs/osd_xattr.c +++ b/lustre/osd-zfs/osd_xattr.c @@ -26,10 +26,8 @@ /* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. - */ -/* - * Copyright (c) 2012, 2013, Intel Corporation. - * Use is subject to license terms. + * + * Copyright (c) 2012, 2014, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -758,10 +756,10 @@ int osd_xattr_del(const struct lu_env *env, struct dt_object *dt, static int osd_sa_xattr_list(const struct lu_env *env, struct osd_object *obj, - struct lu_buf *lb) + const struct lu_buf *lb) { nvpair_t *nvp = NULL; - int len, counted = 0, remain = lb->lb_len; + int len, counted = 0; int rc = 0; if (obj->oo_sa_xattr == NULL) { @@ -780,16 +778,12 @@ osd_sa_xattr_list(const struct lu_env *env, struct osd_object *obj, strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0)) continue; - len = strlen(nvpair_name(nvp)); + len = strlen(name); if (lb->lb_buf != NULL) { - if (len + 1 > remain) + if (counted + len + 1 > lb->lb_len) return -ERANGE; - memcpy(lb->lb_buf, name, len); - lb->lb_buf += len; - *((char *)lb->lb_buf) = '\0'; - lb->lb_buf++; - remain -= len + 1; + memcpy(lb->lb_buf + counted, name, len + 1); } counted += len + 1; } @@ -797,13 +791,13 @@ osd_sa_xattr_list(const struct lu_env *env, struct osd_object *obj, } int osd_xattr_list(const struct lu_env *env, struct dt_object *dt, - struct lu_buf *lb, struct lustre_capa *capa) + const struct lu_buf *lb, struct lustre_capa *capa) { struct osd_object *obj = osd_dt_obj(dt); struct osd_device *osd = osd_obj2dev(obj); zap_attribute_t *za = &osd_oti_get(env)->oti_za; zap_cursor_t *zc; - int rc, counted = 0, remain = lb->lb_len; + int rc, counted; ENTRY; LASSERT(obj->oo_db != NULL); @@ -815,8 +809,8 @@ int osd_xattr_list(const struct lu_env *env, struct dt_object *dt, rc = osd_sa_xattr_list(env, obj, lb); if (rc < 0) GOTO(out, rc); + counted = rc; - remain -= counted; /* continue with dnode xattr if any */ if (obj->oo_xattr == ZFS_NO_OBJECT) @@ -836,14 +830,10 @@ int osd_xattr_list(const struct lu_env *env, struct dt_object *dt, rc = strlen(za->za_name); if (lb->lb_buf != NULL) { - if (rc + 1 > remain) + if (counted + rc + 1 > lb->lb_len) RETURN(-ERANGE); - memcpy(lb->lb_buf, za->za_name, rc); - lb->lb_buf += rc; - *((char *)lb->lb_buf) = '\0'; - lb->lb_buf++; - remain -= rc + 1; + memcpy(lb->lb_buf + counted, za->za_name, rc + 1); } counted += rc + 1;