From nobody Wed Jul 06 11:04:10 2022 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 64B3C1D01247; Wed, 6 Jul 2022 11:04:12 +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 4LdGrW5K7gz3NMs; Wed, 6 Jul 2022 11:04:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657105451; 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=VviAQcKYqevetbg3nZ4xmbrm3w/3VNIVF6W61eMBUWg=; b=V2UHYq1Ffchc4RRWIDdrJ+gpAXzKHOaYd2uH1+zCbMgKj3kJoSD1lSdheS0JDDBoR90yxp F9qJYeJMS7VR5PVwqBh0CyEdYWkWX7AjHNxY1Rcc+kdHbhd4EWXvUKOpD4jzG5Sw7404Ex gPviypn501oluyP0qfi2gf8R+StWO3cS2MsyOV1N5a62T4aGilfQQUy6g1KmnyTQy/yTKN LFkntAXq9z4+6W9OxGDwQA7Qui4O9vjXy2eqAbl5v9PbeAwQtsG4sl2N/ri1hr+hy3cjJv U5CKSSgWYLiHj90Vh3cGPyUMoU2MQa58VUHHTlTcnhM0yuqUxhG+ERAaTlVWQw== 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 0FEA018F77; Wed, 6 Jul 2022 11:04:11 +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 266B4ARP096652; Wed, 6 Jul 2022 11:04:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 266B4AGo096651; Wed, 6 Jul 2022 11:04:10 GMT (envelope-from git) Date: Wed, 6 Jul 2022 11:04:10 GMT Message-Id: <202207061104.266B4AGo096651@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: a5113000069a - stable/13 - libsysdecode: Decode Linux open() flags 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: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a5113000069a7e678f1f769b280f53b00ebfcade Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657105451; 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=VviAQcKYqevetbg3nZ4xmbrm3w/3VNIVF6W61eMBUWg=; b=GndNkq3sODVqBKt1fer8iyTosQ/WlRn2i+bB7F3C/9XpiVyJ+TbMcjOsb1wRQ8RDnQ/D2l QpMpM3US4MwyGTfeE5Ll/BlfUyMrJfhJt4D6OflbDUYG4aDyeFeBgw7fHGi/UAOA7lbM7m o0HUGfZpLl8RdyIIJ++MURrMjdPd79NKek4ff1ng2qq59omzbbU7mm2LRRfhkBWxK2rt+3 6m/jYIIOstdvNdBLveFZDuIvFRH69sGYFVnZfcLDOxCEtGYJdjuSJhoF72UQBa/oGf8HtB XKIBx5PopPN3BgTqfOM9Pksxh1Pg9JGaqf5CNpE+xX7rSc8ldAvWh2beiEOsEg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657105451; a=rsa-sha256; cv=none; b=elo7KLapPwYSSNQmPn9UqCqK4DAlxxEQ2s4rbySEx6d2Do7FydgMx9JbF0oUhTe2f5G0Ev Zccy25yEYAeRFTVcc4NBkvGhv5KaOBoA/MmAlnZVvvj8qcoG1eA+F1hF0uuEibCjiJBzjz wsM6FTdA74MdcLfCmLBjIvXY9yTDWe0qCUPuu3Mtm++GImuI+/P51NoJoUg3+Xi5Xj8GmI aKcG3gVzoFmNMDfFnc7HHNLACGlJt9BUepnv5twJQZ0QKBipl75NghuQmKRP8GXgi3GgU8 6t21Yl6Z/OXVyxL1ixrxSoLMgTGqK0Bm5/MY/bEEWd8IcNv5EBIij28w5tbasQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=a5113000069a7e678f1f769b280f53b00ebfcade commit a5113000069a7e678f1f769b280f53b00ebfcade Author: Dmitry Chagin AuthorDate: 2022-06-22 11:26:10 +0000 Commit: Dmitry Chagin CommitDate: 2022-07-06 11:02:14 +0000 libsysdecode: Decode Linux open() flags MFC after: 2 weeks (cherry picked from commit fde775bc53de5b5abecdf8679f47bb3aa236e546) --- lib/libsysdecode/linux.c | 35 +++++++++++++++++++++++++++++++++++ lib/libsysdecode/mklinuxtables | 1 + lib/libsysdecode/sysdecode.h | 1 + 3 files changed, 37 insertions(+) diff --git a/lib/libsysdecode/linux.c b/lib/libsysdecode/linux.c index 8a3b88a7bfca..ef015dab6dd8 100644 --- a/lib/libsysdecode/linux.c +++ b/lib/libsysdecode/linux.c @@ -205,3 +205,38 @@ sysdecode_linux_atflags(FILE *fp, int flag, int *rem) return (print_mask_int(fp, atflags, flag, rem)); } + +bool +sysdecode_linux_open_flags(FILE *fp, int flags, int *rem) +{ + bool printed; + int mode; + uintmax_t val; + + mode = flags & LINUX_O_ACCMODE; + flags &= ~LINUX_O_ACCMODE; + switch (mode) { + case LINUX_O_RDONLY: + fputs("O_RDONLY", fp); + printed = true; + mode = 0; + break; + case LINUX_O_WRONLY: + fputs("O_WRONLY", fp); + printed = true; + mode = 0; + break; + case LINUX_O_RDWR: + fputs("O_RDWR", fp); + printed = true; + mode = 0; + break; + default: + printed = false; + } + val = (unsigned)flags; + print_mask_part(fp, openflags, &val, &printed); + if (rem != NULL) + *rem = val | mode; + return (printed); +} diff --git a/lib/libsysdecode/mklinuxtables b/lib/libsysdecode/mklinuxtables index 734d69fca9cf..bcd6ddb5f618 100644 --- a/lib/libsysdecode/mklinuxtables +++ b/lib/libsysdecode/mklinuxtables @@ -92,6 +92,7 @@ gen_table "atflags" "LINUX_AT_[A-Z_]+[[:space:]]+[0-9]+" "compat gen_table "clockids" "LINUX_CLOCK_[A-Z_]+[[:space:]]+[0-9]+" "compat/linux/linux_timer.h" gen_table "clockflags" "LINUX_TIMER_[A-Z_]+[[:space:]]+0x[0-9]+" "compat/linux/linux_timer.h" gen_table "clockcpuids" "LINUX_CPUCLOCK_[A-Z_]+[[:space:]]+[0-9]+" "compat/linux/linux_timer.h" "_MASK|_MAX" +gen_table "openflags" "LINUX_O_[A-Z_]+[[:space:]]+[0-9]+" "compat/linux/linux_file.h" "O_RDONLY|O_RDWR|O_WRONLY|O_ACCMODE" gen_table "sigprocmaskhow" "LINUX_SIG_[A-Z]+[[:space:]]+[0-9]+" "compat/linux/linux.h" # Generate a .depend file for our output file diff --git a/lib/libsysdecode/sysdecode.h b/lib/libsysdecode/sysdecode.h index ae09077e969e..4ea2989ca185 100644 --- a/lib/libsysdecode/sysdecode.h +++ b/lib/libsysdecode/sysdecode.h @@ -144,6 +144,7 @@ bool sysdecode_shmflags(FILE *_fp, int _flags, int *_rem); bool sysdecode_linux_atflags(FILE *_fp, int _flag, int *_rem); void sysdecode_linux_clockid(FILE *_fp, clockid_t _which); bool sysdecode_linux_clock_flags(FILE *_fp, int _flags, int *_rem); +bool sysdecode_linux_open_flags(FILE *_fp, int _flags, int *_rem); const char *sysdecode_linux_signal(int _sig); const char *sysdecode_linux_sigprocmask_how(int _how);