From a8215524ac574f4494b827a61ea7e2383c94fcea Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Wed, 11 Feb 2015 12:11:10 +0100 Subject: [PATCH] listxattr.2: Add note on handling increases in sizes of keys or values Signed-off-by: Michael Kerrisk --- man2/listxattr.2 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/man2/listxattr.2 b/man2/listxattr.2 index 7b39df65a..52c32ffb7 100644 --- a/man2/listxattr.2 +++ b/man2/listxattr.2 @@ -171,6 +171,18 @@ To keep the code simple, the program assumes that attribute keys and values are constant during the execution of the program. A production program should expect and handle changes during execution of the program. +For example, +the number of bytes required for attribute keys +might increase between the two calls to +.BR listxattr (). +An application could handle this possibility using +a loop that retries the call +(perhaps up to a predetermined maximum number of attempts) +with a larger buffer each time it fails with the error +.BR ERANGE . +Calls to +.BR getxattr (2) +could be handled similarly. The following output was recorded by first creating a file, setting some extended file attributes,