Re: [PATCH v7] exfat: add EXFAT_IOC_COMBINE to append a file's clusters to another

From: Shaopei Zhu

Date: Thu Nov 26 2026 - 02:54:01 EST


On Wed, Nov 25, 2026 at 11:18 AM Namjae Jeon <linkinjeon@xxxxxxxxxx> wrote:
> Is there a specific device or product expected to use this feature, or
> is it being added as a potentially useful capability without a
> concrete use case? If there is a target device or workflow, could you
> share some details?

Hi Namjae,

Thanks for the review. Yes, it is going to be used in camera products
that record to exFAT SD cards. The open source user is exfatcombine,
posted for exfatprogs [1], and a test for fstests (exfat/002) is posted
as well.

The workflow: cameras and dashcams keep motion or position data with
the video, e.g. gyroscope and accelerometer samples for stabilization,
or GPS.

The products on the market keep that data in one of three ways:

- as a timed metadata track inside the MP4, e.g. GoPro's GPMF, muxed
while recording, so that the samples are interleaved with the video
in the mdat box and indexed in the moov box;
- as a separate sidecar file next to the video, e.g. the GPS logs of
dashcams;
- as a trailer appended after the MP4 boxes when recording stops,
which players ignore and stabilization tools read.

A sidecar file is lost in practice: users copy, share or import only
the video file, and matching the two by name breaks once either is
renamed or moved. A track needs the muxer to take the samples in real
time along with the video. Where the sensor data comes from another
writer, at a few hundred samples per second, it cannot go into the file
the muxer is writing, so it is written to a separate file in the same
directory during recording and appended as a trailer when recording
stops.

That last step is what this ioctl is for. Today the sensor file is
copied into the video file, up to tens of MiB per recording, while the
user waits for the camera to be ready again, with flash wear and free
space needed for the copy. With this ioctl its clusters are appended
to the video file instead, and the sensor file is removed.

> I suggest changing EXFAT_IOC_COMBINE to transfer only the source's
> cluster chain to the destination, leaving the source linked as an
> empty file. Userspace can unlink it afterward if desired.

The sensor file is only a temporary part of the recording. With the
unlink in the same call, a power loss, e.g. the battery being pulled
right after recording stops, leaves one of the two states the
recording application already handles: not combined yet, or combined.
With the unlink in user space there is a third one, the combined video
next to an empty sensor file, which looks like the first one unless
every application also checks the size of the file. It would be easy
to append the sensor data a second time, or to leave an empty file on
a card that users read directly.

Doing it in the same call also refuses the whole call before anything
is changed if the source may not be removed, instead of leaving an
emptied file that cannot be deleted, and it removes the file that was
passed in, not whatever its name refers to by the time user space gets
to unlink it. The unlink goes through start_removing_dentry(),
security_path_unlink() and vfs_unlink(), so it gets the same checks as
unlink(2).

Does this address your concern?

Thanks,
Shaopei

[1] https://github.com/exfatprogs/exfatprogs/pull/412