About | ACP | Buy Stuff | Industry Watch | Learning Curve | Newsletter | Search | Test Drive
Home » Learning Curve » ACP Guru

Swapping on APFS with Catalina

Yes it's an exercise.

Get It

Try It

NOTTING HILL (Rixstep) — The original idea was the Edmund Hillary idea - 'it's there'. The API existed. So use it, expose it, make it available.

The API exchangedata() used CNID 15, otherwise left unused. The 'swap' must have been done on a low level. The correspondence between Unix inodes and HFS CNIDs made it possible.

But today's APFS doesn't have that facility.

Remaking Swap.app for APFS was an exercise, and not much more, but it's been an interesting exercise. exchangedata() could be considered an 'atomic' operation, and the new APIs admit of such a possibility, but they're not available on APFS, at least not yet.

There was little point in trying to make sure that a 'swap' was possible before attempting it: if work with file management shows one thing, it's that nothing's certain until it's carried out. This made it necessary to implement a rollback system. But even a rollback won't necessarily succeed. Additional diagnostics are provided so that you can see where your files go off to if something should go wrong. The files, even in such an event, should still exist, as they're never tampered with in any way.

Normally you'll find 'orphaned' files in /tmp.

A 'swap' on APFS entails three operations, as it would on HFS, but here the three operations are:

  1. 'Move' file 1 to a temporary location (/tmp/SwapXXXXXXXXXX where 'XXXXXXXXXX' is a type of 'random' number generated from your machine 'uptime', which should be unique throughout a boot).
  2. 'Move' file 2 to file 1.
  3. 'Move' the file at the temporary location to file 2.

The files (their contents) are of course never touched.

This version of Swap has been tested with a number of 'nightmare scenarios' such as removing a parent directory's write permission and setting file flags on one or both files.

This version of Swap also makes sure that the two targets are not the same physical file, as the API documentation warns of a possible race condition. The same logic as found in Rixcomp is used: either the file systems or the inodes must be different.

This APFS version for Catalina incorporates 'Dark Mode'.

Swap.app is included in both the ACP and Xfile collections.

About Rixstep

Stockholm/London-based Rixstep are a constellation of programmers and support staff from Radsoft Laboratories who tired of Windows vulnerabilities, Linux driver issues, and cursing x86 hardware all day long. Rixstep have many years of experience behind their efforts, with teaching and consulting credentials from the likes of British Aerospace, General Electric, Lockheed Martin, Lloyds TSB, SAAB Defence Systems, British Broadcasting Corporation, Barclays Bank, IBM, Microsoft, and Sony/Ericsson.

Rixstep and Radsoft products are or have been in use by Sweden's Royal Mail, Sony/Ericsson, the US Department of Defense, the offices of the US Supreme Court, the Government of Western Australia, the German Federal Police, Verizon Wireless, Los Alamos National Laboratory, Microsoft Corporation, the New York Times, Apple Inc, Oxford University, and hundreds of research institutes around the globe. See here.

All Content and Software Copyright © Rixstep. All Rights Reserved.

John Cattelin
Media Contact
ACP/Xfile licences
About | ACP | Buy Stuff | Industry Watch | Learning Curve | Newsletter | Search | Test Drive
Copyright © Rixstep. All rights reserved.