(root)/
strace-6.5/
src/
printmode.c
       1  /*
       2   * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
       3   * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
       4   * Copyright (c) 1993-1996 Rick Sladkey <jrs@world.std.com>
       5   * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
       6   * Copyright (c) 2012 Denys Vlasenko <vda.linux@googlemail.com>
       7   * Copyright (c) 2012-2023 The strace developers.
       8   * All rights reserved.
       9   *
      10   * SPDX-License-Identifier: LGPL-2.1-or-later
      11   */
      12  
      13  #include "defs.h"
      14  
      15  #include <fcntl.h>
      16  #include <sys/stat.h>
      17  
      18  #include "xlat/modetypes.h"
      19  
      20  void
      21  print_symbolic_mode_t(const unsigned int mode)
      22  {
      23  	const char *ifmt = "";
      24  
      25  	if (mode & S_IFMT)
      26  		ifmt = xlookup(modetypes, mode & S_IFMT);
      27  
      28  	if (!ifmt || xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
      29  		PRINT_VAL_03O(mode);
      30  
      31  	if (!ifmt || xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
      32  		return;
      33  
      34  	(xlat_verbose(xlat_verbosity) == XLAT_STYLE_ABBREV
      35  		? tprintf_string : tprintf_comment)("%s%s%s%s%s%#03o",
      36  			ifmt, ifmt[0] ? "|" : "",
      37  			(mode & S_ISUID) ? "S_ISUID|" : "",
      38  			(mode & S_ISGID) ? "S_ISGID|" : "",
      39  			(mode & S_ISVTX) ? "S_ISVTX|" : "",
      40  			mode & ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX));
      41  }
      42  
      43  void
      44  print_numeric_umode_t(const unsigned short mode)
      45  {
      46  	PRINT_VAL_03O(mode);
      47  }
      48  
      49  void
      50  print_numeric_ll_umode_t(const unsigned long long mode)
      51  {
      52  	PRINT_VAL_03O(mode);
      53  }