18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * trace/beauty/sync_file_range.c
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include "trace/beauty/beauty.h"
98c2ecf20Sopenharmony_ci#include <linux/log2.h>
108c2ecf20Sopenharmony_ci#include <uapi/linux/fs.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cistatic size_t sync_file_range__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
138c2ecf20Sopenharmony_ci{
148c2ecf20Sopenharmony_ci#include "trace/beauty/generated/sync_file_range_arrays.c"
158c2ecf20Sopenharmony_ci       static DEFINE_STRARRAY(sync_file_range_flags, "SYNC_FILE_RANGE_");
168c2ecf20Sopenharmony_ci       size_t printed = 0;
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci       if ((flags & SYNC_FILE_RANGE_WRITE_AND_WAIT) == SYNC_FILE_RANGE_WRITE_AND_WAIT) {
198c2ecf20Sopenharmony_ci               printed += scnprintf(bf + printed, size - printed, "%s%s", show_prefix ? "SYNC_FILE_RANGE_" : "", "WRITE_AND_WAIT");
208c2ecf20Sopenharmony_ci	       flags &= ~SYNC_FILE_RANGE_WRITE_AND_WAIT;
218c2ecf20Sopenharmony_ci       }
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci       return printed + strarray__scnprintf_flags(&strarray__sync_file_range_flags, bf + printed, size - printed, show_prefix, flags);
248c2ecf20Sopenharmony_ci}
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cisize_t syscall_arg__scnprintf_sync_file_range_flags(char *bf, size_t size, struct syscall_arg *arg)
278c2ecf20Sopenharmony_ci{
288c2ecf20Sopenharmony_ci	unsigned long flags = arg->val;
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	return sync_file_range__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
318c2ecf20Sopenharmony_ci}
32