From patchwork Wed Nov 11 00:44:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11895981 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 173301668 for ; Wed, 11 Nov 2020 00:44:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBBB121D7F for ; Wed, 11 Nov 2020 00:44:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="jxn5dbZy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732438AbgKKAos (ORCPT ); Tue, 10 Nov 2020 19:44:48 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:56044 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732432AbgKKAos (ORCPT ); Tue, 10 Nov 2020 19:44:48 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AB0XrBu040631; Wed, 11 Nov 2020 00:44:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=y+SPDfh4kLI+6gCrC3nosZ+Q3ot+DI2IHj7DqRiI/+U=; b=jxn5dbZyyEkt6AoKd+EnoQluSim0hXgFSOp6bLOFWivpCe7Q3Lxev4lIFIONw2m4UPcR P8flJ6pbHiwptJX1nsoIHjVx9P6NF4IKJIOG3w42yL6VEj2XX2F/NpIZIwBxCR2MBcoY We+9R7Dgnkklher5HtXDinm8RJXLnn0KjKR4AohBHS774E+VwVcK2nHbUSvSKRM7p0it V9gjSkeESlClltedlOKZL73/MuLOD2dAkJiMLypoocETTPDM5U1JgbnANrbf1sa5fef4 1RqUe91fzsu99gy9ym23tR+6DpbdFAiu6ok8/kvDHnh6WHlCOI2OzY7f4YargCUQIKlv dA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 34nh3axw4p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Nov 2020 00:44:46 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AB0VCEp095247; Wed, 11 Nov 2020 00:44:46 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 34p55paudw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 11 Nov 2020 00:44:46 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0AB0ijg7029360; Wed, 11 Nov 2020 00:44:45 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 16:44:44 -0800 Subject: [PATCH 1/4] fsx: fix strncpy usage error From: "Darrick J. Wong" To: darrick.wong@oracle.com, guaneryu@gmail.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Tue, 10 Nov 2020 16:44:43 -0800 Message-ID: <160505548377.1389938.2367585875193826371.stgit@magnolia> In-Reply-To: <160505547722.1389938.14377167906399924976.stgit@magnolia> References: <160505547722.1389938.14377167906399924976.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011110001 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011110001 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong We shouldn't feed sizeof() to strncpy as the string length. Just use snprintf, which at least doesn't have the zero termination problems. In file included from /usr/include/string.h:495, from ../src/global.h:73, from fsx.c:16: In function 'strncpy', inlined from 'main' at fsx.c:2944:5: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: '__builtin_strncpy' specified bound 4096 equals destination size [-Wstringop-truncation] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function 'strncpy', inlined from 'main' at fsx.c:2914:4: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: '__builtin_strncpy' specified bound 1024 equals destination size [-Wstringop-truncation] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- ltp/fsx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index 0abd7de1..cd0bae55 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -2769,8 +2769,7 @@ main(int argc, char **argv) randomoplen = 0; break; case 'P': - strncpy(dname, optarg, sizeof(dname)); - strcat(dname, "/"); + snprintf(dname, sizeof(dname), "%s/", optarg); dirpath = strlen(dname); break; case 'R': @@ -2799,7 +2798,7 @@ main(int argc, char **argv) break; case 255: /* --record-ops */ if (optarg) - strncpy(opsfile, optarg, sizeof(opsfile)); + snprintf(opsfile, sizeof(opsfile), "%s", optarg); recordops = opsfile; break; case 256: /* --replay-ops */ From patchwork Wed Nov 11 00:44:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11895985 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D34A1668 for ; Wed, 11 Nov 2020 00:44:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CC0F21D7F for ; Wed, 11 Nov 2020 00:44:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="dWS1KcIi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732444AbgKKAoy (ORCPT ); Tue, 10 Nov 2020 19:44:54 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:48480 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732432AbgKKAoy (ORCPT ); Tue, 10 Nov 2020 19:44:54 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AB0XmHX110483; Wed, 11 Nov 2020 00:44:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=tkXCYU/47noBy5aVHguIPhk5KrRsc7NNJTDueCtqj1s=; b=dWS1KcIiKY34m5lpNDMw4EWyPsiiPpO4VDAz/tVFWBnKlJqkhtsdHR/cS8QUWONQidgH YYFVM4lI3GZBSieVGW7Q8XRdxPUdBBhQ+mcR7Y2OeFMRN9Y8zcC2AJ6xWVC7+1768Skr AQgpu8h4+JFLU7TYbDAJXSBA9mTDoQ55jkCxzMOeovdJw7JJBBP3dZmacFg+xQ09jM8r EGxMGJXPzmfiGaVQNi/3mPqGPsk/cXFm7pMrSjFFwyjG9iJfIZyIrnRdHZN5rRKyLcel whS9ut+a5/x40mmv+/Ru8ZSmbhEH0LZd5d0zLJr9f09AYt5MNuo/iv9mX2rQPE37hf1T SQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 34nkhkxnpf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Nov 2020 00:44:52 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AB0UrOG171436; Wed, 11 Nov 2020 00:44:52 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 34p5g12qbt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 11 Nov 2020 00:44:52 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0AB0ipM8001091; Wed, 11 Nov 2020 00:44:51 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 16:44:50 -0800 Subject: [PATCH 2/4] fsstress: stop using attr_set From: "Darrick J. Wong" To: darrick.wong@oracle.com, guaneryu@gmail.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Tue, 10 Nov 2020 16:44:49 -0800 Message-ID: <160505548994.1389938.10129281247073522665.stgit@magnolia> In-Reply-To: <160505547722.1389938.14377167906399924976.stgit@magnolia> References: <160505547722.1389938.14377167906399924976.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=919 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011110001 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 priorityscore=1501 mlxscore=0 suspectscore=2 mlxlogscore=938 lowpriorityscore=0 spamscore=0 malwarescore=0 adultscore=0 clxscore=1015 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011110001 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong attr_set is deprecated, so replace it with lsetxattr. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- ltp/fsstress.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 1238fcf5..41b31060 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -395,7 +395,7 @@ void add_to_flist(int, int, int, int); void append_pathname(pathname_t *, char *); int attr_list_path(pathname_t *, char *, const int, int, attrlist_cursor_t *); int attr_remove_path(pathname_t *, const char *, int); -int attr_set_path(pathname_t *, const char *, const char *, const int, int); +int attr_set_path(pathname_t *, const char *, const char *, const int); void check_cwd(void); void cleanup_flist(void); int creat_path(pathname_t *, mode_t); @@ -909,19 +909,19 @@ attr_remove_path(pathname_t *name, const char *attrname, int flags) int attr_set_path(pathname_t *name, const char *attrname, const char *attrvalue, - const int valuelength, int flags) + const int valuelength) { char buf[NAME_MAX + 1]; pathname_t newname; int rval; - rval = attr_set(name->path, attrname, attrvalue, valuelength, flags); + rval = lsetxattr(name->path, attrname, attrvalue, valuelength, 0); if (rval >= 0 || errno != ENAMETOOLONG) return rval; separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { - rval = attr_set_path(&newname, attrname, attrvalue, valuelength, - flags); + rval = attr_set_path(&newname, attrname, attrvalue, + valuelength); assert(chdir("..") == 0); } free_pathname(&newname); @@ -2392,7 +2392,7 @@ attr_set_f(int opno, long r) len = 1; aval = malloc(len); memset(aval, nameseq & 0xff, len); - e = attr_set_path(&f, aname, aval, len, ATTR_DONTFOLLOW) < 0 ? + e = attr_set_path(&f, aname, aval, len) < 0 ? errno : 0; check_cwd(); free(aval); From patchwork Wed Nov 11 00:44:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11895989 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45A0316C0 for ; Wed, 11 Nov 2020 00:45:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 201C321D46 for ; Wed, 11 Nov 2020 00:45:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="h/dFSgQa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732465AbgKKApC (ORCPT ); Tue, 10 Nov 2020 19:45:02 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:35356 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732432AbgKKApA (ORCPT ); Tue, 10 Nov 2020 19:45:00 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AB0ZQQl016861; Wed, 11 Nov 2020 00:44:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=Y7vvaiIy+72Jn5DkfvcYc6/nZYqsudMwxsmRDmvXwKg=; b=h/dFSgQaFX+DWLCWEXp2Dh9KM9+0wlCoRL7u7ZadXIiexyXV+Z1zgsgH9V+Hc90d2RQi fD/+9vR/j+ZoSr+TFBNLEul6fm0iNCjlx6Zc3292MfSe51Ic6pNMpFfiXREJXrWfQSXB 2fHANJilMKUflKuytK0S8jktdF9u8NJse8wvL64txBi3X74LQzM6K7prmI2mjmE6DPGe J+Cls4JsXZPj2og6ZWyCEHFdb9w6c/jyYM22Jk07rzGEo4p0yFxPmsO6Vk9qN2yez0xR XcZ5mGLoqvgf9JSk3hc9FDC6FLHnyPcqJc9IjPokrD8DUky7nVdmySRM8NmOFFUlm4PK Ow== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 34p72emv6m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Nov 2020 00:44:58 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AB0V6v1027454; Wed, 11 Nov 2020 00:44:58 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 34qgp7krcj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 11 Nov 2020 00:44:58 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0AB0ivML018557; Wed, 11 Nov 2020 00:44:57 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 16:44:57 -0800 Subject: [PATCH 3/4] fsstress: remove attr_remove From: "Darrick J. Wong" To: darrick.wong@oracle.com, guaneryu@gmail.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Tue, 10 Nov 2020 16:44:56 -0800 Message-ID: <160505549612.1389938.4557085048629140407.stgit@magnolia> In-Reply-To: <160505547722.1389938.14377167906399924976.stgit@magnolia> References: <160505547722.1389938.14377167906399924976.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011110001 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 suspectscore=2 lowpriorityscore=0 adultscore=0 phishscore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011110001 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong attr_remove is deprecated, so replace it with lremovexattr. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- ltp/fsstress.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 41b31060..ad42cb65 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -394,7 +394,7 @@ struct print_string flag_str = {0}; void add_to_flist(int, int, int, int); void append_pathname(pathname_t *, char *); int attr_list_path(pathname_t *, char *, const int, int, attrlist_cursor_t *); -int attr_remove_path(pathname_t *, const char *, int); +int attr_remove_path(pathname_t *, const char *); int attr_set_path(pathname_t *, const char *, const char *, const int); void check_cwd(void); void cleanup_flist(void); @@ -889,18 +889,18 @@ attr_list_path(pathname_t *name, } int -attr_remove_path(pathname_t *name, const char *attrname, int flags) +attr_remove_path(pathname_t *name, const char *attrname) { char buf[NAME_MAX + 1]; pathname_t newname; int rval; - rval = attr_remove(name->path, attrname, flags); + rval = lremovexattr(name->path, attrname); if (rval >= 0 || errno != ENAMETOOLONG) return rval; separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { - rval = attr_remove_path(&newname, attrname, flags); + rval = attr_remove_path(&newname, attrname); assert(chdir("..") == 0); } free_pathname(&newname); @@ -2362,7 +2362,7 @@ attr_remove_f(int opno, long r) free_pathname(&f); return; } - e = attr_remove_path(&f, aname, ATTR_DONTFOLLOW) < 0 ? errno : 0; + e = attr_remove_path(&f, aname) < 0 ? errno : 0; check_cwd(); if (v) printf("%d/%d: attr_remove %s %s %d\n", From patchwork Wed Nov 11 00:45:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11895993 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A80CF1668 for ; Wed, 11 Nov 2020 00:45:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87A5621D7F for ; Wed, 11 Nov 2020 00:45:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="avfYtBDs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732475AbgKKApH (ORCPT ); Tue, 10 Nov 2020 19:45:07 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:48600 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732471AbgKKApH (ORCPT ); Tue, 10 Nov 2020 19:45:07 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AB0XmQC110506; Wed, 11 Nov 2020 00:45:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=ZISJicSdjUHdd449hzWRzWMRs0WaLwYokQU7Kryy2ZU=; b=avfYtBDsYmR/9VC5uxA31DalPdbdKtcCQMcYSAHgY2fLU9KGlPeEvgOTjcboWdJb+XzB UDHkHtpHvTMSXgJh6rRN8uCqDnasnDYd2j1C7zWcZGJwbe7gBbuMs6OPTpT21kfkhZ9u 2ROzAjAnocK8jx36izW+V1QTs2a7y14bxgvoWowDL6wZqYiy3ANSBz8T/rUKmd1X4FpZ XtuO8hXzdkd9w03Kq1QwocPDjxp9P3r7O26c7yVziure0mfD6og0WqCw/vnERZSqamrP R5TLPBIHD0bqDq7gstOx13AvVYTWscuYfpaxd0nzAl4FsaSyiNGTSNeaazP5fUQPN8Wz hA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 34nkhkxnps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Nov 2020 00:45:05 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AB0U9OV097566; Wed, 11 Nov 2020 00:45:04 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 34p5gxq7u1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 11 Nov 2020 00:45:04 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0AB0j3uw029395; Wed, 11 Nov 2020 00:45:03 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Nov 2020 16:45:03 -0800 Subject: [PATCH 4/4] fsstress: get rid of attr_list From: "Darrick J. Wong" To: darrick.wong@oracle.com, guaneryu@gmail.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Tue, 10 Nov 2020 16:45:02 -0800 Message-ID: <160505550232.1389938.14087037220733512558.stgit@magnolia> In-Reply-To: <160505547722.1389938.14377167906399924976.stgit@magnolia> References: <160505547722.1389938.14377167906399924976.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 adultscore=0 malwarescore=0 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011110001 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9801 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 priorityscore=1501 mlxscore=0 suspectscore=2 mlxlogscore=999 lowpriorityscore=0 spamscore=0 malwarescore=0 adultscore=0 clxscore=1015 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011110001 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Darrick J. Wong attr_list is deprecated, so just call llistxattr directly. This is a bit involved, since attr_remove_f was highly dependent on libattr structures. Note that attr_list uses llistxattr internally and llistxattr is limited to XATTR_LIST_MAX, so this doesn't result in any loss of functionality. Signed-off-by: Darrick J. Wong --- ltp/fsstress.c | 80 ++++++++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index ad42cb65..e4940ba4 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -393,7 +393,7 @@ struct print_string flag_str = {0}; void add_to_flist(int, int, int, int); void append_pathname(pathname_t *, char *); -int attr_list_path(pathname_t *, char *, const int, int, attrlist_cursor_t *); +int attr_list_path(pathname_t *, char *, const int); int attr_remove_path(pathname_t *, const char *); int attr_set_path(pathname_t *, const char *, const char *, const int); void check_cwd(void); @@ -860,28 +860,36 @@ append_pathname(pathname_t *name, char *str) name->len += len; } +int +attr_list_count(char *buffer, int buffersize) +{ + char *p = buffer; + char *end = buffer + buffersize; + int count = 0; + + while (p < end && *p != 0) { + count++; + p += strlen(p) + 1; + } + + return count; +} + int attr_list_path(pathname_t *name, char *buffer, - const int buffersize, - int flags, - attrlist_cursor_t *cursor) + const int buffersize) { char buf[NAME_MAX + 1]; pathname_t newname; int rval; - if (flags != ATTR_DONTFOLLOW) { - errno = EINVAL; - return -1; - } - - rval = attr_list(name->path, buffer, buffersize, flags, cursor); + rval = llistxattr(name->path, buffer, buffersize); if (rval >= 0 || errno != ENAMETOOLONG) return rval; separate_pathname(name, buf, &newname); if (chdir(buf) == 0) { - rval = attr_list_path(&newname, buffer, buffersize, flags, cursor); + rval = attr_list_path(&newname, buffer, buffersize); assert(chdir("..") == 0); } free_pathname(&newname); @@ -2302,32 +2310,24 @@ aread_f(int opno, long r) void attr_remove_f(int opno, long r) { - attrlist_ent_t *aep; - attrlist_t *alist; - char *aname; - char buf[4096]; - attrlist_cursor_t cursor; + char *bufname; + char *bufend; + char *aname = NULL; + char buf[XATTR_LIST_MAX]; int e; int ent; pathname_t f; - int total; + int total = 0; int v; int which; init_pathname(&f); if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v)) append_pathname(&f, "."); - total = 0; - bzero(&cursor, sizeof(cursor)); - do { - bzero(buf, sizeof(buf)); - e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW, &cursor); - check_cwd(); - if (e) - break; - alist = (attrlist_t *)buf; - total += alist->al_count; - } while (alist->al_more); + e = attr_list_path(&f, buf, sizeof(buf)); + check_cwd(); + if (e > 0) + total = attr_list_count(buf, e); if (total == 0) { if (v) printf("%d/%d: attr_remove - no attrs for %s\n", @@ -2335,25 +2335,19 @@ attr_remove_f(int opno, long r) free_pathname(&f); return; } + which = (int)(random() % total); - bzero(&cursor, sizeof(cursor)); + bufname = buf; + bufend = buf + e; ent = 0; - aname = NULL; - do { - bzero(buf, sizeof(buf)); - e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW, &cursor); - check_cwd(); - if (e) - break; - alist = (attrlist_t *)buf; - if (which < ent + alist->al_count) { - aep = (attrlist_ent_t *) - &buf[alist->al_offset[which - ent]]; - aname = aep->a_name; + while (bufname < bufend) { + if (which < ent) { + aname = bufname; break; } - ent += alist->al_count; - } while (alist->al_more); + ent++; + bufname += strlen(bufname) + 1; + } if (aname == NULL) { if (v) printf(