xfs_symlink.c (8aa921a95335d0a8c8e2be35a44467e7c91ec3e4) xfs_symlink.c (f736d93d76d3e97d6986c6d26c8eaa32536ccc5c)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
4 * Copyright (c) 2012-2013 Red Hat, Inc.
5 * All rights reserved.
6 */
7#include "xfs.h"
8#include "xfs_shared.h"

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

129
130 out:
131 xfs_iunlock(ip, XFS_ILOCK_SHARED);
132 return error;
133}
134
135int
136xfs_symlink(
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
4 * Copyright (c) 2012-2013 Red Hat, Inc.
5 * All rights reserved.
6 */
7#include "xfs.h"
8#include "xfs_shared.h"

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

129
130 out:
131 xfs_iunlock(ip, XFS_ILOCK_SHARED);
132 return error;
133}
134
135int
136xfs_symlink(
137 struct user_namespace *mnt_userns,
137 struct xfs_inode *dp,
138 struct xfs_name *link_name,
139 const char *target_path,
140 umode_t mode,
141 struct xfs_inode **ipp)
142{
143 struct xfs_mount *mp = dp->i_mount;
144 struct xfs_trans *tp = NULL;

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

215 /*
216 * Reserve disk quota : blocks and inode.
217 */
218 error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp,
219 pdqp, resblks, 1, 0);
220 if (error)
221 goto out_trans_cancel;
222
138 struct xfs_inode *dp,
139 struct xfs_name *link_name,
140 const char *target_path,
141 umode_t mode,
142 struct xfs_inode **ipp)
143{
144 struct xfs_mount *mp = dp->i_mount;
145 struct xfs_trans *tp = NULL;

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

216 /*
217 * Reserve disk quota : blocks and inode.
218 */
219 error = xfs_trans_reserve_quota(tp, mp, udqp, gdqp,
220 pdqp, resblks, 1, 0);
221 if (error)
222 goto out_trans_cancel;
223
223 error = xfs_iext_count_may_overflow(dp, XFS_DATA_FORK,
224 XFS_IEXT_DIR_MANIP_CNT(mp));
225 if (error)
226 goto out_trans_cancel;
227
228 /*
229 * Allocate an inode for the symlink.
230 */
224 /*
225 * Allocate an inode for the symlink.
226 */
231 error = xfs_dir_ialloc(&tp, dp, S_IFLNK | (mode & ~S_IFMT), 1, 0,
232 prid, &ip);
227 error = xfs_dir_ialloc(mnt_userns, &tp, dp, S_IFLNK | (mode & ~S_IFMT),
228 1, 0, prid, &ip);
233 if (error)
234 goto out_trans_cancel;
235
236 /*
237 * Now we join the directory inode to the transaction. We do not do it
238 * earlier because xfs_dir_ialloc might commit the previous transaction
239 * (and release all the locks). An error from here on will result in
240 * the transaction cancel unlocking dp so don't do it explicitly in the

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

300 offset += byte_cnt;
301
302 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SYMLINK_BUF);
303 xfs_trans_log_buf(tp, bp, 0, (buf + byte_cnt - 1) -
304 (char *)bp->b_addr);
305 }
306 ASSERT(pathlen == 0);
307 }
229 if (error)
230 goto out_trans_cancel;
231
232 /*
233 * Now we join the directory inode to the transaction. We do not do it
234 * earlier because xfs_dir_ialloc might commit the previous transaction
235 * (and release all the locks). An error from here on will result in
236 * the transaction cancel unlocking dp so don't do it explicitly in the

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

296 offset += byte_cnt;
297
298 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SYMLINK_BUF);
299 xfs_trans_log_buf(tp, bp, 0, (buf + byte_cnt - 1) -
300 (char *)bp->b_addr);
301 }
302 ASSERT(pathlen == 0);
303 }
308 i_size_write(VFS_I(ip), ip->i_d.di_size);
309
310 /*
311 * Create the directory entry for the symlink.
312 */
313 error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks);
314 if (error)
315 goto out_trans_cancel;
316 xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);

--- 193 unchanged lines hidden ---
304
305 /*
306 * Create the directory entry for the symlink.
307 */
308 error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks);
309 if (error)
310 goto out_trans_cancel;
311 xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);

--- 193 unchanged lines hidden ---