Re: [PATCH 20/27] [AARCH64] Make lp64 and ilp32 directories.
From: Andreas Schwab
Date: Tue Jun 21 2016 - 04:34:55 EST
Yury Norov <ynorov@xxxxxxxxxxxxxxxxxx> writes:
> diff --git a/sysdeps/unix/sysv/linux/aarch64/ilp32/getdents.c b/sysdeps/unix/sysv/linux/aarch64/ilp32/getdents.c
> new file mode 100644
> index 0000000..0f89a09
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/aarch64/ilp32/getdents.c
> @@ -0,0 +1,78 @@
> +/* Copyright (C) 2007-2015 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 <dirent.h>
> +#include <stddef.h>
> +#include <stdint.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <sys/types.h>
> +#include <bits/wordsize.h>
> +
> +#include <sysdep.h>
> +#include <sys/syscall.h>
> +#include <linux/posix_types.h>
> +
> +struct kernel_dirent64
> + {
> + uint64_t d_ino;
> + int64_t d_off;
> + unsigned short int d_reclen;
> + unsigned char d_type;
> + char d_name[256];
> + };
> +
> +static size_t conv (char *buf, size_t nbytes)
> +{
> + char *end = buf + nbytes;
> + struct dirent *u = (struct dirent *) buf;
> + struct kernel_dirent64 *k = (struct kernel_dirent64 *) buf;
> + size_t sizd = offsetof(struct kernel_dirent64, d_name)
> + - offsetof(struct dirent, d_name);
> +
> + while ((char*) k < end)
> + {
> + struct kernel_dirent64 *nk = (char *) k + k->d_reclen;
> + size_t name_len = k->d_reclen - offsetof(struct kernel_dirent64, d_name);
> +
> + u->d_ino = k->d_ino;
> + u->d_off = k->d_off;
> + u->d_reclen = k->d_reclen - sizd;
> + u->d_type = k->d_type;
> + memcpy (u->d_name, k->d_name, name_len);
> +
> + u = (char *) u + u->d_reclen;
> + k = nk;
> + }
> +
> + return (size_t) u - (size_t) buf;
> +}
> +
> +ssize_t
> +__getdents (int fd, char *buf, size_t nbytes)
> +{
> +
> + struct kernel_dirent64 *k;
Unused variable.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@xxxxxxx
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."