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