Index: trunk/src/kmk/function.c
===================================================================
--- trunk/src/kmk/function.c	(revision 2553)
+++ trunk/src/kmk/function.c	(revision 2554)
@@ -5238,6 +5238,6 @@
 }
 #endif  /* CONFIG_WITH_COMMANDS_FUNC */
-
 #ifdef KMK
+
 /* Useful when debugging kmk and/or makefiles. */
 char *
@@ -5255,4 +5255,103 @@
   return o;
 }
+
+/* umask | umask -S. */
+char *
+func_get_umask (char *o, char **argv UNUSED, const char *funcname UNUSED)
+{
+  char sz[80];
+  int off;
+  mode_t u;
+  int symbolic = 0;
+
+  if (argv[0])
+    {
+      if (   !strcmp (argv[0], "S")
+          || !strcmp (argv[0], "-S")
+          || !strcmp (argv[0], "symbolic") )
+        symbolic = 1;
+      else
+        error (reading_file, _("$(%s ) invalid argument `%s'"), funcname, argv[0]);
+    }
+
+  u = umask (002);
+  umask (u);
+
+  if (symbolic)
+    {
+      off = 0;
+      sz[off++] = 'u';
+      sz[off++] = '=';
+      if ((u & S_IRUSR) == 0)
+        sz[off++] = 'r';
+      if ((u & S_IWUSR) == 0)
+        sz[off++] = 'w';
+      if ((u & S_IXUSR) == 0)
+        sz[off++] = 'x';
+      sz[off++] = ',';
+      sz[off++] = 'g';
+      sz[off++] = '=';
+      if ((u & S_IRGRP) == 0)
+        sz[off++] = 'r';
+      if ((u & S_IWGRP) == 0)
+        sz[off++] = 'w';
+      if ((u & S_IXGRP) == 0)
+        sz[off++] = 'x';
+      sz[off++] = ',';
+      sz[off++] = 'o';
+      sz[off++] = '=';
+      if ((u & S_IROTH) == 0)
+        sz[off++] = 'r';
+      if ((u & S_IWOTH) == 0)
+        sz[off++] = 'w';
+      if ((u & S_IXOTH) == 0)
+        sz[off++] = 'x';
+    }
+  else
+    off = sprintf (sz, "%.4o", u);
+
+  return variable_buffer_output (o, sz, off);
+}
+
+
+/* umask 0002 | umask u=rwx,g=rwx,o=rx. */
+char *
+func_set_umask (char *o, char **argv UNUSED, const char *funcname UNUSED)
+{
+  mode_t u;
+  const char *psz;
+
+  /* Figure what kind of input this is. */
+  psz = argv[0];
+  while (isblank ((unsigned char)*psz))
+    psz++;
+
+  if (isdigit ((unsigned char)*psz))
+   {
+      u = 0;
+      while (*psz)
+        {
+          u <<= 3;
+          if (*psz >= '0' && *psz < '8')
+            u += *psz - '0';
+          else
+            error (reading_file, _("$(%s ) illegal number `%s'"), funcname, argv[0]);
+        }
+
+      if (argv[1] != NULL)
+          error (reading_file, _("$(%s ) too many arguments for octal mode"), funcname);
+  }
+  else
+  {
+      u = umask(0);
+      umask(u);
+      error (reading_file, _("$(%s ) symbol mode is not implemented"), funcname);
+  }
+
+  umask(u);
+
+  return o;
+}
+
 #endif /* KMK */
 
@@ -5444,4 +5543,6 @@
 #ifdef KMK
   { STRING_SIZE_TUPLE("breakpoint"),    0,  0,  0,  func_breakpoint},
+  { STRING_SIZE_TUPLE("set-umask"),     1,  3,  1,  func_set_umask},
+  { STRING_SIZE_TUPLE("get-umask"),     0,  0,  0,  func_get_umask},
 #endif
 };
Index: trunk/src/kmk/variable.c
===================================================================
--- trunk/src/kmk/variable.c	(revision 2553)
+++ trunk/src/kmk/variable.c	(revision 2554)
@@ -1331,5 +1331,5 @@
   && defined (KMK_HELPERS)
   (void) define_variable ("KMK_FEATURES", 12,
-                          "append-dash-n abspath includedep-queue install-hard-linking"
+                          "append-dash-n abspath includedep-queue install-hard-linking umask"
                           " kBuild-define"
                           " rsort"
@@ -1357,10 +1357,10 @@
                           " root"
                           " length insert pos lastpos substr translate"
-                          " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl "
-                          " firstdefined lastdefined "
+                          " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl"
+                          " firstdefined lastdefined"
                           , o_default, 0);
 # else /* MSC can't deal with strings mixed with #if/#endif, thus the slow way. */
 #  error "All features should be enabled by default!"
-  strcpy (buf, "append-dash-n abspath includedep-queue install-hard-linking"
+  strcpy (buf, "append-dash-n abspath includedep-queue install-hard-linking umask"
                " kBuild-define");
 #  if defined (CONFIG_WITH_RSORT)
