Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Jul 2022 11:04:10 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: a5113000069a - stable/13 - libsysdecode: Decode Linux open() flags
Message-ID:  <202207061104.266B4AGo096651@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=a5113000069a7e678f1f769b280f53b00ebfcade

commit a5113000069a7e678f1f769b280f53b00ebfcade
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-06-22 11:26:10 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207061104.266B4AGo096651>