Re: [PATCH 22/27] [AARCH64] ILP32: support stat syscall family

Andreas Schwab
2016-06-21T08:44:37Z

Yury Norov <ynorov@caviumnetworks.com> writes:

> diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/statfs.h b/sysdeps/unix/sysv/linux/aarch64/bits/statfs.h
> new file mode 100644
> index 0000000..81a8626
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/aarch64/bits/statfs.h
> @@ -0,0 +1,72 @@
> +/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> + Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library. If not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +#ifndef _SYS_STATFS_H
> +# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
> +#endif
> +
> +#include <endian.h>
> +#include <bits/types.h>
> +#include <bits/wordsize.h>
> +
> +/* 64-bit libc uses the kernel's 'struct statfs', accessed via the
> + statfs() syscall; 32-bit libc uses the kernel's 'struct statfs64'
> + and accesses it via the statfs64() syscall. All the various
> + APIs offered by libc use the kernel shape for their struct statfs
> + structure; the only difference is that 32-bit programs not
> + using __USE_FILE_OFFSET64 only see the low 32 bits of some
> + of the fields (the __fsblkcnt_t and __fsfilcnt_t fields). */

Is that comment accurate?

> diff --git a/sysdeps/unix/sysv/linux/aarch64/ilp32/fstatfs64.c b/sysdeps/unix/sysv/linux/aarch64/ilp32/fstatfs64.c
> new file mode 100644
> index 0000000..d7b90bb
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/aarch64/ilp32/fstatfs64.c
> @@ -0,0 +1,72 @@
> +/* Return information about the filesystem on which FD resides.
> + Copyright (C) 1996-2016 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +#include <errno.h>
> +#include <string.h>
> +#include <sys/statfs.h>
> +#include <stddef.h>
> +#include <sysdep.h>
> +#include <kernel-features.h>
> +
> +/* Defined in statfs64.c. */
> +extern int __no_statfs64 attribute_hidden;

No need for probing, statfs64 is always available.

> diff --git a/sysdeps/unix/sysv/linux/aarch64/ilp32/fxstat64.c b/sysdeps/unix/sysv/linux/aarch64/ilp32/fxstat64.c
> new file mode 100644
> index 0000000..f651921
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/aarch64/ilp32/fxstat64.c
> @@ -0,0 +1,54 @@
> +/* fxstat64 using Linux fstat64 system call.
> + Copyright (C) 1997-2016 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +#include <errno.h>
> +#include <stddef.h>
> +#include <sys/stat.h>
> +#include <kernel_stat.h>
> +
> +#include <sysdep.h>
> +#include <sys/syscall.h>
> +
> +#include <kernel-features.h>
> +
> +/* Get information about the file FD in BUF. */
> +
> +int
> +___fxstat64 (int vers, int fd, struct stat64 *buf)
> +{
> + int result;
> + result = INLINE_SYSCALL (fstat64, 2, fd, buf);
> + if (!result) {
> + conv_timespec(&buf->st_atim, &buf->__st_atim);
> + conv_timespec(&buf->st_mtim, &buf->__st_mtim);
> + conv_timespec(&buf->st_ctim, &buf->__st_ctim);
> + }
> + return result;
> +}
> +
> +#include <shlib-compat.h>
> +
> +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)

No need for compat symbols in a new port.

Andreas.

--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."