I need to write a code in C which will be forming a B TREE using the address of certain files from a pen-drive for example...
Now, problem lies in opening the file and assigning it to a file pointer manually when number of files become very large ( say, 1000) ..
In that case, is it possible to access one file manually and others automatically using some mechanism (say, from FAT/NTFS whatever be the file system of the prn drive) and assign all the files to an array of file pointers?
Accessing FAT using C
Started by $AP, Jul 06 2009 09:28 AM
4 replies to this topic
#1
Posted 06 July 2009 - 09:28 AM
|
|
|
#2
Posted 06 July 2009 - 11:20 AM
I would expect that having around 1000 files open at once would cause issues. Why do you need them open simultaneously?
#3
Posted 06 July 2009 - 12:10 PM
Actually, i want to store the addresses of the files in a B TREE format.... addresses of 1000 files for example.... can u suggest anything??
#4
Posted 06 July 2009 - 12:26 PM
I'm pretty rusty on my C. However, something about this feels very odd. If the files are not open, they could change during the lifetime of your program. What is the purpose of storing them in a B Tree?
#5
Posted 06 July 2009 - 04:56 PM
This makes no sense to me either, and I've written filesystem drivers for FAT12/16/32...
If you have block access to the device, you can read/write to it just like a file, either using /dev/sd* or the internal device name on windows. I'll save you some time,
If you have block access to the device, you can read/write to it just like a file, either using /dev/sd* or the internal device name on windows. I'll save you some time,
typedef struct fat_extBS_32
{
//extended fat32 stuff
unsigned int table_size_32;
unsigned short extended_flags;
unsigned short fat_version;
unsigned int root_cluster;
unsigned short fat_info;
unsigned short backup_BS_sector;
unsigned char reserved_0[12];
unsigned char drive_number;
unsigned char reserved_1;
unsigned char boot_signature;
unsigned int volume_id;
unsigned char volume_label[11];
unsigned char fat_type_label[8];
}__attribute__((packed)) fat_extBS_32_t;
typedef struct fat_extBS_16
{
//extended fat12 and fat16 stuff
unsigned char bios_drive_num;
unsigned char reserved1;
unsigned char boot_signature;
unsigned int volume_id;
unsigned char volume_label[11];
unsigned char fat_type_label[8];
}__attribute__((packed)) fat_extBS_16_t;
typedef struct fat_BS
{
unsigned char bootjmp[3];
unsigned char oem_name[8];
unsigned short bytes_per_sector;
unsigned char sectors_per_cluster;
unsigned short reserved_sector_count;
unsigned char table_count;
unsigned short root_entry_count;
unsigned short total_sectors_16;
unsigned char media_type;
unsigned short table_size_16;
unsigned short sectors_per_track;
unsigned short head_side_count;
unsigned int hidden_sector_count;
unsigned int total_sectors_32;
}__attribute__((packed)) fat_BS_t;
typedef union fat_dir
{
struct
{
unsigned char dos_name[8];
unsigned char dos_ext[3];
unsigned char attributes;
unsigned char reserved;
unsigned char fine_create_time;
unsigned short create_time;
unsigned short create_date;
unsigned short last_access;
union
{
unsigned short ea_index;
unsigned short high32;
};
unsigned short last_modified_time;
unsigned short last_modified_date;
union
{
unsigned short first_cluster;
unsigned short low32;
};
unsigned int file_size;
}__attribute__((packed)) std;
struct
{
unsigned char seq_number;
unsigned char name1[10];
unsigned char attributes;
unsigned char reserved;
unsigned char checksum;
unsigned char name2[12];
unsigned short first_cluster;
unsigned char name3[4];
}__attribute__((packed)) lfn;
}__attribute__((packed)) fat_dir_t;


Sign In
Create Account


Back to top









