Add "rbfs" prefix to native filesystem functions

Most of the churn here occurs because 'filesize' is one of
the redefined filesystem functions, but some of the structs
used by the native FS code also include a 'filesize' member
variable which gets renamed by the macro in some but not all
source files.

It's easier to rename 'filesize()' to 'ffilesize()' rather
than try to clean up the macro mess or renaming the struct
members.

There is weirdness with root_realpath() which now breaks on
native builds because it was assumed to be unprefixed there.
dir_get_info() was unprefixed everywhere but this just seems
inconsistent; make it follow the FS_PREFIX() convention too.

Change-Id: Ic3700c6234ea45f32679c1a8429d70fdb8f4088a
This commit is contained in:
Aidan MacDonald 2026-09-03 20:35:48 +01:00
parent 6958f6638e
commit 3a57f2f721
105 changed files with 188 additions and 182 deletions

View file

@ -32,7 +32,7 @@
#include "inttypes.h"
#include <sys/stat.h>
int filesize(int fd)
int ffilesize(int fd)
{
struct stat buf;

View file

@ -95,7 +95,7 @@ int rm_get_packet(uint8_t **src,RMContext *rmctx, RMPacket *pkt);
#ifdef TEST
int filesize(int fd);
int ffilesize(int fd);
void advance_buffer(uint8_t **buf, int val);
/* Get a (sub_packet_h*frames_per_packet) number of audio frames from a file descriptor */

View file

@ -70,7 +70,7 @@ bool get_a52_metadata(int fd, struct mp3entry *id3)
id3->bitrate = a52_bitrates[i >> 1];
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
switch (buf[4] & 0xc0)
{

View file

@ -72,7 +72,7 @@ bool get_aac_metadata(int fd, struct mp3entry *entry)
entry->id3v1len = 0;
entry->id3v2len = getid3v2len(fd);
entry->first_frame_offset = entry->id3v2len;
entry->filesize = filesize(fd) - entry->first_frame_offset;
entry->filesize = ffilesize(fd) - entry->first_frame_offset;
entry->needs_upsampling_correction = false;
if (entry->id3v2len)

View file

@ -69,7 +69,7 @@ bool get_adx_metadata(int fd, struct mp3entry* id3)
id3->bitrate = id3->frequency * channels * 18 * 8 / 32 / 1000;
id3->length = get_long_be(&buf[12]) / id3->frequency * 1000;
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
/* get loop info */
if (!memcmp(buf+0x10,"\x01\xF4\x03",3)) {

View file

@ -142,7 +142,7 @@ bool get_aiff_metadata(int fd, struct mp3entry* id3)
}
id3->vbr = false; /* AIFF files are CBR */
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
}
else
{

View file

@ -241,7 +241,7 @@ static bool parse_sap_header(int fd, struct mp3entry* id3, int file_len)
bool get_asap_metadata(int fd, struct mp3entry* id3)
{
int filelength = filesize(fd);
int filelength = ffilesize(fd);
if(parse_sap_header(fd, id3, filelength) == false)
{

View file

@ -647,7 +647,7 @@ bool get_asf_metadata(int fd, struct mp3entry* id3)
header.
*/
id3->first_frame_offset = lseek(fd, 0, SEEK_CUR) + 26;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
/* We copy the wfx struct to the MP3 TOC field in the id3 struct so
the codec doesn't need to parse the header object again */
memcpy(id3->toc, &wfx, sizeof(wfx));

View file

@ -58,7 +58,7 @@ bool get_au_metadata(int fd, struct mp3entry* id3)
int offset;
id3->vbr = false; /* All Sun audio files are CBR */
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->length = 0;
lseek(fd, 0, SEEK_SET);

View file

@ -135,7 +135,7 @@ bool get_ay_metadata(int fd, struct mp3entry* id3)
return false;
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->bitrate = 706;
id3->frequency = 44100;

View file

@ -121,7 +121,7 @@ bool get_flac_metadata(int fd, struct mp3entry* id3)
}
id3->vbr = true; /* All FLAC files are VBR */
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->frequency = (buf[10] << 12) | (buf[11] << 4)
| ((buf[12] & 0xf0) >> 4);
rc = true; /* Got vital metadata */

View file

@ -52,7 +52,7 @@ bool get_gbs_metadata(int fd, struct mp3entry* id3)
return false;
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
/* we only render 16 bits, 44.1KHz, Stereo */
id3->bitrate = 706;
id3->frequency = 44100;

View file

@ -26,7 +26,7 @@ bool get_hes_metadata(int fd, struct mp3entry* id3)
return false;
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
/* we only render 16 bits, 44.1KHz, Stereo */
id3->bitrate = 706;
id3->frequency = 44100;

View file

@ -40,7 +40,7 @@ bool get_kss_metadata(int fd, struct mp3entry* id3)
return false;
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
/* we only render 16 bits, 44.1KHz, Stereo */
id3->bitrate = 706;
id3->frequency = 44100;

View file

@ -41,7 +41,7 @@ static bool get_shn_metadata(int fd, struct mp3entry *id3)
{
/* TODO: read the id3v2 header if it exists */
id3->vbr = true;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
return skip_id3v2(fd, id3);
}
@ -50,7 +50,7 @@ static bool get_other_asap_metadata(int fd, struct mp3entry *id3)
id3->bitrate = 706;
id3->frequency = 44100;
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->genre_string = id3_get_num_genre(36); /* GAME */
return true;
}

View file

@ -91,11 +91,11 @@ bool get_mod_metadata(int fd, struct mp3entry* id3)
return false;
id3->title = id3->id3v2buf; /* Point title to previous read ID3 buffer. */
id3->bitrate = filesize(fd)/1024; /* size in kb */
id3->frequency = 44100;
id3->length = 120*1000;
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->bitrate = id3->filesize / 1024; /* size in kb */
return true;
}

View file

@ -82,7 +82,7 @@ bool get_monkeys_metadata(int fd, struct mp3entry* id3)
}
id3->vbr = true; /* All APE files are VBR */
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
totalsamples = finalframeblocks;
if (totalframes > 1)

View file

@ -162,7 +162,7 @@ static int getsonglength(int fd, struct mp3entry *entry)
bool get_mp3_metadata(int fd, struct mp3entry *entry)
{
entry->title = NULL;
entry->filesize = filesize(fd);
entry->filesize = ffilesize(fd);
entry->id3v1len = getid3v1len(fd);
entry->id3v2len = getid3v2len(fd);

View file

@ -608,7 +608,7 @@ int get_mp3file_info(int fd, struct mp3info *info)
if(result)
return result;
info->byte_count = filesize(fd) - getid3v1len(fd) - offset - bytecount;
info->byte_count = ffilesize(fd) - getid3v1len(fd) - offset - bytecount;
}
return bytecount;

View file

@ -823,7 +823,7 @@ bool get_mp4_metadata(int fd, struct mp3entry* id3)
id3->filesize = 0;
errno = 0;
if (read_mp4_container(fd, id3, filesize(fd)) && (errno == 0)
if (read_mp4_container(fd, id3, ffilesize(fd)) && (errno == 0)
&& (id3->samples > 0) && (id3->frequency > 0)
&& (id3->filesize > 0))
{

View file

@ -211,7 +211,7 @@ bool get_musepack_metadata(int fd, struct mp3entry *id3)
return false;
}
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->bitrate = id3->filesize * 8 / id3->length;
read_ape_tags(fd, id3);

View file

@ -262,7 +262,7 @@ bool get_nsf_metadata(int fd, struct mp3entry* id3)
return false;
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
/* we only render 16 bits, 44.1KHz, Mono */
id3->bitrate = 706;
id3->frequency = 44100;

View file

@ -133,7 +133,7 @@ bool get_ogg_metadata(int fd, struct mp3entry* id3)
return false;
}
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
/* We need to ensure the serial number from this page is the same as the
* one from the last page (since we only support a single bitstream).

View file

@ -179,7 +179,7 @@ bool get_oma_metadata(int fd, struct mp3entry* id3)
/* Currently, there's no means of knowing the duration *
* directly from the the file so we calculate it. */
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->length = ((id3->filesize - id3->first_frame_offset) * 8) / id3->bitrate;
return true;
}

View file

@ -266,7 +266,7 @@ static inline int rm_parse_header(int fd, RMContext *rmctx, struct mp3entry *id3
rmctx->data_offset = skipped + 8;
rmctx->bit_rate = rmctx->block_align * rmctx->sample_rate / 192;
if (rmctx->block_align)
rmctx->nb_packets = (filesize(fd) - rmctx->data_offset) / rmctx->block_align;
rmctx->nb_packets = (ffilesize(fd) - rmctx->data_offset) / rmctx->block_align;
if (rmctx->sample_rate)
rmctx->duration = (uint32_t)(256LL * 6 * 1000 * rmctx->nb_packets / rmctx->sample_rate);
rmctx->flags |= RM_RAW_DATASTREAM;
@ -504,6 +504,6 @@ bool get_rm_metadata(int fd, struct mp3entry* id3)
id3->bitrate = (rmctx->bit_rate + 500) / 1000;
id3->frequency = rmctx->sample_rate;
id3->length = rmctx->duration;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
return true;
}

View file

@ -54,7 +54,7 @@ bool get_sgc_metadata(int fd, struct mp3entry* id3)
return false;
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
/* we only render 16 bits, 44.1KHz, Stereo */
id3->bitrate = 706;
id3->frequency = 44100;

View file

@ -82,7 +82,7 @@ bool get_sid_metadata(int fd, struct mp3entry* id3)
*/
id3->length = (buf[0xf]-1)*1000;
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
return true;
}

View file

@ -445,7 +445,7 @@ bool get_smaf_metadata(int fd, struct mp3entry* id3)
id3->composer = NULL;
id3->vbr = false; /* All SMAF files are CBR */
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
/* check File Chunk and Contents Info Chunk */
lseek(fd, 0, SEEK_SET);

View file

@ -124,7 +124,7 @@ bool get_spc_metadata(int fd, struct mp3entry* id3)
id3->frequency = 32000;
id3->length = length+fade;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->genre_string = id3_get_num_genre(36);
return true;

View file

@ -53,7 +53,7 @@
static void read_id3_tags(int fd, struct mp3entry* id3)
{
id3->title = NULL;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->id3v2len = getid3v2len(fd);
id3->vbr = false; /* All TTA files are CBR */

View file

@ -153,7 +153,7 @@ bool get_vgm_metadata(int fd, struct mp3entry* id3)
}
id3->vbr = false;
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->bitrate = 1411;
id3->frequency = 44100;

View file

@ -41,7 +41,7 @@ bool get_vox_metadata(int fd, struct mp3entry* id3)
id3->frequency = 8000;
id3->bitrate = 8000 * 4 / 1000;
id3->vbr = false; /* All VOX files are CBR */
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->length = id3->filesize >> 2;
return true;

View file

@ -102,7 +102,7 @@ bool get_vtx_metadata(int fd, struct mp3entry* id3)
if (lseek(fd, 0, SEEK_SET) < 0)
goto exit_bad;
if (filesize(fd) < 20)
if (ffilesize(fd) < 20)
goto exit_bad;
uint hdr = Reader_ReadWord(fd);
@ -142,7 +142,7 @@ bool get_vtx_metadata(int fd, struct mp3entry* id3)
id3->bitrate = 706;
id3->frequency = 44100; // XXX allow this to be configured?
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
id3->length = info.frames * 1000 / info.playerfreq;
return true;

View file

@ -305,7 +305,7 @@ static bool read_header(int fd, struct mp3entry* id3, const unsigned char *chunk
memset(&fmt, 0, sizeof(struct wave_fmt));
id3->vbr = false; /* All Wave/Wave64 files are CBR */
id3->filesize = filesize(fd);
id3->filesize = ffilesize(fd);
/* get RIFF chunk header */
lseek(fd, 0, SEEK_SET);

View file

@ -78,7 +78,7 @@ bool get_wavpack_metadata(int fd, struct mp3entry* id3)
}
id3->vbr = true; /* All WavPack files are VBR */
id3->filesize = filesize (fd);
id3->filesize = ffilesize (fd);
/* check up to 16 headers before we give up finding one with audio */

View file

@ -50,7 +50,7 @@
#endif
/* filesize */
off_t filesize(int fd);
off_t ffilesize(int fd);
/* snprintf */
#include <stdio.h>

View file

@ -3,4 +3,4 @@
#include <unistd.h>
#include <fcntl.h>
off_t filesize(int fd);
off_t ffilesize(int fd);

View file

@ -88,7 +88,7 @@ int find_first_set_bit(uint32_t value)
return __builtin_ctz(value);
}
off_t filesize(int fd)
off_t ffilesize(int fd)
{
struct stat st;
fstat(fd, &st);
@ -844,7 +844,7 @@ static void decode_file(const char *input_fn)
exit(1);
}
print_mp3entry(&id3, stderr);
ci.filesize = filesize(input_fd);
ci.filesize = ffilesize(input_fd);
ci.id3 = &id3;
if (use_dsp) {
ci.dsp = dsp_get_config(CODEC_IDX_AUDIO);