MCPcopy Create free account
hub / github.com/F-Stack/f-stack / extattr_get_vp

Function extattr_get_vp

freebsd/kern/vfs_extattr.c:328–386  ·  view source on GitHub ↗

- * Get a named extended attribute on a file or directory * * Arguments: unlocked vnode "vp", attribute namespace "attrnamespace", * kernelspace string pointer "attrname", userspace buffer * pointer "data", buffer length "nbytes", thread "td". * Returns: 0 on success, an error number otherwise * Locks: none * References: vp must be a valid reference for the duration o

Source from the content-addressed store, hash-verified

326 * References: vp must be a valid reference for the duration of the call
327 */
328static int
329extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname,
330 void *data, size_t nbytes, struct thread *td)
331{
332 struct uio auio, *auiop;
333 struct iovec aiov;
334 ssize_t cnt;
335 size_t size, *sizep;
336 int error;
337
338 if (nbytes > IOSIZE_MAX)
339 return (EINVAL);
340
341 vn_lock(vp, LK_SHARED | LK_RETRY);
342
343 /*
344 * Slightly unusual semantics: if the user provides a NULL data
345 * pointer, they don't want to receive the data, just the maximum
346 * read length.
347 */
348 auiop = NULL;
349 sizep = NULL;
350 cnt = 0;
351 if (data != NULL) {
352 aiov.iov_base = data;
353 aiov.iov_len = nbytes;
354 auio.uio_iov = &aiov;
355 auio.uio_iovcnt = 1;
356 auio.uio_offset = 0;
357 auio.uio_resid = nbytes;
358 auio.uio_rw = UIO_READ;
359 auio.uio_segflg = UIO_USERSPACE;
360 auio.uio_td = td;
361 auiop = &auio;
362 cnt = nbytes;
363 } else
364 sizep = &size;
365
366#ifdef MAC
367 error = mac_vnode_check_getextattr(td->td_ucred, vp, attrnamespace,
368 attrname);
369 if (error)
370 goto done;
371#endif
372
373 error = VOP_GETEXTATTR(vp, attrnamespace, attrname, auiop, sizep,
374 td->td_ucred, td);
375
376 if (auiop != NULL) {
377 cnt -= auio.uio_resid;
378 td->td_retval[0] = cnt;
379 } else
380 td->td_retval[0] = size;
381#ifdef MAC
382done:
383#endif
384 VOP_UNLOCK(vp);
385 return (error);

Callers 2

sys_extattr_get_fdFunction · 0.85
kern_extattr_get_pathFunction · 0.85

Calls 2

vn_lockFunction · 0.85

Tested by

no test coverage detected