xfs_itable.c (4b4193256c8d3bc3a5397b5cd9494c2ad386317d) xfs_itable.c (f736d93d76d3e97d6986c6d26c8eaa32536ccc5c)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6#include "xfs.h"
7#include "xfs_fs.h"
8#include "xfs_shared.h"

--- 40 unchanged lines hidden (view full) ---

49 * we can send back an error code.
50 *
51 * Note that if the formatter tells us there's no space left in the buffer we
52 * move the cursor forward and abort the walk.
53 */
54STATIC int
55xfs_bulkstat_one_int(
56 struct xfs_mount *mp,
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6#include "xfs.h"
7#include "xfs_fs.h"
8#include "xfs_shared.h"

--- 40 unchanged lines hidden (view full) ---

49 * we can send back an error code.
50 *
51 * Note that if the formatter tells us there's no space left in the buffer we
52 * move the cursor forward and abort the walk.
53 */
54STATIC int
55xfs_bulkstat_one_int(
56 struct xfs_mount *mp,
57 struct user_namespace *mnt_userns,
57 struct xfs_trans *tp,
58 xfs_ino_t ino,
59 struct xfs_bstat_chunk *bc)
60{
58 struct xfs_trans *tp,
59 xfs_ino_t ino,
60 struct xfs_bstat_chunk *bc)
61{
62 struct user_namespace *sb_userns = mp->m_super->s_user_ns;
61 struct xfs_icdinode *dic; /* dinode core info pointer */
62 struct xfs_inode *ip; /* incore inode pointer */
63 struct inode *inode;
64 struct xfs_bulkstat *buf = bc->buf;
65 int error = -EINVAL;
66
67 if (xfs_internal_inum(mp, ino))
68 goto out_advance;

--- 12 unchanged lines hidden (view full) ---

81
82 dic = &ip->i_d;
83
84 /* xfs_iget returns the following without needing
85 * further change.
86 */
87 buf->bs_projectid = ip->i_d.di_projid;
88 buf->bs_ino = ino;
63 struct xfs_icdinode *dic; /* dinode core info pointer */
64 struct xfs_inode *ip; /* incore inode pointer */
65 struct inode *inode;
66 struct xfs_bulkstat *buf = bc->buf;
67 int error = -EINVAL;
68
69 if (xfs_internal_inum(mp, ino))
70 goto out_advance;

--- 12 unchanged lines hidden (view full) ---

83
84 dic = &ip->i_d;
85
86 /* xfs_iget returns the following without needing
87 * further change.
88 */
89 buf->bs_projectid = ip->i_d.di_projid;
90 buf->bs_ino = ino;
89 buf->bs_uid = i_uid_read(inode);
90 buf->bs_gid = i_gid_read(inode);
91 buf->bs_uid = from_kuid(sb_userns, i_uid_into_mnt(mnt_userns, inode));
92 buf->bs_gid = from_kgid(sb_userns, i_gid_into_mnt(mnt_userns, inode));
91 buf->bs_size = dic->di_size;
92
93 buf->bs_nlink = inode->i_nlink;
94 buf->bs_atime = inode->i_atime.tv_sec;
95 buf->bs_atime_nsec = inode->i_atime.tv_nsec;
96 buf->bs_mtime = inode->i_mtime.tv_sec;
97 buf->bs_mtime_nsec = inode->i_mtime.tv_nsec;
98 buf->bs_ctime = inode->i_ctime.tv_sec;

--- 69 unchanged lines hidden (view full) ---

168
169 ASSERT(breq->icount == 1);
170
171 bc.buf = kmem_zalloc(sizeof(struct xfs_bulkstat),
172 KM_MAYFAIL);
173 if (!bc.buf)
174 return -ENOMEM;
175
93 buf->bs_size = dic->di_size;
94
95 buf->bs_nlink = inode->i_nlink;
96 buf->bs_atime = inode->i_atime.tv_sec;
97 buf->bs_atime_nsec = inode->i_atime.tv_nsec;
98 buf->bs_mtime = inode->i_mtime.tv_sec;
99 buf->bs_mtime_nsec = inode->i_mtime.tv_nsec;
100 buf->bs_ctime = inode->i_ctime.tv_sec;

--- 69 unchanged lines hidden (view full) ---

170
171 ASSERT(breq->icount == 1);
172
173 bc.buf = kmem_zalloc(sizeof(struct xfs_bulkstat),
174 KM_MAYFAIL);
175 if (!bc.buf)
176 return -ENOMEM;
177
176 error = xfs_bulkstat_one_int(breq->mp, NULL, breq->startino, &bc);
178 error = xfs_bulkstat_one_int(breq->mp, breq->mnt_userns, NULL,
179 breq->startino, &bc);
177
178 kmem_free(bc.buf);
179
180 /*
181 * If we reported one inode to userspace then we abort because we hit
182 * the end of the buffer. Don't leak that back to userspace.
183 */
184 if (error == -ECANCELED)

--- 4 unchanged lines hidden (view full) ---

189
190static int
191xfs_bulkstat_iwalk(
192 struct xfs_mount *mp,
193 struct xfs_trans *tp,
194 xfs_ino_t ino,
195 void *data)
196{
180
181 kmem_free(bc.buf);
182
183 /*
184 * If we reported one inode to userspace then we abort because we hit
185 * the end of the buffer. Don't leak that back to userspace.
186 */
187 if (error == -ECANCELED)

--- 4 unchanged lines hidden (view full) ---

192
193static int
194xfs_bulkstat_iwalk(
195 struct xfs_mount *mp,
196 struct xfs_trans *tp,
197 xfs_ino_t ino,
198 void *data)
199{
200 struct xfs_bstat_chunk *bc = data;
197 int error;
198
201 int error;
202
199 error = xfs_bulkstat_one_int(mp, tp, ino, data);
203 error = xfs_bulkstat_one_int(mp, bc->breq->mnt_userns, tp, ino, data);
200 /* bulkstat just skips over missing inodes */
201 if (error == -ENOENT || error == -EINVAL)
202 return 0;
203 return error;
204}
205
206/*
207 * Check the incoming lastino parameter.

--- 26 unchanged lines hidden (view full) ---

234 bulkstat_one_fmt_pf formatter)
235{
236 struct xfs_bstat_chunk bc = {
237 .formatter = formatter,
238 .breq = breq,
239 };
240 int error;
241
204 /* bulkstat just skips over missing inodes */
205 if (error == -ENOENT || error == -EINVAL)
206 return 0;
207 return error;
208}
209
210/*
211 * Check the incoming lastino parameter.

--- 26 unchanged lines hidden (view full) ---

238 bulkstat_one_fmt_pf formatter)
239{
240 struct xfs_bstat_chunk bc = {
241 .formatter = formatter,
242 .breq = breq,
243 };
244 int error;
245
246 if (breq->mnt_userns != &init_user_ns) {
247 xfs_warn_ratelimited(breq->mp,
248 "bulkstat not supported inside of idmapped mounts.");
249 return -EINVAL;
250 }
242 if (xfs_bulkstat_already_done(breq->mp, breq->startino))
243 return 0;
244
245 bc.buf = kmem_zalloc(sizeof(struct xfs_bulkstat),
246 KM_MAYFAIL);
247 if (!bc.buf)
248 return -ENOMEM;
249

--- 148 unchanged lines hidden ---
251 if (xfs_bulkstat_already_done(breq->mp, breq->startino))
252 return 0;
253
254 bc.buf = kmem_zalloc(sizeof(struct xfs_bulkstat),
255 KM_MAYFAIL);
256 if (!bc.buf)
257 return -ENOMEM;
258

--- 148 unchanged lines hidden ---