makedev-syntax.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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
  19. * d: a directory
  20. * r: a directory recursively
  21. * c: a character device file
  22. * b: a block device file
  23. * p: a named pipe
  24. - +mode+ are the usual permissions settings (only numerical values
  25. are allowed)
  26. - +uid+ and +gid+ are the UID and GID to set on this file; can be
  27. either numerical values or actual names
  28. - +major+ and +minor+ are here for device files, set to +-+ for other
  29. files
  30. - +start+, +inc+ and +count+ are for when you want to create a batch
  31. of files, and can be reduced to a loop, beginning at +start+,
  32. incrementing its counter by +inc+ until it reaches +count+
  33. Let's say you want to change the permissions of a given file; using
  34. this syntax, you will need to write:
  35. ----
  36. /usr/bin/foo f 755 0 0 - - - - -
  37. /usr/bin/bar f 755 root root - - - - -
  38. /data/buz f 644 buz-user buz-group - - - - -
  39. ----
  40. Alternatively, if you want to change owner/permission of a directory
  41. recursively, you can write (to set UID to foo, GID to bar and access
  42. rights to rwxr-x--- for the directory /usr/share/myapp and all files
  43. and directories below it):
  44. ----
  45. /usr/share/myapp r 750 foo bar - - - - -
  46. ----
  47. On the other hand, if you want to create the device file +/dev/hda+
  48. and the corresponding 15 files for the partitions, you will need for
  49. +/dev/hda+:
  50. ----
  51. /dev/hda b 640 root root 3 0 0 0 -
  52. ----
  53. and then for device files corresponding to the partitions of
  54. +/dev/hda+, +/dev/hdaX+, +X+ ranging from 1 to 15:
  55. ----
  56. /dev/hda b 640 root root 3 1 1 1 15
  57. ----
  58. Extended attributes are supported if
  59. +BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES+ is enabled.
  60. This is done by adding a line starting with +|xattr+ after
  61. the line describing the file. Right now, only capability
  62. is supported as extended attribute.
  63. |=====================
  64. | \|xattr | capability
  65. |=====================
  66. - +|xattr+ is a "flag" that indicate an extended attribute
  67. - +capability+ is a capability to add to the previous file
  68. If you want to add the capability cap_sys_admin to the binary foo,
  69. you will write :
  70. ----
  71. /usr/bin/foo f 755 root root - - - - -
  72. |xattr cap_sys_admin+eip
  73. ----
  74. You can add several capabilities to a file by using several +|xattr+ lines.
  75. If you want to add the capability cap_sys_admin and cap_net_admin to the
  76. binary foo, you will write :
  77. ----
  78. /usr/bin/foo f 755 root root - - - - -
  79. |xattr cap_sys_admin+eip
  80. |xattr cap_net_admin+eip
  81. ----