MODECANON(3ast) MODECANON(3ast)

# [NAME](#NAME)

modecanon - canonical file mode representation

# [SYNOPSIS](#SYNOPSIS)

```
#include <modex.h>
int    modei(int external);
int    modex(int internal);
```

# [DESCRIPTION](#DESCRIPTION)

POSIX threw out the file type bit macros and replaced them with function-like macros that test file type. This is bad in many ways, the worst of which is that it provides no way for a user program to synthesize file types in the mode bits. [*pax*(1)](/man/os/ksh/pax.1), [*tar*(1)](/man/os/ksh/tar.1) and [*cpio*(1)](/man/os/ksh/cpio.1) are examples of user programs that must convert between the internal mode representation and a private external representation. These routines provide a canonical external representation with macros to access and synthesize the bits in the external representation.

modei takes an external mode representation *external* and returns the equivalent internal representation.

modex takes an internal mode representation *internal* and returns the equivalent external representation.

The traditional bit access macro (**S\_** prefix changes to **X\_**) are: X\_IFMT, X\_IFSOCK, X\_IFLNK, X\_IFCTG, X\_IFREG, X\_IFBLK, X\_IFDIR, X\_IFCHR, X\_IFIFO, X\_IPERM, X\_ISUID, X\_ISGID, X\_ISVTX, X\_IRUSR, X\_IWUSR, X\_IXUSR, X\_IRGRP, X\_IWGRP, X\_IXGRP, X\_IROTH, X\_IWOTH, X\_IXOTH, X\_IRWXU, X\_IRWXG and X\_IRWXO. returns the type bits for *mode*.

# [SEE ALSO](#SEE_ALSO)

[pax(1)](/man/os/ksh/pax.1), [stat(2)](/man/os/ksh/stat.2)

---

Document: modecanon(3ast) from ksh 1.0.10-r36 (Chainguard OS)
Source: https://github.com/ksh93/ksh
