xref: /OK3568_Linux_fs/buildroot/docs/manual/makedev-syntax.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1// -*- mode:doc; -*-
2// vim: set syntax=asciidoc:
3
4[[makedev-syntax]]
5== Makedev syntax documentation
6
7The makedev syntax is used in several places in Buildroot to
8define changes to be made for permissions, or which device files to
9create and how to create them, in order to avoid calls to mknod.
10
11This syntax is derived from the makedev utility, and more complete
12documentation can be found in the +package/makedevs/README+ file.
13
14It takes the form of a space separated list of fields, one file per
15line; the fields are:
16
17|===========================================================
18|name |type |mode |uid |gid |major |minor |start |inc |count
19|===========================================================
20
21There are a few non-trivial blocks:
22
23- +name+ is the path to the file you want to create/modify
24- +type+ is the type of the file, being one of:
25  * f: a regular file
26  * d: a directory
27  * r: a directory recursively
28  * c: a character device file
29  * b: a block device file
30  * p: a named pipe
31- +mode+ are the usual permissions settings (only numerical values
32  are allowed)
33- +uid+ and +gid+ are the UID and GID to set on this file; can be
34  either numerical values or actual names
35- +major+ and +minor+ are here for device files, set to +-+ for other
36  files
37- +start+, +inc+ and +count+ are for when you want to create a batch
38  of files, and can be reduced to a loop, beginning at +start+,
39  incrementing its counter by +inc+ until it reaches +count+
40
41Let's say you want to change the permissions of a given file; using
42this syntax, you will need to write:
43
44----
45/usr/bin/foo f 755 0 0 - - - - -
46/usr/bin/bar f 755 root root - - - - -
47/data/buz f 644 buz-user buz-group - - - - -
48----
49
50Alternatively, if you want to change owner/permission of a directory
51recursively, you can write (to set UID to foo, GID to bar and access
52rights to rwxr-x--- for the directory /usr/share/myapp and all files
53and directories below it):
54
55----
56/usr/share/myapp r 750 foo bar - - - - -
57----
58
59On the other hand, if you want to create the device file +/dev/hda+
60and the corresponding 15 files for the partitions, you will need for
61+/dev/hda+:
62
63----
64/dev/hda b 640 root root 3 0 0 0 -
65----
66
67and then for device files corresponding to the partitions of
68+/dev/hda+, +/dev/hdaX+, +X+ ranging from 1 to 15:
69
70----
71/dev/hda b 640 root root 3 1 1 1 15
72----
73
74Extended attributes are supported if
75+BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES+ is enabled.
76This is done by adding a line starting with +|xattr+ after
77the line describing the file. Right now, only capability
78is supported as extended attribute.
79
80|=====================
81| \|xattr | capability
82|=====================
83
84- +|xattr+ is a "flag" that indicate an extended attribute
85- +capability+ is a capability to add to the previous file
86
87If you want to add the capability cap_sys_admin to the binary foo,
88you will write :
89
90----
91/usr/bin/foo f 755 root root - - - - -
92|xattr cap_sys_admin+eip
93----
94
95You can add several capabilities to a file by using several +|xattr+ lines.
96If you want to add the capability cap_sys_admin and cap_net_admin to the
97binary foo, you will write :
98
99----
100/usr/bin/foo f 755 root root - - - - -
101|xattr cap_sys_admin+eip
102|xattr cap_net_admin+eip
103----
104