0

How can I open a file in an ext2 file system. For example, lets say I want to open the file: /a/b/c.txt

I'm looking at the functions here: http://www.nongnu.org/ext2-doc/ext2.html

User
  • 23,729
  • 38
  • 124
  • 207

1 Answers1

3

The same as any other filesystem: use fopen("/path/to/the/file", "r") or similar.

The documentation you found is only relevant to people implementing the filesystem.

user253751
  • 57,427
  • 7
  • 48
  • 90
  • I guess I mean't implement the filesystem. – User Dec 14 '15 at 03:37
  • @User: What do you mean by "I meant 'implement the file system'"? Are you planning to reimplement part of the ext2 file system that is already implemented and tested? Or are you interested in what the `open()` support function does on an ext2 file system? Or what? If you're interested in what the file opening code does, should you not look at the code? – Jonathan Leffler Dec 14 '15 at 03:41
  • @User well if you're implementing it... be prepare to be shocked that filesystems have no concept of "opening" a file! That's entirely an OS thing. (Obviously most filesystem implementations do have such a concept, but only so they can interact with the rest of the OS) – user253751 Dec 14 '15 at 04:16
  • @JonathanLeffler I want to open a file using ext2 functions. – User Dec 14 '15 at 12:22
  • @User: you mean you want to write code that will run in the kernel to open a file on an ext2 file system? If you're writing user-space code (a normal program), you can only call the regular `open()` system call — or one of its relatives, such as `creat()` or `openat()` — and then get on with life. Inside some sort of kernel module, you'll have to follow the rules and regulations for kernel modules accessing files — I'm not even sure what the R&R are, but they're bound to exist. What will you do after it is open? Close it? – Jonathan Leffler Dec 14 '15 at 15:09