From 1feb16ceabda25affc416b1bec3b6f2f911a6fcf Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 4 May 2022 10:11:50 +0200 Subject: [PATCH] regress: Add get_perm function to functions.pm module Some tests are using "stat -c %a" to get file permission in a way that is suitable to compare later on. Unfortunately, it is not portable. --- regress/scripts/functions.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/regress/scripts/functions.pm b/regress/scripts/functions.pm index 9cc540ef9..2154a985c 100644 --- a/regress/scripts/functions.pm +++ b/regress/scripts/functions.pm @@ -52,7 +52,7 @@ our @EXPORT = qw(update_some_files create_many_files check_multiple_copies check_openfile check_cloud_hash check_bscan add_log_message compare_backup_content check_tls_traces println add_virtual_changer check_events check_events_json create_many_hardlinks check_dot_status parse_fuse_trace generate_random_seek - check_storage_selection check_json + check_storage_selection check_json get_perm ); @@ -2575,4 +2575,12 @@ sub check_json } exit 0; } + +# Get the permission in octal for a file, equivalent to stat -c %a +sub get_perm +{ + my ($file) = @_; + my $mode = (stat($file))[2]; + printf "%04o\n", $mode & 07777; +} 1; -- 2.47.3