LFCS · Question #371
Which of the following statements is true when querying the extended attributes of a file that has no extended attributes set?
The correct answer is C. No output will be produced and getfattr will exit with a value of 0. When getfattr is used to query a file that lacks extended attributes, it produces no output and indicates success by exiting with a status code of 0.
Question
Options
- Agetfattr will print a warning and exit with a value of 0.
- Bgetfattr will print a warning and exit with a value of 1.
- CNo output will be produced and getfattr will exit with a value of 0.
- DNo output will be produced and getfattr will exit with a value of 1.
How the community answered
(58 responses)- A2% (1)
- B2% (1)
- C93% (54)
- D3% (2)
Why each option
When `getfattr` is used to query a file that lacks extended attributes, it produces no output and indicates success by exiting with a status code of 0.
`getfattr` does not print a warning; it simply outputs nothing when no attributes are found.
`getfattr` does not print a warning nor does it exit with a non-zero status code, as it considers finding no attributes a successful query.
The `getfattr` command, when executed on a file without extended attributes, will silently succeed. It does not output any warning or error messages, and it exits with a status code of 0, indicating successful execution.
`getfattr` exits with a value of 0, indicating success, not 1, when no attributes are found.
Concept tested: Linux extended attributes getfattr behavior
Source: https://www.man7.org/linux/man-pages/man1/getfattr.1.html
Topics
Community Discussion
No community discussion yet for this question.