From 7fae5acf0b57293ecb2dff9da829de973b98263b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 20 Oct 2008 15:36:42 -0700 Subject: [PATCH] filestore: fix getattrs to interpret listxattr return value correctly --- src/os/FileStore.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 1201994565518..3ea8a688ae9f6 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -1469,19 +1469,21 @@ int FileStore::_getattrs(const char *fn, map& aset) // get attr list char names1[100]; char *name = names1; - int num = do_listxattr(fn, names1, sizeof(names1)); + int len = do_listxattr(fn, names1, sizeof(names1)); char *names2 = 0; - if (num == -ERANGE) { - int l = do_listxattr(fn, 0, 0); - if (l < 0) return l; - name = names2 = new char[l]; - num = do_listxattr(fn, names2, l); + if (len == -ERANGE) { + len = do_listxattr(fn, 0, 0); + if (len < 0) return len; + name = names2 = new char[len]; + len = do_listxattr(fn, names2, len); + if (len < 0) + return len; } - - for (int i=0; i