From nobody Thu Jul 28 04:32:01 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Ltd5s5Qsfz4XsTp; Thu, 28 Jul 2022 04:32:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ltd5s4ht0z3CVs; Thu, 28 Jul 2022 04:32:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658982721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CUQ/LQGJz5Jzgv1q4Rqvu3KXEuz2FZKDQuSeBN0tXgM=; b=rgJ7VFf71dGCM2jJgpGYMoKVzLaMe+QIvse+34t8vEOxvWhJYBVYCYkqjWS7Clj+o83n8c QhESy76XScS2G0xl8uqcEQgQceuhsvA9VpSWzriC/wZqLqw/Fw9MR897rkcmpEKdBQQf6R k1qNBo9+ECLbvORJKcGrkWD2tHcgvH+kCVsJCnUFmxpHPQERUqDMdbs5FyFAJSK8DM2Q2b oE1hCkLbijoJtvUWkDT3oZk7XTPRvEO0Cj+332hE/armu0hqW7DEEmIpoAhGB6a8PjTIgc WcykAlp5aMVhwiMzarcNY+CnV1oH+wKOiX162csY+o80IF6rvVksSQ4ZjyIvhA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Ltd5s3bDbzk2T; Thu, 28 Jul 2022 04:32:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26S4W1cG014587; Thu, 28 Jul 2022 04:32:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26S4W1WE014586; Thu, 28 Jul 2022 04:32:01 GMT (envelope-from git) Date: Thu, 28 Jul 2022 04:32:01 GMT Message-Id: <202207280432.26S4W1WE014586@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 3a1b966ae0c1 - main - kboot: Convert from getdents to getdents64 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3a1b966ae0c1b9f334e1e3a7ad8b4bf8e845f3c5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658982721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CUQ/LQGJz5Jzgv1q4Rqvu3KXEuz2FZKDQuSeBN0tXgM=; b=XIWZRHCmu9Gxxg1wItOhAY/sLqkEFwjalMN0J6vc9vU07T4IjutOtAfKHgxucDMj99ILqE PGmYrVPAUOiaasOQEoC29n+7mfHZ7s1uMr0TKhFIh7COcL6rrJjs3Fl4mEV26jCCARcVf1 3yhG62BAcT/U2/rr45IiXbnYhxOUWrhyW92SwvTTqXUbaPSBq3xAgNJhNBrhV9CDA4Zoev oMjszj8rOU4figDITl8M/4DbenFiaeqDfqvlvFwCYPWUcqJ9wldj84A0fNBYiUr8UIk7Nb nqt1Yw8q7Y1nlOcuGrUjlo2PqE2JkQVNRYpTfZNmrjivaPjXpSJ4pXVSvk7Ujw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658982721; a=rsa-sha256; cv=none; b=vqStzoKpC2jnDRknlrWgODGVMbgsRmRasaWD5hvy/C2GyRzgMU6XIb2EeeEfnwxSmXya19 HGqSnb71GjlwuuSgu65qrNRVGBq+8nd95Ue6Y8C7HxINR1qAzT0JELAV4ehRnDW/zjcHO7 SfQNBo6q8X6bd7uQU4AculhrGaXHblnALvTGhRF9Z41J44YdEus5baCYn1UF+J4regcMHK erb74+BM5Bc1eyIDgjRYP3NNK9YZUhc0harwvQ4+btNTOKvnb+agzNZBd6GPQeQ8c51mys 8GG/Pknbuar55gcdEoWVyYLFYxxHaF69IlP5vHbTiOB9prRKttTEqy8ZbShZ3A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3a1b966ae0c1b9f334e1e3a7ad8b4bf8e845f3c5 commit 3a1b966ae0c1b9f334e1e3a7ad8b4bf8e845f3c5 Author: Warner Losh AuthorDate: 2022-07-28 04:24:50 +0000 Commit: Warner Losh CommitDate: 2022-07-28 04:29:27 +0000 kboot: Convert from getdents to getdents64 Linux 2.4 introduced getdents64. Switch to using it because aarch64 doesn't have getdents as that syscall was obsoleted before that port was created. Sponsored by: Netflix --- stand/kboot/arch/amd64/syscall_nr.h | 2 +- stand/kboot/arch/powerpc64/syscall_nr.h | 2 +- stand/kboot/host_syscall.h | 21 ++++++++++++++++++++- stand/kboot/host_syscalls.c | 4 ++-- stand/kboot/kbootfdt.c | 18 +++++------------- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/stand/kboot/arch/amd64/syscall_nr.h b/stand/kboot/arch/amd64/syscall_nr.h index 4d8db2083ebc..71930001c1cf 100644 --- a/stand/kboot/arch/amd64/syscall_nr.h +++ b/stand/kboot/arch/amd64/syscall_nr.h @@ -1,6 +1,6 @@ #define SYS_close 3 #define SYS_dup 32 -#define SYS_getdents 78 +#define SYS_getdents64 217 #define SYS_getpid 39 #define SYS_gettimeofday 96 #define SYS_kexec_load 246 diff --git a/stand/kboot/arch/powerpc64/syscall_nr.h b/stand/kboot/arch/powerpc64/syscall_nr.h index a467259e8b60..0702673c7228 100644 --- a/stand/kboot/arch/powerpc64/syscall_nr.h +++ b/stand/kboot/arch/powerpc64/syscall_nr.h @@ -1,7 +1,7 @@ #define SYS_close 6 #define SYS_dup 41 #define SYS_fstat 108 -#define SYS_getdents 141 +#define SYS_getdents64 202 #define SYS_getpid 20 #define SYS_gettimeofday 78 #define SYS_kexec_load 268 diff --git a/stand/kboot/host_syscall.h b/stand/kboot/host_syscall.h index b867cd9f0d99..9f876952641e 100644 --- a/stand/kboot/host_syscall.h +++ b/stand/kboot/host_syscall.h @@ -131,13 +131,32 @@ struct host_kexec_segment { int memsz; }; +struct host_dirent64 { + uint64_t d_ino; /* 64-bit inode number */ + int64_t d_off; /* 64-bit offset to next structure */ + unsigned short d_reclen; /* Size of this dirent */ + unsigned char d_type; /* File type */ + char d_name[]; /* Filename (null-terminated) */ +}; + +/* d_type values */ +#define HOST_DT_UNKNOWN 0 +#define HOST_DT_FIFO 1 +#define HOST_DT_CHR 2 +#define HOST_DT_DIR 4 +#define HOST_DT_BLK 6 +#define HOST_DT_REG 8 +#define HOST_DT_LNK 10 +#define HOST_DT_SOCK 12 +#define HOST_DT_WHT 14 + /* * System Calls */ int host_close(int fd); int host_dup(int fd); int host_fstat(int fd, struct host_kstat *sb); -int host_getdents(int fd, void *dirp, int count); +int host_getdents64(int fd, void *dirp, int count); int host_getpid(void); int host_gettimeofday(struct host_timeval *a, void *b); int host_kexec_load(unsigned long entry, unsigned long nsegs, struct host_kexec_segment *segs, unsigned long flags); diff --git a/stand/kboot/host_syscalls.c b/stand/kboot/host_syscalls.c index 865107263d7b..771f9e128fdd 100644 --- a/stand/kboot/host_syscalls.c +++ b/stand/kboot/host_syscalls.c @@ -26,9 +26,9 @@ host_fstat(int fd, struct host_kstat *sb) } int -host_getdents(int fd, void *dirp, int count) +host_getdents64(int fd, void *dirp, int count) { - return host_syscall(SYS_getdents, fd, (uintptr_t)dirp, count); + return host_syscall(SYS_getdents64, fd, (uintptr_t)dirp, count); } int diff --git a/stand/kboot/kbootfdt.c b/stand/kboot/kbootfdt.c index 5e0ef9ea3068..e4e8e7cfbf04 100644 --- a/stand/kboot/kbootfdt.c +++ b/stand/kboot/kbootfdt.c @@ -40,30 +40,23 @@ add_node_to_fdt(void *buffer, const char *path, int fdt_offset) void *propbuf; ssize_t proplen; - struct host_dent { - unsigned long d_fileno; - unsigned long d_off; - unsigned short d_reclen; - char d_name[]; - /* uint8_t d_type; */ - }; char dents[2048]; - struct host_dent *dent; + struct host_dirent64 *dent; int d_type; fd = host_open(path, O_RDONLY, 0); while (1) { - dentsize = host_getdents(fd, dents, sizeof(dents)); + dentsize = host_getdents64(fd, dents, sizeof(dents)); if (dentsize <= 0) break; - for (dent = (struct host_dent *)dents; + for (dent = (struct host_dirent64 *)dents; (char *)dent < dents + dentsize; - dent = (struct host_dent *)((void *)dent + dent->d_reclen)) { + dent = (struct host_dirent64 *)((void *)dent + dent->d_reclen)) { sprintf(subpath, "%s/%s", path, dent->d_name); if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; - d_type = *((char *)(dent) + dent->d_reclen - 1); + d_type = dent->d_type; if (d_type == 4 /* DT_DIR */) { child_offset = fdt_add_subnode(buffer, fdt_offset, dent->d_name); @@ -72,7 +65,6 @@ add_node_to_fdt(void *buffer, const char *path, int fdt_offset) child_offset, path, dent->d_name); continue; } - add_node_to_fdt(buffer, subpath, child_offset); } else { propbuf = malloc(1024);