Posted: Tue 14 May 2013, 13:54
technosaurus, no matter how you succeed with your database, it is always a pleasure to read your code!
tallboy
tallboy
READ-ONLY Archive
https://oldforum.puppylinux.com/
That's just the beginning..think about complexity of memory allocation.amigo wrote:When you first started the thread I thought you had in mind to use no files at all -that entries would only consist of directories and/or links.
Using flat files to hold data becomes a space problem since every file has a minimum size even if it only contains one character. The block size of the filesystem determines the minimum size requirement -usually at least 4k.
Wouldn't that involve a separate inode for every process of every user of every file?technosaurus wrote:That was the original plan, but then I read about a couple of filesystems that can store small files in the inode table, which most well planned databases should be.
Sorry for the delayed reply, this kind of dropped off my radar, but to answer the question, each file gets an inode in the filesystem, but processes typically would only be opening 1 file descriptor (or so) at a time.jpeps wrote:Wouldn't that involve a separate inode for every process of every user of every file?
Code: Select all
int get_value(const char *path, void *buf,size_t len){
int fd = open(path, O_RDONLY);
if (fd<0) return fd;
len=read(fd,buf,len);
close(fd);
return len;
}
int set_value(const char *path, void *buf,size_t len){
int fd = open(path, O_CREAT|O_WRONLY|O_TRUNC);
if (fd<0) return fd;
len=write(fd,buf,len);
close(fd);
return len;
}