Skip to main content
Light Dark System

Vfs Mode

<et2-vfs-mode> | Et2VfsMode

Unix permission string renderer. Migrated from classic et2_vfsMode (et2_widget_vfs.ts). No dependency on any legacy et2_vfs* class.

When to use it

<et2-vfs-mode> turns a numeric unix file mode into the drwxr-xr-x string ls -l would print. It is a pure formatter - it takes the number the VFS stores and makes it readable. There is nothing to edit and no way to change permissions through it.

Examples

What it does

The value is the raw mode; the widget shows the permission string. The same string is also the element’s tooltip, so a narrow column stays readable.

value octal shown as
33188 100644
33261 100755
16877 40755
33152 100600
41471 120777
<table>
    <thead>
        <tr><th align="left">value</th><th align="left">octal</th><th align="left">shown as</th></tr>
    </thead>
    <tbody>
        <tr><td>33188</td><td>100644</td><td><et2-vfs-mode value="33188"></et2-vfs-mode></td></tr>
        <tr><td>33261</td><td>100755</td><td><et2-vfs-mode value="33261"></et2-vfs-mode></td></tr>
        <tr><td>16877</td><td>40755</td><td><et2-vfs-mode value="16877"></et2-vfs-mode></td></tr>
        <tr><td>33152</td><td>100600</td><td><et2-vfs-mode value="33152"></et2-vfs-mode></td></tr>
        <tr><td>41471</td><td>120777</td><td><et2-vfs-mode value="41471"></et2-vfs-mode></td></tr>
    </tbody>
</table>

The first character is the file type, taken from the same S_IFMT bits the C library uses: - for a regular file, d for a directory, l for a symlink, and s, p, c or b for the rarer kinds.

<et2-vfs-mode value="24996"></et2-vfs-mode>

That is 0o60644, a block device. The type is matched against the whole S_IFMT field rather than by testing single bits, which matters here: a block device’s bits contain a character device’s, so a per-bit test reports the wrong type for it.

Special permission bits

set-UID, set-GID and the sticky bit each replace the execute character of their own triplet. Following ls, the replacement is lowercase when that execute bit is set too and uppercase when it is not - so the letter tells you the special bit is on, and its case tells you whether the file is actually executable.

octal bit shown as
104755 set-UID, owner executable
104655 set-UID, not owner executable
102755 set-GID, group executable
41777 sticky, world executable
41776 sticky, not world executable
107777 all three at once
<table>
    <thead>
        <tr><th align="left">octal</th><th align="left">bit</th><th align="left">shown as</th></tr>
    </thead>
    <tbody>
        <tr><td>104755</td><td>set-UID, owner executable</td><td><et2-vfs-mode value="35309"></et2-vfs-mode></td></tr>
        <tr><td>104655</td><td>set-UID, not owner executable</td><td><et2-vfs-mode value="35245"></et2-vfs-mode></td></tr>
        <tr><td>102755</td><td>set-GID, group executable</td><td><et2-vfs-mode value="34285"></et2-vfs-mode></td></tr>
        <tr><td>41777</td><td>sticky, world executable</td><td><et2-vfs-mode value="17407"></et2-vfs-mode></td></tr>
        <tr><td>41776</td><td>sticky, not world executable</td><td><et2-vfs-mode value="17406"></et2-vfs-mode></td></tr>
        <tr><td>107777</td><td>all three at once</td><td><et2-vfs-mode value="36863"></et2-vfs-mode></td></tr>
    </tbody>
</table>

In a row

The usual use is a filemanager column. The widget accepts the whole row object as well as a bare number, and picks mode out of it - so binding it to the row is enough.

<et2-vfs-mode id="${row}[mode]"/>

Nothing to show

An empty, missing or non-numeric value renders nothing at all, rather than a row of dashes that would look like a real set of permissions.

a real mode ← shows
an empty value ← empty
no value at all ← empty
not a number ← empty
<table>
    <tbody>
        <tr><td>a real mode</td><td><et2-vfs-mode value="33188"></et2-vfs-mode></td><td>&larr; shows</td></tr>
        <tr><td>an empty value</td><td><et2-vfs-mode value=""></et2-vfs-mode></td><td>&larr; empty</td></tr>
        <tr><td>no value at all</td><td><et2-vfs-mode></et2-vfs-mode></td><td>&larr; empty</td></tr>
        <tr><td>not a number</td><td><et2-vfs-mode value="rw-r--r--"></et2-vfs-mode></td><td>&larr; empty</td></tr>
    </tbody>
</table>

From javascript

Et2VfsMode.formatMode() is the same conversion as a static method, for when you need the string outside a widget - in a tooltip, a confirmation message, a log line.

import {Et2VfsMode} from "../../api/js/etemplate/Et2Vfs/Et2VfsMode";

Et2VfsMode.formatMode(33188);        // "-rw-r--r--"
Et2VfsMode.formatMode({mode: 16877}); // "drwxr-xr-x"

Properties

Name Description Reflects Type Default
perms
Read / write / execute bit masks. Record { 'x': 0x1, // Execute 'w': 0x2, // Write 'r': 0x4 // Read }
S_IFMT
Mask selecting the file-type bits out of a mode, everything below it is permissions. number 0xF000
sticky
Sticky / set-UID / set-GID overrides. Each replaces the execute character of one permission triplet. The positions are indices into the 9 character permission string only - the leading file-type character is prepended afterwards and must not be counted here. {mask : number, char : string, position : number}[] [ {mask: 0x200, char: "T", position: 8}, // Sticky, replaces world execute {mask: 0x400, char: "S", position: 5}, // sGID, replaces group execute {mask: 0x800, char: "S", position: 2} // SUID, replaces owner execute ]
types
File-type masks, to be compared against the S_IFMT bits as a whole. Several of these share bits (block special 0x6000 contains character special 0x2000, for example), so a plain mode & mask test matches the wrong type - mask with S_IFMT and compare for equality instead, which also makes the result independent of the order declared here. Record { 'l': 0xA000, // link 's': 0xC000, // Socket 'p': 0x1000, // FIFO pipe 'c': 0x2000, // Character special 'd': 0x4000, // Directory 'b': 0x6000, // Block special '-': 0x8000 // Regular }

Learn more about attributes and properties.

Inherited properties (27)

Description

Name Description
accesskey Accesskey provides a hint for generating a keyboard shortcut for the current element. The attribute value must consist of a single printable character.
actions Set Actions on the widget Each action is defined as an object: move: { type: “drop”, acceptedTypes: “mail”, icon: “move”, caption: “Move to” onExecute: javascript:mail_move” } This will turn the widget into a drop target for “mail” drag types. When “mail” drag types are dropped, the global function mail_move(egwAction action, egwActionObject sender) will be called. The ID of the dragged “mail” will be in sender.id, some information about the sender will be in sender.context. The etemplate2 widget involved can typically be found in action.parent.data.widget, so your handler can operate in the widget context easily. The location varies depending on your action though. It might be action.parent.parent.data.widget To customise how the actions are handled for a particular widget, override _link_actions(). It handles the more widget-specific parts.
activateLinks Scan the value, and if there are any links (URL, mailto:) then wrap them in a clickable tag
align Used by Et2Box to determine alignment. Allowed values are left, right
class CSS Class. This class is applied to the outside, on the web component itself. Due to how WebComponents work, this might not change anything inside the component.
data Set the dataset from a CSV
deferredProperties Any attribute that refers to row content cannot be resolved immediately, but some like booleans cannot stay a string because it’s a boolean attribute. We store them for later, and parse when they’re fully in their row. If you are creating a widget that can go in a nextmatch row, and it has boolean attributes that can change for each row, add those attributes into deferredProperties
disabled Defines whether this widget is visibly disabled. The widget is still visible, but clearly cannot be interacted with. Widgets disabled in the template will not return a value to the application code, even if re-enabled via javascript before submitting. To allow a disabled widget to be re-enabled and return a value, disable via javascript in the app’s et2_ready() instead of an attribute in the template file.
dom_id Get the actual DOM ID, which has been prefixed to make sure it’s unique.
extraLinkPopup widthxheight, if popup should be used, eg. 640x480
extraLinkTarget Extra link target Goes with href. If provided, that’s the target for opening the link.
full Take every column of a layout, the same as span="all". Boolean rather than a bare marker so it can be driven from content the way the rest of the template can - full="@is_wide" resolves through the array manager like any other boolean attribute. That does mean it needs a value: write full="true", since an empty full="" resolves to false and removes the attribute again. Reflects for the same reason grow does.
grow How much of a layout’s leftover space this widget should take. Only means anything inside a container that has a layout (see Et2LayoutController): a bare grow or grow="1" takes an equal share of whatever the non-growing children left over, grow="2" takes twice what a grow="1" sibling does. It has to reflect. The layout stylesheet matches the [grow] attribute - CSS cannot see a property - and transformAttributes() only calls setAttribute() for an attribute the element already carries or a property declared as reflecting. Widgets built from a .xet are created with document.createElement() and handed their attributes as an object, so they carry none at that point: without this declaration grow="1" lands as an inert JS property and nothing in the layout ever matches it.
hidden The widget is not visible. As far as the user is concerned, the widget does not exist. Widgets hidden with an attribute in the template may not be created in the DOM, and will not return a value. Widgets can be hidden after creation, and they may return a value if hidden this way.
href Link URL If provided, will be clickable and open this URL
id Get the ID of the widget
label The label of the widget This is usually displayed in some way. It’s also important for accessability. This is defined in the parent somewhere, and re-defining it causes labels to disappear
LINK_STYLES_ID Id of the