Unlink a file from FUSE virtual file system - fuse

I am new to FUSE. I created a virtual file system via FUSE. I can read a file with the command:
cat /deneme/club/basketball/students/student1
and it returns the value of file correctly:
"111111111"
However, I want to delete same file from file system. I use unlink system call:
unlink /deneme/club/basketball/students/student1
This code does not give any error but when I called the cat for the same file, it prints the same value:
"111111111"
What should i do to remove file from file system. Thanks
This is how i declared the unlink operation

You have to use the system call unlink and passing the file path as a parameter to the system call.
unlink(file_path);

Related

run c++ program in linux terminal with command

I have a cpp file called FileSystem.cpp, while I want to use the linux terminal and call the FileSystem executable file with command
FileSystem -i
" no matter where it located and call it without extension or './' at the front. I tried call it directly from terminal but it said:
FileSystem: command not found
When you type a command into the command line like FileSystem -i, without an explicit path on the command (no / characters in the first word), it looks for the exectuable in your $PATH. You can use the command echo $PATH to see what your current path is.
Normally, on linux, your path will include the directory $HOME/bin if it exists. That's the bin directory in your home directory, so you can put an executable you create (such as FileSystem) in that directory and then run it as FileSystem -i

Create a file in a filesystem

I've been requested to run a code on a file in a file system I had to create.
(I created the fs using mkfs and then mounted it with another directory: /home/may/new_place (the original fs appears on my desktop - 8.6GB filesystem)
My question is, can you even create a file in a filesystem? I can't even transfer a file into it, so can't execute my code.
I'm really new to this.. thank you all
(P.S. I'm using linux xubunto OS)
are you able to touch any files -- with touch command -- also open a sample file -- write echo $HOSTNAME - save it - chmod u+x and run it -- see if you are able to execute the file

what happens if i rename a parent directory while file is being written by program

I have a question.
I'm running a program on a LINUX machine. This program is writing output to the file 'output.txt' within the subfolder 'SUB' of the parent folder 'PARENT'
PARENT
|________SUB
|_________ output.txt
I accidentally renamed PARENT while output was writing...Namely, I did the following command
mv PARENT PARENT_NEW
So far my program hasn't crashed or anything. Does anyone know the repercussions of what I just did?
On Linux, as inherited from Unix, once a file on the local disk is open, the process has a handle to it. You may rename the parent directory, you may even delete the file. These operations don't trouble the process writing to the file as long as it does not close and reopen it.
The file is kept open by the program via a file descriptor, which is an unsigned integer that the kernel uses to access files. Your action should have no effect.
According to UNIX, the fill will be present in the new location. Here is a simple experiment:
$ mkdir /tmp/test
$ cat > /tmp/test/abc.txt
hello
world
and again!
So while cat is still waiting for input, open a new terminal and rename the folder:
$ mv /tmp/test/ /tmp/test2
Now back to earlier terminal: ( press Ctrl+D to complete the input to cat )
$ ls /tmp/test/
ls: cannot access /tmp/test1/abc.txt: No such file or directory
$ ls /tmp/test2/
abc.txt
$ cat /tmp/test2/abc.txt
hello
world
and again!
So basically, unless the file or directory is deleted completely, it will be present in the new location after the write is complete.
However, if process B deletes a file f while some other process A is still writing to that file, the file f will be available to process A because it holds an inode reference. But for rest of the processes including B it will not be accessible. Any other process can still access file f only if it can obtain a reference to inode via file descriptors from /proc/<PID-of-A>/fd.

How to change the temprary directory for configure script?

When I run the configure script to build GNU global on Linux system, I got the message "cannot create temp file for here document: No space left on device". Indeed, / disk was full.
So I tried to change temporary directory to another disk, and I set the environment variable TMPDIR, TMP, and TEMP to another disk directory, say /mnt/tmp.
I retried to run configure script, but I got the same message. What's wrong? Please give me any advice.
Thanks.
you could add the below statement at the beginning of your script.
export TMPDIR='DIRNAME'
where "DIRNAME" is any directory on which you have full permissions and has sufficient memory available in it
you can override the location of the temporary directory during configure like so:
./configure TMPDIR=path/to/your/tmp/folder
If your / directory is full, and the program is trying to write to your /tmp directory, try renaming the tmp directory to something like tmp_old, then create a symbolic link to your new tmp folder like: ln -s /mnt/tmp /tmp

Where is the zipcloak puts the temporary file by default?

When I use zipcloak to encrypt an existed zip file, I got an error like this:
zipcloak error: Permission denied
zipcloak error: Temporary file failure (ziC8mO6F)
The command I executed:
/usr/local/bin/zipcloak /Library/WebServer/foo.zip
I'm sure I've set the permission of /Library/WebServer to 777, but it seems like zipcloak create the temporary file in a different place.
By the way when I specify the temporary path by -b option of zipcloak, it's worked.
/usr/local/bin/zipcloak -b /Library/WebServer/ /Library/WebServer/foo.zip
The -b option:
-b Use the specified path for the temporary zip archive
It tries to open a temporary file in the current directory.

Resources