From nobody Tue Jan 24 22:11:33 2023 X-Original-To: dev-commits-src-all@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 4P1h5K5WWlz3bfZw; Tue, 24 Jan 2023 22:11:33 +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 4P1h5K49zkz4Nqs; Tue, 24 Jan 2023 22:11:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598293; 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=U5r2Tegroc0XJAClHi+eZzprnbEOStv/a+8bRRu5vc0=; b=H5P2jGacE4epSm+bDUMVKpEsfO3uNjB8RPPL+CUlK1sOJsTMdPe8EPK9FaGKipWeCecb8k zv1LRw+hVWq2Y+q0nXk+Kew+9IKcfFSt4sWY/2KXSLEV9SWQbG4iqx8AABztyA+wSkuqRm UvC+sxcF54evkFXFgFEwFLdrLW1Y7MYVL4ltLEvh/excWwyRYej533hjLPSfPAS4ZEHWVI 5DpzBu3oNFAj8Mm7093kIVwEroAU+titaftBOuLrCH+Jd1sJBDvwb6h5XKqcJeVb+W99YP 2PiOMdlIPXh/pbQfFvPUD9WYoWriegRz4FzgspOlM6Syx1d8+9HmEilmLd7DrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598293; 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=U5r2Tegroc0XJAClHi+eZzprnbEOStv/a+8bRRu5vc0=; b=WxEDBMCzz4DCV3DW6bL6rstkwgHHIoQzrmNSoiPnEJuG3kEr+Le4KBf8WufjoBT9oYJvWd ULxlcWlg6gPeepdYvrqDSAVqqzlPATOrtJ6rMWFkm4LoeX5LbfaGCS2aeqA0JdNWZKkFQl 9OiA6istxMeVOGKJy1t/teKEpQb6ypuP0XJOiudc8gFVbJHUrW2ZYnpPMPG18OlODhRbgB /8nUpIUyYOkG3G8f4rP1EuTVmNEgSkgRUpRIIg1T5ew6rsRfan5aWunzRcEv6pPU50pfs3 zZ2TBrdVjFLmtRh8rD7r1kQ0zjAvsUSN9GILCf82x1o2zloivQOLURKncxFQZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598293; a=rsa-sha256; cv=none; b=k7HpPe6bCaycDQhjSk7OhyxATb7dCX7R2ELX3c5WcklyUR99FQhuBUaeHw3U5kQsh+HcUd 4pj8hnHBTun4dG37qJye67R8T/7zaaP8HWk7n6hBBDqXpo2JpVnXPtunGSpUo/heEI2BYt SGqGVytMy8K0gQjo5354/NYZOWX6W2J36eLty19KGBsIhfZRr7H+tu2HzKbZsGd4tfqt2L xJIKrYkGa+XdVAjXtPYc9Y2gG/2O90eelHYdEaqzef5/NFiWqXAM6uO/MU9ER4NCghkHIu qIialqhwvAENZNFzwNfdZpTM23gO8IiEA2h1u9i6X1nl2CHYKZynbkP+9g8ISg== 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 4P1h5K3Gt1zQTr; Tue, 24 Jan 2023 22:11:33 +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 30OMBXbk084884; Tue, 24 Jan 2023 22:11:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMBXDS084883; Tue, 24 Jan 2023 22:11:33 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:11:33 GMT Message-Id: <202301242211.30OMBXDS084883@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: b40746e8ead2 - stable/13 - kboot: Convert from getdents to getdents64 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: b40746e8ead296324dee20c50cb9d766dcdb0113 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=b40746e8ead296324dee20c50cb9d766dcdb0113 commit b40746e8ead296324dee20c50cb9d766dcdb0113 Author: Warner Losh AuthorDate: 2022-07-28 04:24:50 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:28 +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 (cherry picked from commit 3a1b966ae0c1b9f334e1e3a7ad8b4bf8e845f3c5) --- 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);