From 4e5327187d6474e81241dd2b6f5418be2387a0cb Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sat, 17 Apr 2010 13:07:56 +0100 Subject: [PATCH] New API: get-umask, returns the current umask (RHBZ#582891). --- daemon/umask.c | 17 +++++++++++++++++ src/MAX_PROC_NR | 2 +- src/generator.ml | 11 ++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/daemon/umask.c b/daemon/umask.c index 22d2cc9..a9ddeab 100644 --- a/daemon/umask.c +++ b/daemon/umask.c @@ -44,3 +44,20 @@ do_umask (int mask) return r; } + +int +do_get_umask (void) +{ + int r; + + r = umask (022); + if (r == -1) { + reply_with_perror ("umask"); + return -1; + } + + /* Restore the umask, since the call above corrupted it. */ + umask (r); + + return r; +} diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index b4249c4..eb08bc0 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -239 +240 diff --git a/src/generator.ml b/src/generator.ml index b97584a..61323a9 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -3034,7 +3034,8 @@ The default umask is C<022>. This is important because it means that directories and device nodes will be created with C<0644> or C<0755> mode even if you specify C<0777>. -See also L, C, C. +See also C, +L, C, C. This call returns the previous umask."); @@ -4484,6 +4485,14 @@ group."); Set the value associated with C to C. This is the same as the L C command."); + ("get_umask", (RInt "mask", []), 240, [FishOutput FishOutputOctal], + [InitEmpty, Always, TestOutputInt ( + [["get_umask"]], 0o22)], + "get the current umask", + "\ +Return the current umask. By default the umask is C<022> +unless it has been set by calling C."); + ] let all_functions = non_daemon_functions @ daemon_functions -- 1.8.3.1