How to stop a program from accessing the file system

This is a discussion on How to stop a program from accessing the file system within the C++ Programming forums, part of the General Programming Boards category; I don't want my programs to access the file system at all
means no file creation, no deletion not even ...

I find it quite unlikely that you would be able to start an application without accessing the filesystem on either of Linux or Windows.

You can of course have a read-only filesystem [available in both] that would essentially prevent any CHANGES to the filesystem.

If you explain what your ultimate goal is (I suspect that you are trying to set up an internet cafe/student computer room or similar and want to prevent users from corrupting the machines), we may be able to suggest better solutions.

the scenario is that i have to some programs on my system.
the programs are quite simple, hardly 4-5 classes, i have to test it on my system but i dont want to mess up my system up because i dont know the code provided and c++ is really powerful .. other then these class files i wont the program to touch any other filse

the scenario is that i have to some programs on my system.
the programs are quite simple, hardly 4-5 classes, i have to test it on my system but i dont want to mess up my system up because i dont know the code provided and c++ is really powerful .. other then these class files i wont the program to touch any other filse

So, make your filesystem read only. You can do that trivially by setting up a different user that has no access to write to any directory on the machine.

But a quick code-review should expose any trivial attempts to do harmful things to your system. If the attempts are really complex, then you probably want to run this in a virtual machine that doesn't have access to the hardware at all, such as Xen or VMWare's solutions. Both are free.

the scenario is that i have to some programs on my system.
the programs are quite simple, hardly 4-5 classes, i have to test it on my system but i dont want to mess up my system up because i dont know the code provided and c++ is really powerful .. other then these class files i wont the program to touch any other filse

Then run the programs inside a VMWare image. If the image gets messed up, who cares -- just bring up a clean image and continue...