fs/xfs/libxfs/xfs_symlink_remote.c
Source file repositories/reference/linux-study-clean/fs/xfs/libxfs/xfs_symlink_remote.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/libxfs/xfs_symlink_remote.c- Extension
.c- Size
- 9988 bytes
- Lines
- 433
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xfs_platform.hxfs_fs.hxfs_format.hxfs_log_format.hxfs_shared.hxfs_trans_resv.hxfs_mount.hxfs_inode.hxfs_error.hxfs_trans.hxfs_buf_item.hxfs_log.hxfs_symlink_remote.hxfs_bit.hxfs_bmap.hxfs_health.h
Detected Declarations
function Copyrightfunction xfs_symlink_hdr_setfunction xfs_symlink_hdr_okfunction xfs_symlink_verifyfunction xfs_symlink_read_verifyfunction xfs_symlink_write_verifyfunction xfs_symlink_local_to_remotefunction xfs_symlink_shortform_verifyfunction xfs_symlink_remote_readfunction xfs_symlink_write_targetfunction xfs_symlink_remote_truncate
Annotated Snippet
if (xfs_has_crc(mp)) {
if (!xfs_symlink_hdr_ok(I_INO(ip), offset,
byte_cnt, bp)) {
xfs_inode_mark_sick(ip, XFS_SICK_INO_SYMLINK);
error = -EFSCORRUPTED;
xfs_alert(mp,
"symlink header does not match required off/len/owner (0x%x/0x%x,0x%llx)",
offset, byte_cnt, I_INO(ip));
xfs_buf_relse(bp);
goto out;
}
cur_chunk += sizeof(struct xfs_dsymlink_hdr);
}
memcpy(link + offset, cur_chunk, byte_cnt);
pathlen -= byte_cnt;
offset += byte_cnt;
xfs_buf_relse(bp);
}
ASSERT(pathlen == 0);
link[ip->i_disk_size] = '\0';
error = 0;
out:
return error;
}
/* Write the symlink target into the inode. */
int
xfs_symlink_write_target(
struct xfs_trans *tp,
struct xfs_inode *ip,
xfs_ino_t owner,
const char *target_path,
int pathlen,
xfs_fsblock_t fs_blocks,
uint resblks)
{
struct xfs_bmbt_irec mval[XFS_SYMLINK_MAPS];
struct xfs_mount *mp = tp->t_mountp;
const char *cur_chunk;
struct xfs_buf *bp;
xfs_daddr_t d;
int byte_cnt;
int nmaps;
int offset = 0;
int n;
int error;
/*
* If the symlink will fit into the inode, write it inline.
*/
if (pathlen <= xfs_inode_data_fork_size(ip)) {
xfs_init_local_fork(ip, XFS_DATA_FORK, target_path, pathlen);
ip->i_disk_size = pathlen;
ip->i_df.if_format = XFS_DINODE_FMT_LOCAL;
xfs_trans_log_inode(tp, ip, XFS_ILOG_DDATA | XFS_ILOG_CORE);
return 0;
}
nmaps = XFS_SYMLINK_MAPS;
error = xfs_bmapi_write(tp, ip, 0, fs_blocks, XFS_BMAPI_METADATA,
resblks, mval, &nmaps);
if (error)
return error;
ip->i_disk_size = pathlen;
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
cur_chunk = target_path;
offset = 0;
for (n = 0; n < nmaps; n++) {
char *buf;
d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock);
byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
BTOBB(byte_cnt), 0, &bp);
if (error)
return error;
bp->b_ops = &xfs_symlink_buf_ops;
byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt);
byte_cnt = min(byte_cnt, pathlen);
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_shared.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_inode.h`.
- Detected declarations: `function Copyright`, `function xfs_symlink_hdr_set`, `function xfs_symlink_hdr_ok`, `function xfs_symlink_verify`, `function xfs_symlink_read_verify`, `function xfs_symlink_write_verify`, `function xfs_symlink_local_to_remote`, `function xfs_symlink_shortform_verify`, `function xfs_symlink_remote_read`, `function xfs_symlink_write_target`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.