Is it good to run "fsck" command in C++ code program before mounting a file system?

878 views Asked by At

I am writing a C++ Library to attach/mount file systems present on Logical Volumes in Linux and AIX.

Can I run/execute fsck command in the C++ code before mounting a file system?

What problems will arise if I execute fsck command in C++ code on Linux and AIX?

1

There are 1 answers

0
Eric Fournie On

In this case, you would probably have to run fsck in non-interactive mode, assuming the user is answering "yes"to all questions by running fsck -y.

This can lead to all sorts of unwanted behaviour if something nasty happens.

If you need to mount a filesystem in your C++ code, I would consider letting the OS and/or the mount command decide when fsck needs to be run (based on the number of previous mounts since the last fsck) and let it run in interactive mode, offering the user a possibility to answer to the potential questions.