makedev-syntax.adoc 3.7 KB

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