Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
signed __int64 __fastcall apfs_snapshot_rename_raw(rename_call_struct *args)
{
void *v_mount; // x0
__int64 fs_private; // x19
snap_info_args_struct *oldsnap_info; // x8
__int64 oldname_len; // x20
unsigned __int8 *oldname; // x21
snap_info_args_struct *newsnap_info; // x8
unsigned __int64 namelen; // x22
unsigned __int8 *newname; // x23
int v10; // w8
int v11; // w9
signed __int64 v13; // x10
char *v14; // x11
char *v15; // x12
char v16; // t1
char v17; // t1
__int64 ret; // x0 MAPDST
void *snap_vnode; // x25
signed int a3; // [xsp+44h] [xbp-6Ch]
__int64 snap_data_out; // [xsp+48h] [xbp-68h]
__int64 result; // [xsp+50h] [xbp-60h]
__int64 fsnode; // [xsp+58h] [xbp-58h] MAPDST
__int64 v29; // [xsp+60h] [xbp-50h]
__int64 snap_xid; // [xsp+68h] [xbp-48h]
v_mount = vnode_mount_stub(args->vnode);
fs_private = vfs_fsprivate(v_mount);
v29 = 0LL;
result = 0LL;
fsnode = 0LL;
snap_data_out = 0LL;
if ( *(*(fs_private + 0xB8) + 0x11CLL)
|| *(vnode_fsnode_stub(args->vnode) + 8)
|| *vnode_fsnode_stub(args->vnode) != 1
|| *(vnode_fsnode_stub(args->fvp) + 8)
|| *vnode_fsnode_stub(args->fvp) != 1 )
{
return 1LL;
}
oldsnap_info = args->oldsnap_info;
oldname_len = oldsnap_info->oldname_len;
oldname = oldsnap_info->oldname_buf;
newsnap_info = args->newsnap_info;
namelen = newsnap_info->oldname_len;
newname = newsnap_info->oldname_buf;
v10 = *oldname;
if ( v10 == 46 && (oldname_len == 1 || oldname_len == 2 && oldname[1] == 46) )
return 22LL;
v11 = *newname;
if ( v11 == 46 && (namelen == 1 || namelen == 2 && newname[1] == 46) )
return 22LL;
if ( namelen > 255 )
return 63LL;
if ( oldname_len == namelen )
{
if ( oldname_len )
{
v13 = 1 - oldname_len;
v14 = (newname + 1);
v15 = (oldname + 1);
while ( v10 == v11 )
{
if ( !v11 || !v13 )
return 22LL;
v16 = *v15++;
LOBYTE(v10) = v16;
v17 = *v14++;
LOBYTE(v11) = v17;
++v13;
}
goto LABEL_23;
}
return 22LL;
}
LABEL_23:
if ( apfs_find_snap_from_name(newname, namelen, 0LL, 0LL) & 1 )
return 1LL;
sub_FFFFFFF006AA1CDC(*(fs_private + 7872));
++*(fs_private + 7864);
sub_FFFFFFF006AA1CF4(*(fs_private + 7872));
sub_FFFFFFF006AA1D18(*(fs_private + 7840));
sub_FFFFFFF006A28870(fs_private);
sub_FFFFFFF006AA1D30(*(fs_private + 7848));
ret = sub_FFFFFFF006A1E6D8(fs_private, newname, namelen, &result);
if ( ret != 2 )
{
if ( !ret )
{
sub_FFFFFFF006A5ED28(result);
ret = 17LL;
}
goto LABEL_47;
}
if ( apfs_find_snap_from_name(oldname, oldname_len, &a3, &snap_xid) )
{
if ( a3 != 1 )
{
ret = 2LL;
goto LABEL_47;
}
ret = sub_FFFFFFF006A1E5A0(fs_private, snap_xid, &fsnode, &snap_data_out);
}
else
{
ret = apfs_lookup_snap(fs_private, oldname, oldname_len, &fsnode, &snap_data_out);
}
if ( ret )
{
LABEL_35:
if ( fsnode )
sub_FFFFFFF006A5ED28(fsnode);
goto LABEL_47;
}
snap_vnode = apfs_jhash_getvnode(fs_private, *(fs_private + 0x1B8), *(fsnode + 8), 1LL, 0LL, 0LL);
if ( snap_vnode && (sub_FFFFFFF006A5ED28(fsnode), fsnode = vnode_fsnode_stub(snap_vnode), *(fsnode + 49) & 0x40) )
{
ret = 1LL;
}
else
{
v29 = 0LL;
ret = fs_tx_enter_recursively(fs_private, 1LL, 4LL, 0LL, &v29);
if ( !ret )
{
ret = fs_rename_snapshot(fs_private, fsnode, snap_data_out, newname, namelen, v29);
if ( ret )
vprintf_sth_stub(aSDFsRenameSnap, aApfsSnapVnopRe_0, 898LL, oldname, oldname_len, newname, namelen, ret);
}
if ( !snap_vnode )
goto LABEL_35;
}
vnode_put_stub(snap_vnode);
LABEL_47:
if ( snap_data_out )
sub_FFFFFFF006A5ED28(snap_data_out);
if ( v29 )
{
sub_FFFFFFF006A66B50(fs_private, 1LL, 4LL, 0LL);
v29 = 0LL;
}
sub_FFFFFFF006AA1D54(*(fs_private + 7840));
sub_FFFFFFF006AA1D60(*(fs_private + 7848));
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.