Lines Matching +full:- +full:gp

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * Copyright (c) 2022-2024 Oracle.
38 return sizeof(struct xfs_fid) - sizeof(handle->ha_fid.fid_len); in xfs_filehandle_fid_len()
48 memcpy(&handle->ha_fsid, mp->m_fixedfsid, sizeof(struct xfs_fsid)); in xfs_filehandle_init()
50 handle->ha_fid.fid_len = xfs_filehandle_fid_len(); in xfs_filehandle_init()
51 handle->ha_fid.fid_pad = 0; in xfs_filehandle_init()
52 handle->ha_fid.fid_gen = gen; in xfs_filehandle_init()
53 handle->ha_fid.fid_ino = ino; in xfs_filehandle_init()
63 memcpy(&handle->ha_fsid, mp->m_fixedfsid, sizeof(struct xfs_fsid)); in xfs_fshandle_init()
64 memset(&handle->ha_fid, 0, sizeof(handle->ha_fid)); in xfs_fshandle_init()
93 CLASS(fd, f)(hreq->fd); in xfs_find_handle()
96 return -EBADF; in xfs_find_handle()
97 path = fd_file(f)->f_path; in xfs_find_handle()
100 error = user_path_at(AT_FDCWD, hreq->path, 0, &path); in xfs_find_handle()
111 error = -EINVAL; in xfs_find_handle()
112 if (inode->i_sb->s_magic != XFS_SB_MAGIC) in xfs_find_handle()
115 error = -EBADF; in xfs_find_handle()
116 if (!S_ISREG(inode->i_mode) && in xfs_find_handle()
117 !S_ISDIR(inode->i_mode) && in xfs_find_handle()
118 !S_ISLNK(inode->i_mode)) in xfs_find_handle()
122 memcpy(&handle.ha_fsid, ip->i_mount->m_fixedfsid, sizeof(xfs_fsid_t)); in xfs_find_handle()
125 hsize = xfs_fshandle_init(ip->i_mount, &handle); in xfs_find_handle()
127 hsize = xfs_filehandle_init(ip->i_mount, ip->i_ino, in xfs_find_handle()
128 inode->i_generation, &handle); in xfs_find_handle()
130 error = -EFAULT; in xfs_find_handle()
131 if (copy_to_user(hreq->ohandle, &handle, hsize) || in xfs_find_handle()
132 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32))) in xfs_find_handle()
161 .ino = handle->ha_fid.fid_ino, in xfs_khandle_to_dentry()
162 .gen = handle->ha_fid.fid_gen, in xfs_khandle_to_dentry()
168 if (!S_ISDIR(file_inode(file)->i_mode)) in xfs_khandle_to_dentry()
169 return ERR_PTR(-ENOTDIR); in xfs_khandle_to_dentry()
171 if (handle->ha_fid.fid_len != xfs_filehandle_fid_len()) in xfs_khandle_to_dentry()
172 return ERR_PTR(-EINVAL); in xfs_khandle_to_dentry()
174 return exportfs_decode_fh(file->f_path.mnt, (struct fid *)&fid, 3, in xfs_khandle_to_dentry()
186 struct xfs_mount *mp = ip->i_mount; in xfs_khandle_to_inode()
189 if (!S_ISDIR(VFS_I(ip)->i_mode)) in xfs_khandle_to_inode()
190 return ERR_PTR(-ENOTDIR); in xfs_khandle_to_inode()
192 if (handle->ha_fid.fid_len != xfs_filehandle_fid_len()) in xfs_khandle_to_inode()
193 return ERR_PTR(-EINVAL); in xfs_khandle_to_inode()
195 inode = xfs_nfs_get_inode(mp->m_super, handle->ha_fid.fid_ino, in xfs_khandle_to_inode()
196 handle->ha_fid.fid_gen); in xfs_khandle_to_inode()
215 return ERR_PTR(-EINVAL); in xfs_handle_to_dentry()
217 return ERR_PTR(-EFAULT); in xfs_handle_to_dentry()
227 return xfs_handle_to_dentry(parfilp, hreq->ihandle, hreq->ihandlen); in xfs_handlereq_to_dentry()
246 return -EPERM; in xfs_open_by_handle()
254 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) { in xfs_open_by_handle()
255 error = -EPERM; in xfs_open_by_handle()
260 hreq->oflags |= O_LARGEFILE; in xfs_open_by_handle()
263 permflag = hreq->oflags; in xfs_open_by_handle()
267 error = -EPERM; in xfs_open_by_handle()
272 error = -EPERM; in xfs_open_by_handle()
277 if (S_ISDIR(inode->i_mode) && (fmode & FMODE_WRITE)) { in xfs_open_by_handle()
278 error = -EISDIR; in xfs_open_by_handle()
288 path.mnt = parfilp->f_path.mnt; in xfs_open_by_handle()
290 filp = dentry_open(&path, hreq->oflags, cred); in xfs_open_by_handle()
297 if (S_ISREG(inode->i_mode)) { in xfs_open_by_handle()
298 filp->f_flags |= O_NOATIME; in xfs_open_by_handle()
299 filp->f_mode |= FMODE_NOCMTIME; in xfs_open_by_handle()
320 return -EPERM; in xfs_readlink_by_handle()
328 error = -EINVAL; in xfs_readlink_by_handle()
332 if (copy_from_user(&olen, hreq->ohandlen, sizeof(__u32))) { in xfs_readlink_by_handle()
333 error = -EFAULT; in xfs_readlink_by_handle()
337 error = vfs_readlink(dentry, hreq->ohandle, olen); in xfs_readlink_by_handle()
358 struct xfs_attrlist *alist = context->buffer; in xfs_ioc_attr_put_listent()
362 ASSERT(!context->seen_enough); in xfs_ioc_attr_put_listent()
363 ASSERT(context->count >= 0); in xfs_ioc_attr_put_listent()
364 ASSERT(context->count < (ATTR_MAX_VALUELEN/8)); in xfs_ioc_attr_put_listent()
365 ASSERT(context->firstu >= sizeof(*alist)); in xfs_ioc_attr_put_listent()
366 ASSERT(context->firstu <= context->bufsize); in xfs_ioc_attr_put_listent()
371 if (context->attr_filter != (flags & XFS_ATTR_NSP_ONDISK_MASK)) in xfs_ioc_attr_put_listent()
375 context->count * sizeof(alist->al_offset[0]); in xfs_ioc_attr_put_listent()
378 context->firstu -= round_up(offsetof(struct xfs_attrlist_ent, a_name) + in xfs_ioc_attr_put_listent()
380 if (context->firstu < arraytop) { in xfs_ioc_attr_put_listent()
382 alist->al_more = 1; in xfs_ioc_attr_put_listent()
383 context->seen_enough = 1; in xfs_ioc_attr_put_listent()
387 aep = context->buffer + context->firstu; in xfs_ioc_attr_put_listent()
388 aep->a_valuelen = valuelen; in xfs_ioc_attr_put_listent()
389 memcpy(aep->a_name, name, namelen); in xfs_ioc_attr_put_listent()
390 aep->a_name[namelen] = 0; in xfs_ioc_attr_put_listent()
391 alist->al_offset[context->count++] = context->firstu; in xfs_ioc_attr_put_listent()
392 alist->al_count = context->count; in xfs_ioc_attr_put_listent()
436 return -EINVAL; in xfs_ioc_attr_list()
442 return -EINVAL; in xfs_ioc_attr_list()
444 return -EINVAL; in xfs_ioc_attr_list()
450 return -EFAULT; in xfs_ioc_attr_list()
452 return -EINVAL; in xfs_ioc_attr_list()
456 return -EINVAL; in xfs_ioc_attr_list()
460 return -ENOMEM; in xfs_ioc_attr_list()
474 alist->al_count = 0; in xfs_ioc_attr_list()
475 alist->al_more = 0; in xfs_ioc_attr_list()
476 alist->al_offset[0] = context.bufsize; in xfs_ioc_attr_list()
484 error = -EFAULT; in xfs_ioc_attr_list()
497 int error = -ENOMEM; in xfs_attrlist_by_handle()
500 return -EPERM; in xfs_attrlist_by_handle()
502 return -EFAULT; in xfs_attrlist_by_handle()
509 al_hreq.buflen, al_hreq.flags, &p->pos); in xfs_attrlist_by_handle()
532 return -EINVAL; in xfs_attrmulti_attr_get()
540 error = -EFAULT; in xfs_attrmulti_attr_get()
564 return -EPERM; in xfs_attrmulti_attr_set()
568 return -EINVAL; in xfs_attrmulti_attr_set()
596 return -EINVAL; in xfs_ioc_attrmulti_one()
618 error = -EINVAL; in xfs_ioc_attrmulti_one()
638 return -EPERM; in xfs_attrmulti_by_handle()
640 return -EFAULT; in xfs_attrmulti_by_handle()
644 return -E2BIG; in xfs_attrmulti_by_handle()
650 error = -E2BIG; in xfs_attrmulti_by_handle()
670 error = -EFAULT; in xfs_attrmulti_by_handle()
713 struct xfs_inode *ip = context->dp; in xfs_getparents_put_listent()
714 struct xfs_mount *mp = ip->i_mount; in xfs_getparents_put_listent()
715 struct xfs_getparents *gp = &gpx->gph.gph_request; in xfs_getparents_put_listent() local
716 struct xfs_getparents_rec *gpr = gpx->krecords + context->firstu; in xfs_getparents_put_listent()
730 context->seen_enough = -EFSCORRUPTED; in xfs_getparents_put_listent()
739 if (context->firstu > context->bufsize - reclen) { in xfs_getparents_put_listent()
740 context->seen_enough = 1; in xfs_getparents_put_listent()
745 gpr->gpr_reclen = reclen; in xfs_getparents_put_listent()
746 xfs_filehandle_init(mp, ino, gen, &gpr->gpr_parent); in xfs_getparents_put_listent()
747 memcpy(gpr->gpr_name, name, namelen); in xfs_getparents_put_listent()
748 gpr->gpr_name[namelen] = 0; in xfs_getparents_put_listent()
750 trace_xfs_getparents_put_listent(ip, gp, context, gpr); in xfs_getparents_put_listent()
752 context->firstu += reclen; in xfs_getparents_put_listent()
753 gpx->count++; in xfs_getparents_put_listent()
754 gpx->lastrec = gpr; in xfs_getparents_put_listent()
762 struct xfs_getparents *gp = &gpx->gph.gph_request; in xfs_getparents_expand_lastrec() local
763 struct xfs_getparents_rec *gpr = gpx->lastrec; in xfs_getparents_expand_lastrec()
765 if (!gpx->lastrec) in xfs_getparents_expand_lastrec()
766 gpr = gpx->krecords; in xfs_getparents_expand_lastrec()
768 gpr->gpr_reclen = gp->gp_bufsize - ((void *)gpr - gpx->krecords); in xfs_getparents_expand_lastrec()
770 trace_xfs_getparents_expand_lastrec(gpx->ip, gp, &gpx->context, gpr); in xfs_getparents_expand_lastrec()
778 struct xfs_getparents *gp = &gpx->gph.gph_request; in xfs_getparents() local
779 struct xfs_inode *ip = gpx->ip; in xfs_getparents()
780 struct xfs_mount *mp = ip->i_mount; in xfs_getparents()
785 if (gp->gp_bufsize > XFS_XATTR_LIST_MAX) in xfs_getparents()
786 return -ENOMEM; in xfs_getparents()
787 if (gp->gp_bufsize < xfs_getparents_rec_sizeof(1)) in xfs_getparents()
788 return -EINVAL; in xfs_getparents()
790 if (gp->gp_iflags & ~XFS_GETPARENTS_IFLAGS_ALL) in xfs_getparents()
791 return -EINVAL; in xfs_getparents()
792 if (gp->gp_reserved) in xfs_getparents()
793 return -EINVAL; in xfs_getparents()
795 bufsize = round_down(gp->gp_bufsize, sizeof(uint64_t)); in xfs_getparents()
796 gpx->krecords = kvzalloc(bufsize, GFP_KERNEL); in xfs_getparents()
797 if (!gpx->krecords) { in xfs_getparents()
799 gpx->krecords = kvzalloc(bufsize, GFP_KERNEL); in xfs_getparents()
800 if (!gpx->krecords) in xfs_getparents()
801 return -ENOMEM; in xfs_getparents()
804 gpx->context.dp = ip; in xfs_getparents()
805 gpx->context.resynch = 1; in xfs_getparents()
806 gpx->context.put_listent = xfs_getparents_put_listent; in xfs_getparents()
807 gpx->context.bufsize = bufsize; in xfs_getparents()
809 gpx->context.firstu = 0; in xfs_getparents()
812 memcpy(&gpx->context.cursor, &gp->gp_cursor, in xfs_getparents()
814 gpx->count = 0; in xfs_getparents()
815 gp->gp_oflags = 0; in xfs_getparents()
817 trace_xfs_getparents_begin(ip, gp, &gpx->context.cursor); in xfs_getparents()
819 error = xfs_attr_list(&gpx->context); in xfs_getparents()
822 if (gpx->context.seen_enough < 0) { in xfs_getparents()
823 error = gpx->context.seen_enough; in xfs_getparents()
829 memcpy(&gp->gp_cursor, &gpx->context.cursor, in xfs_getparents()
833 if (ip->i_ino == mp->m_sb.sb_rootino) in xfs_getparents()
834 gp->gp_oflags |= XFS_GETPARENTS_OFLAG_ROOT; in xfs_getparents()
836 if (gpx->context.seen_enough == 0) { in xfs_getparents()
841 gp->gp_oflags |= XFS_GETPARENTS_OFLAG_DONE; in xfs_getparents()
842 } else if (gpx->count == 0) { in xfs_getparents()
848 error = -EMSGSIZE; in xfs_getparents()
852 trace_xfs_getparents_end(ip, gp, &gpx->context.cursor); in xfs_getparents()
854 ASSERT(gpx->context.firstu <= gpx->gph.gph_request.gp_bufsize); in xfs_getparents()
857 if (copy_to_user(u64_to_user_ptr(gpx->gph.gph_request.gp_buffer), in xfs_getparents()
858 gpx->krecords, gpx->context.firstu)) in xfs_getparents()
859 error = -EFAULT; in xfs_getparents()
862 kvfree(gpx->krecords); in xfs_getparents()
863 gpx->krecords = NULL; in xfs_getparents()
877 struct xfs_mount *mp = gpx.ip->i_mount; in xfs_ioc_getparents()
881 return -EPERM; in xfs_ioc_getparents()
883 return -EOPNOTSUPP; in xfs_ioc_getparents()
885 return -EFAULT; in xfs_ioc_getparents()
892 return -EFAULT; in xfs_ioc_getparents()
905 struct xfs_mount *mp = ip->i_mount; in xfs_ioc_getparents_by_handle()
907 struct xfs_handle *handle = &kreq->gph_handle; in xfs_ioc_getparents_by_handle()
911 return -EPERM; in xfs_ioc_getparents_by_handle()
913 return -EOPNOTSUPP; in xfs_ioc_getparents_by_handle()
915 return -EFAULT; in xfs_ioc_getparents_by_handle()
927 * userspace single-step the path reconstruction to avoid loops or in xfs_ioc_getparents_by_handle()
939 error = -EFAULT; in xfs_ioc_getparents_by_handle()