mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Implement volume information for AmigaOS.
This commit is contained in:
@@ -22,9 +22,122 @@ Aaru Data Preservation Suite
|
||||
Copyright (C) 2011-2021 Natalia Portillo
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dos/dos.h>
|
||||
#include <proto/dos.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
|
||||
void GetVolumeInfo(const char* path, size_t* clusterSize)
|
||||
{
|
||||
// TODO
|
||||
BPTR pathLock;
|
||||
struct InfoData info;
|
||||
int rc;
|
||||
long long total, free;
|
||||
unsigned char type[255];
|
||||
int pos = 0;
|
||||
unsigned char typeByte;
|
||||
|
||||
*clusterSize = 0;
|
||||
|
||||
memset(&info, 0, sizeof(struct InfoData));
|
||||
|
||||
pathLock = Lock((CONST_STRPTR)path, SHARED_LOCK);
|
||||
|
||||
if(!pathLock)
|
||||
{
|
||||
printf("Error %ld obtaining lock for the requested path\n", IoErr());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
rc = Info(pathLock, &info);
|
||||
|
||||
if(!rc)
|
||||
{
|
||||
printf("Error %ld obtaining lock for the requested path\n", IoErr());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
*clusterSize = info.id_BytesPerBlock;
|
||||
|
||||
total = info.id_NumBlocks * (long long)info.id_BytesPerBlock;
|
||||
free = (info.id_NumBlocks - info.id_NumBlocksUsed) * (long long)info.id_BytesPerBlock;
|
||||
|
||||
memset(type, 0, 255);
|
||||
|
||||
typeByte = info.id_DiskType >> 24;
|
||||
|
||||
if(typeByte < 0x20)
|
||||
{
|
||||
type[pos++] = '\\';
|
||||
|
||||
if(typeByte <= 7) type[pos++] = typeByte + 0x30;
|
||||
else
|
||||
{
|
||||
type[pos++] = (typeByte / 8) + 0x30;
|
||||
type[pos++] = (typeByte % 8) + 0x30;
|
||||
}
|
||||
}
|
||||
else
|
||||
type[pos++] = typeByte;
|
||||
|
||||
typeByte = (info.id_DiskType >> 16) & 0xFF;
|
||||
|
||||
if(typeByte < 0x20)
|
||||
{
|
||||
type[pos++] = '\\';
|
||||
|
||||
if(typeByte <= 7) type[pos++] = typeByte + 0x30;
|
||||
else
|
||||
{
|
||||
type[pos++] = (typeByte / 8) + 0x30;
|
||||
type[pos++] = (typeByte % 8) + 0x30;
|
||||
}
|
||||
}
|
||||
else
|
||||
type[pos++] = typeByte;
|
||||
|
||||
typeByte = (info.id_DiskType >> 8) & 0xFF;
|
||||
|
||||
if(typeByte < 0x20)
|
||||
{
|
||||
type[pos++] = '\\';
|
||||
|
||||
if(typeByte <= 7) type[pos++] = typeByte + 0x30;
|
||||
else
|
||||
{
|
||||
type[pos++] = (typeByte / 8) + 0x30;
|
||||
type[pos++] = (typeByte % 8) + 0x30;
|
||||
}
|
||||
}
|
||||
else
|
||||
type[pos++] = typeByte;
|
||||
|
||||
typeByte = info.id_DiskType & 0xFF;
|
||||
|
||||
if(typeByte < 0x20)
|
||||
{
|
||||
type[pos++] = '\\';
|
||||
|
||||
if(typeByte <= 7) type[pos++] = typeByte + 0x30;
|
||||
else
|
||||
{
|
||||
type[pos++] = (typeByte / 8) + 0x30;
|
||||
type[pos++] = (typeByte % 8) + 0x30;
|
||||
}
|
||||
}
|
||||
else
|
||||
type[pos++] = typeByte;
|
||||
|
||||
log_write("Volume information:\n");
|
||||
|
||||
log_write("\tPath: %s\n", path);
|
||||
log_write("\tDOS type: '%s'\n", type);
|
||||
log_write("\t%d bytes per block\n", info.id_BytesPerBlock);
|
||||
log_write("\t%ld blocks (%lld bytes)\n", info.id_NumBlocks, total);
|
||||
log_write("\t%ld blocks free (%lld bytes)\n", info.id_NumBlocks - info.id_NumBlocksUsed, free);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user