162306a36Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * trace/beauty/sync_file_range.c 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com> 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#include "trace/beauty/beauty.h" 962306a36Sopenharmony_ci#include <linux/log2.h> 1062306a36Sopenharmony_ci#include <uapi/linux/fs.h> 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_cistatic size_t sync_file_range__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix) 1362306a36Sopenharmony_ci{ 1462306a36Sopenharmony_ci#include "trace/beauty/generated/sync_file_range_arrays.c" 1562306a36Sopenharmony_ci static DEFINE_STRARRAY(sync_file_range_flags, "SYNC_FILE_RANGE_"); 1662306a36Sopenharmony_ci size_t printed = 0; 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci if ((flags & SYNC_FILE_RANGE_WRITE_AND_WAIT) == SYNC_FILE_RANGE_WRITE_AND_WAIT) { 1962306a36Sopenharmony_ci printed += scnprintf(bf + printed, size - printed, "%s%s", show_prefix ? "SYNC_FILE_RANGE_" : "", "WRITE_AND_WAIT"); 2062306a36Sopenharmony_ci flags &= ~SYNC_FILE_RANGE_WRITE_AND_WAIT; 2162306a36Sopenharmony_ci } 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci return printed + strarray__scnprintf_flags(&strarray__sync_file_range_flags, bf + printed, size - printed, show_prefix, flags); 2462306a36Sopenharmony_ci} 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_cisize_t syscall_arg__scnprintf_sync_file_range_flags(char *bf, size_t size, struct syscall_arg *arg) 2762306a36Sopenharmony_ci{ 2862306a36Sopenharmony_ci unsigned long flags = arg->val; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci return sync_file_range__scnprintf_flags(flags, bf, size, arg->show_string_prefix); 3162306a36Sopenharmony_ci} 32