Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754420AbbKBXeR (ORCPT ); Mon, 2 Nov 2015 18:34:17 -0500 Received: from mail-bn1bon0082.outbound.protection.outlook.com ([157.56.111.82]:19479 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754377AbbKBXeN (ORCPT ); Mon, 2 Nov 2015 18:34:13 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; From: Yury Norov To: , , , CC: , , , , , , , , , , , , Yury Norov Subject: [PATCH v6 14/17] aarch64: ilp32: use generic stat64 structure Date: Tue, 3 Nov 2015 02:30:43 +0300 Message-ID: <1446507046-24604-15-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446507046-24604-1-git-send-email-ynorov@caviumnetworks.com> References: <1446507046-24604-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [109.252.143.100] X-ClientProxiedBy: DB5PR03CA0003.eurprd03.prod.outlook.com (25.162.150.13) To BY2PR07MB613.namprd07.prod.outlook.com (10.141.222.144) X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB613;2:9w4sos+7lQr3h8v6QERd5svbOxr9GVgHor799r5WdSW4N+2Cmi4Gig6ZBTxYCA45IcZPLbp3KTG8URJQIOo4CqxxVsA8InU6GUR35rtILweAm7OgysDBCA+dP8MJDDzP9vAHMvko/kbIpqp7Aj3atafKyK9j9IS7MX7HCfXFH3w=;3:meZT+atoJVbm7L5AhHrt9xXvoOvyQquE4r/rnkcs+S7v1KC3gMYUQzhR5nn2I8rr6i8kHrhAxBSV056YTu7F4opS6xKttPhF9IWUWITosRQcqDMN6FvmITdjybcd7Ag1g29YmHhfJfQW34A0aeGBpA==;25:5mTm1ZK3fy3/VvuVwm9RQ0e1MLrlhMJoA5g/9wcb6Xk43HEGnp+jFXz7mpQUy8T7ht9Iz8p+MHU6K94gYwXX04imjONTqBkk7HpmxFh6FfizpTfJ9O1yMTbt/e7d4Ml1dG8TLYps/F8wVvlFSqJu18hKsPHvmEOQz36U+PxQKULhYxO82uhKU+0yxi2aLmyoSUhyqyJn9cFWDL5imFpvsqT/lFiZIAcsx+nyq+8GwAG1Sz2xEhB+iopOJsb0N02ZGeQANlYJo3uBr6i27RrBRQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB613; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB613;20:Pjraoz9ekzyDB8yTP0xWRVvGOaN2cHqoCaU682ISGkN+OsQn7n0lbSsvBs2k1acJvJJXkJjOxdFCdI8A5iOEERHJ+oDM/2s2sSR9ILBsmhsfIGN8pw5JfIDf8q6oDKwFKCW3Er3ZqBfFMCxT9/Aq9JI5tiUJaveflkmhb56L1NXqBujKBnntFFe8HVdtjCgl3axss6vg9Lwo/+7n30EL0nAKDyDFbRd4nEMtXx5eAkJ2NYK42avreS2R4UHzD5vNRzEzqZOJKvxz4JY48TPVC9s1oaGVPFctdzSGTEa69vvi71jQgrl3mW3tlcDdTdWVJfrVaDl9EZqZUMGeGX5lhutmg81O2W1xg0rAUZek/Y0IVuY1WraN/1AihbvCU1a0tipoyb7wBPBec4vs7esPI2/9Pjlv2yNQfLCPNrZg9GG8EnxLGnVD8OrwrCD3VxBjBn6Y+3S4fRlVJfDYIxnKa0U9i+6nJ69kOssKjy6miBJo+KgVak3WKcsip9FjIZ06FDNkdNWzvQVOuHhPyMqgRH2frIDzOE3eHXHrtU3o42jDGvAFSZ0C8fPC9n9wUmMvIdcctUUy+ACZ4MKQUY6GoHDpIl2bBv7+czouc2+UK7A= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001);SRVR:BY2PR07MB613;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB613; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB613;4:VqQL4Yr62Eqz/641dq1ZmfRJWP6P14LgLh1WNssXyDzFzhZ/BO+/8s9CseZZfcydr+hY+uQkLtCfLNJESQUBQ4ndd8QeKoOD2vJmh8czIvhFeE2G0iFiYLRd04gmAHms/f1j5vaI7Mygqjc0KBeZtkmITxaC+QbOifXyYYESGSwGSzboJieZBpp39ZewcYp5apJojoiK5ilDpVVJ7RwMsuMd4F/3SYu0T0nCBCDSj+zVDbMQsBh3IfRoH50+43kQ2g4vRblkE0I5J8eDLxfXpwbQe60P93B//VhnGICts1qqU3Noss/Q46NZWZvjZhqcHJ1Sw0oBLQWfhkBaoXbXvorlLH1u7cRzDMQYKHsduW8UJW1Xx3/TODaDX34+Ul/5 X-Forefront-PRVS: 0748FF9A04 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(6009001)(40224003)(199003)(189002)(5001770100001)(48376002)(19580395003)(33646002)(2201001)(101416001)(81156007)(2950100001)(5007970100001)(42186005)(77096005)(5008740100001)(122386002)(5003940100001)(106356001)(40100003)(105586002)(5004730100002)(66066001)(50226001)(76176999)(50466002)(92566002)(5001960100002)(97736004)(36756003)(4001430100002)(50986999)(107886002)(229853001)(76506005)(189998001)(87976001)(47776003)(19580405001)(41533002)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR07MB613;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR07MB613;23:KKyQk5PScnGtFryUXWU/3JtegjHWHtc8PTfNM0Pf8O?= =?us-ascii?Q?Vslvl0TJtcI0/sfVzEa1/XL3Y+T/FBq6s+JEd8lp0WHM4WQYrGhWDclJlp3i?= =?us-ascii?Q?D7MDH4Ed5i2crJx9BxkHaEd+xrMj5S6oOjy46PusZGXtsi7J88KFIIx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Tf8Tn+i7fE95VMyQ8YZenYAvthqCxhuRmTVrosgc?= =?us-ascii?Q?mhYuYZqcstSMXodzhHIWsnL4xzXBpZzlpD8+4pebk5qBIv0b2Hvk37zsvTVD?= =?us-ascii?Q?nKNMZ9nQcmPsllg7IZZX2wJmlmzoGI?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB613;5:Q0WlJtKdeetnjBvQiVU1VfYZUSXWmpxWeavbcXriyjUluXenoQ4KGhoGJD1eMwvZLsh7AHqrLMCvRsj3ZrM0yAd7rdBQrdeX3RO+HdAYGjYaSTfJ5c4+H7HuccEb0d1PyTcQzvjZbqdFZjVEwnx80A==;24:RzeO5ili+kbMTAuH1aGX1Mnqs5NSUpiXd2cAA9hmrvzB4bglhfeDYgnURdmkKmYiL7LRGRnRL066TUHF1bE/Ei49oxg3kmh6z+MSnvVrJoQ=;20:Vt9Ka7rhOehp9KOyhZuChUJhqAYqK7zOd7xe9yGUTtxYcQ2paEeieG4X3csChTW7M2yuakgCKBU7kK6rSiVkIA== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2015 23:34:09.6450 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB613 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3689 Lines: 118 Generic 32-bit and AARCH32 stat64 structures has same names. ILP32 needs generic stat64. So we can either make ILP32 mutual exclusive with AARCH32, or introduce __stat64, and where needed, cast stat64 to it with #define. Second option requires to duplicate cp_new_stat64 code. But we choose it, because it's more flexible to have independend support for ABIs. Signed-off-by: Yury Norov Reviewed-by: David Daney --- arch/arm64/kernel/sys_ilp32.c | 57 +++++++++++++++++++++++++++++++++++++++++ include/uapi/asm-generic/stat.h | 8 +++--- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/sys_ilp32.c b/arch/arm64/kernel/sys_ilp32.c index 6c7d274..889f1d3 100644 --- a/arch/arm64/kernel/sys_ilp32.c +++ b/arch/arm64/kernel/sys_ilp32.c @@ -205,6 +205,63 @@ long ilp32_sys_sigaltstack(const stack_t __user *uss_ptr, for stack_t might not be non-zero. */ #define sys_sigaltstack ilp32_sys_sigaltstack +/* fs */ + +#define sys_fcntl compat_sys_fcntl + +static long __cp_new_stat64(struct kstat *stat, struct __stat64 __user *statbuf) +{ + struct __stat64 tmp; + + memset(&tmp, 0, sizeof(tmp)); + tmp.st_dev = huge_encode_dev(stat->dev); + tmp.st_rdev = huge_encode_dev(stat->rdev); + + tmp.st_ino = stat->ino; + if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino) + return -EOVERFLOW; + tmp.st_mode = stat->mode; + tmp.st_nlink = stat->nlink; + tmp.st_uid = from_kuid_munged(current_user_ns(), stat->uid); + tmp.st_gid = from_kgid_munged(current_user_ns(), stat->gid); + tmp.st_atime = stat->atime.tv_sec; + tmp.st_atime_nsec = stat->atime.tv_nsec; + tmp.st_mtime = stat->mtime.tv_sec; + tmp.st_mtime_nsec = stat->mtime.tv_nsec; + tmp.st_ctime = stat->ctime.tv_sec; + tmp.st_ctime_nsec = stat->ctime.tv_nsec; + tmp.st_size = stat->size; + tmp.st_blocks = stat->blocks; + tmp.st_blksize = stat->blksize; + return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0; +} + +long ilp32_sys_fstat64(int fd, struct __stat64 __user * statbuf) +{ + struct kstat stat; + int error = vfs_fstat(fd, &stat); + + if (!error) + error = __cp_new_stat64(&stat, statbuf); + + return error; +} + +#define sys_newfstat ilp32_sys_fstat64 + +long ilp32_sys_fstatat64(int dfd, const char __user * filename, + struct __stat64 __user * statbuf, int flag) +{ + struct kstat stat; + int error; + + error = vfs_fstatat(dfd, filename, &stat, flag); + if (error) + return error; + return __cp_new_stat64(&stat, statbuf); +} + +#define sys_newfstatat ilp32_sys_fstatat64 #include diff --git a/include/uapi/asm-generic/stat.h b/include/uapi/asm-generic/stat.h index bd8cad2..ae81e73 100644 --- a/include/uapi/asm-generic/stat.h +++ b/include/uapi/asm-generic/stat.h @@ -43,9 +43,7 @@ struct stat { unsigned int __unused5; }; -/* This matches struct stat64 in glibc2.1. Only used for 32 bit. */ -#if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64) -struct stat64 { +struct __stat64 { unsigned long long st_dev; /* Device. */ unsigned long long st_ino; /* File serial number. */ unsigned int st_mode; /* File mode. */ @@ -67,6 +65,10 @@ struct stat64 { unsigned int __unused4; unsigned int __unused5; }; + +#if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64) +/* This matches struct stat64 in glibc2.1. Only used for 32 bit. */ +#define stat64 __stat64 #endif #endif /* __ASM_GENERIC_STAT_H */ -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/