Back to index

cell-binutils  2.17cvs20070401
Defines | Functions
filemode.c File Reference
#include "bfd.h"
#include "bucomm.h"

Go to the source code of this file.

Defines

#define S_IRWXU   0700
#define S_IRUSR   0400
#define S_IWUSR   0200
#define S_IXUSR   0100
#define S_IRWXG   0070
#define S_IRGRP   0040
#define S_IWGRP   0020
#define S_IXGRP   0010
#define S_IRWXO   0007
#define S_IROTH   0004
#define S_IWOTH   0002
#define S_IXOTH   0001
#define S_ISDIR(i)   (((i) & 0170000) == 040000)
#define S_ISBLK(i)   0
#define S_ISCHR(i)   0
#define S_ISFIFO(i)   0
#define S_ISSOCK(i)   0
#define S_ISLNK(i)   0

Functions

static char ftypelet (unsigned long)
static void setst (unsigned long, char *)
void mode_string (unsigned long mode, char *str)
static void setst (unsigned long bits ATTRIBUTE_UNUSED, char *chars ATTRIBUTE_UNUSED)

Define Documentation

#define S_IRGRP   0040

Definition at line 81 of file filemode.c.

#define S_IROTH   0004

Definition at line 94 of file filemode.c.

#define S_IRUSR   0400

Definition at line 68 of file filemode.c.

#define S_IRWXG   0070

Definition at line 78 of file filemode.c.

#define S_IRWXO   0007

Definition at line 91 of file filemode.c.

#define S_IRWXU   0700

Definition at line 65 of file filemode.c.

#define S_ISBLK (   i)    0

Definition at line 145 of file filemode.c.

#define S_ISCHR (   i)    0

Definition at line 153 of file filemode.c.

#define S_ISDIR (   i)    (((i) & 0170000) == 040000)

Definition at line 137 of file filemode.c.

#define S_ISFIFO (   i)    0

Definition at line 161 of file filemode.c.

#define S_ISLNK (   i)    0

Definition at line 177 of file filemode.c.

#define S_ISSOCK (   i)    0

Definition at line 169 of file filemode.c.

#define S_IWGRP   0020

Definition at line 84 of file filemode.c.

#define S_IWOTH   0002

Definition at line 97 of file filemode.c.

#define S_IWUSR   0200

Definition at line 71 of file filemode.c.

#define S_IXGRP   0010

Definition at line 87 of file filemode.c.

#define S_IXOTH   0001

Definition at line 100 of file filemode.c.

#define S_IXUSR   0100

Definition at line 74 of file filemode.c.


Function Documentation

static char ftypelet ( unsigned long  bits) [static]

Definition at line 182 of file filemode.c.

{
  if (S_ISDIR (bits))
    return 'd';
  if (S_ISLNK (bits))
    return 'l';
  if (S_ISBLK (bits))
    return 'b';
  if (S_ISCHR (bits))
    return 'c';
  if (S_ISSOCK (bits))
    return 's';
  if (S_ISFIFO (bits))
    return 'p';

#ifdef S_IFMT
#ifdef S_IFMPC
  if ((bits & S_IFMT) == S_IFMPC
      || (bits & S_IFMT) == S_IFMPB)
    return 'm';
#endif
#ifdef S_IFNWK
  if ((bits & S_IFMT) == S_IFNWK)
    return 'n';
#endif
#endif

  return '-';
}

Here is the caller graph for this function:

void mode_string ( unsigned long  mode,
char *  str 
)

Definition at line 107 of file filemode.c.

{
  str[0] = ftypelet ((unsigned long) mode);
  str[1] = (mode & S_IRUSR) != 0 ? 'r' : '-';
  str[2] = (mode & S_IWUSR) != 0 ? 'w' : '-';
  str[3] = (mode & S_IXUSR) != 0 ? 'x' : '-';
  str[4] = (mode & S_IRGRP) != 0 ? 'r' : '-';
  str[5] = (mode & S_IWGRP) != 0 ? 'w' : '-';
  str[6] = (mode & S_IXGRP) != 0 ? 'x' : '-';
  str[7] = (mode & S_IROTH) != 0 ? 'r' : '-';
  str[8] = (mode & S_IWOTH) != 0 ? 'w' : '-';
  str[9] = (mode & S_IXOTH) != 0 ? 'x' : '-';
  setst ((unsigned long) mode, str);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void setst ( unsigned  long,
char *   
) [static]

Here is the caller graph for this function:

static void setst ( unsigned long bits  ATTRIBUTE_UNUSED,
char *chars  ATTRIBUTE_UNUSED 
) [static]

Definition at line 216 of file filemode.c.

{
#ifdef S_ISUID
  if (bits & S_ISUID)
    {
      if (chars[3] != 'x')
       /* Set-uid, but not executable by owner.  */
       chars[3] = 'S';
      else
       chars[3] = 's';
    }
#endif
#ifdef S_ISGID
  if (bits & S_ISGID)
    {
      if (chars[6] != 'x')
       /* Set-gid, but not executable by group.  */
       chars[6] = 'S';
      else
       chars[6] = 's';
    }
#endif
#ifdef S_ISVTX
  if (bits & S_ISVTX)
    {
      if (chars[9] != 'x')
       /* Sticky, but not executable by others.  */
       chars[9] = 'T';
      else
       chars[9] = 't';
    }
#endif
}