MCPcopy Index your code
hub / github.com/RsyncProject/rsync / get_xattr_data

Function get_xattr_data

xattrs.c:187–229  ·  view source on GitHub ↗

On entry, the *len_ptr parameter contains the size of the extra space we * should allocate when we create a buffer for the data. On exit, it contains * the length of the datum. */

Source from the content-addressed store, hash-verified

185 * should allocate when we create a buffer for the data. On exit, it contains
186 * the length of the datum. */
187static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr, int no_missing_error)
188{
189 size_t datum_len = sys_lgetxattr(fname, name, NULL, 0);
190 size_t extra_len = *len_ptr;
191 char *ptr;
192
193 *len_ptr = datum_len;
194
195 if (datum_len == (size_t)-1) {
196 if (errno == ENOTSUP || no_missing_error)
197 return NULL;
198 rsyserr(FERROR_XFER, errno,
199 "get_xattr_data: lgetxattr(%s,\"%s\",0) failed",
200 full_fname(fname), name);
201 return NULL;
202 }
203
204 if (!datum_len && !extra_len)
205 extra_len = 1; /* request non-zero amount of memory */
206 if (SIZE_MAX - datum_len < extra_len)
207 overflow_exit("get_xattr_data");
208 ptr = new_array(char, datum_len + extra_len);
209
210 if (datum_len) {
211 size_t len = sys_lgetxattr(fname, name, ptr, datum_len);
212 if (len != datum_len) {
213 if (len == (size_t)-1) {
214 rsyserr(FERROR_XFER, errno,
215 "get_xattr_data: lgetxattr(%s,\"%s\",%ld) failed",
216 full_fname(fname), name, (long)datum_len);
217 } else {
218 rprintf(FERROR_XFER,
219 "get_xattr_data: lgetxattr(%s,\"%s\",%ld) returned %ld\n",
220 full_fname(fname), name,
221 (long)datum_len, (long)len);
222 }
223 free(ptr);
224 return NULL;
225 }
226 }
227
228 return ptr;
229}
230
231static int rsync_xal_get(const char *fname, item_list *xalp)
232{

Callers 5

rsync_xal_getFunction · 0.85
copy_xattrsFunction · 0.85
send_xattr_requestFunction · 0.85
rsync_xal_setFunction · 0.85
get_xattr_aclFunction · 0.85

Calls 4

sys_lgetxattrFunction · 0.85
full_fnameFunction · 0.85
rsyserrFunction · 0.70
rprintfFunction · 0.70

Tested by

no test coverage detected