V
V
Valeriy Solovyov2014-11-20 16:06:57
linux
Valeriy Solovyov, 2014-11-20 16:06:57

How to implement work with file systems?

Hello everyone
Question:
How to implement (program) work with file systems?
I started and ran into the problem that at least all the objects in which the file system is stored have a universal interaction interface. Internally, they must be implemented differently.
In linux, you can mount (mount) various file systems. Moreover, each file system has its own number of parameters and "folders" and even the sequence of command execution (+ their number).
Examples:

  1. Simple example:
    mount -t ntfs /dev/sda1 /mnt/win_xp
  2. Mounting /lxc/shared:
    mount --bind /lxc/shared /lxc/shared
    mount --make-unbindable /lxc/shared
    mount --make-shared /lxc/shared
  3. Accepts 2 directories, not just one:
    mount -t overlayfs -o rw,lowerdir=/low-layer,upperdir=/hilayer overlayfs /overlayfs
    find /overlayfs -lname '(overlay-whiteout)' -exec rm -rf {} \;

Essentially, every file system has two states:
  1. mounted
  2. not mounted

And on each you can perform a limited number of operations:
  • mount()
  • unmount()
  • Check mounted
  • Remove (after unmounting)

PS:
I write in Go. Here's what happened: play.golang.org/p/Ri5yAqsLu7
Of course, it's far from working with any file system =(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2014-11-20
@leahch

And there is also ceph + rbd, where the key and monitors can be specified well
And also xfs, where you can make a separate log
And all sorts of gpfs, lustre, gluster ..., where there is also a variety ...
And why is it actually?! For example, I have everything written in fstab, maybe old-school, but somehow familiar ...

U
uvelichitel, 2014-11-22
@uvelichitel

Working with files - golang.org/pkg/io/ioutil
Working with the system - golang.org/pkg/syscall/#Mount
Your snippet is command line work in my opinion

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question