Skip to content
forked from harisankarh/Mutef

Mutef: Mutually exclusive file access for applications

Notifications You must be signed in to change notification settings

santoshkvs/Mutef

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Mutef: Mutually exclusive file access for applications
------------------------------------------------------

Some of the applications which read and perform modifications on a file do not support warnings when the file is parallely modified from multiple terminals.
I faced this problem when using hnb and decided to write a wrapper script over hnb which provides mutually exclusive file access. 

The file mutef.c compiles to a binary which can be used instead of hnb to open the files.

Steps:

1. mv /usr/bin/hnb /usr/bin/orighnb
2. cc mutexopenc -o hnb
3. mv ./hnb /usr/bin/hnb

The first step renames the original hnb binary in the /usr/bin directory. The compiled binary from the mutef.c becomes the new /usr/bin/hnb in step 3.
Any file can now be opened using the usual "hnb <filename>" command, but now with mutually exclusive file access.

The program works as follows:

First it checks whether a lock file(filename + "_lock") exists for the file which is to be opened. If so, it exits after issuing an "already open" warning.
Otherwise, it opens the file after creating a lock file. The lock file is then deleted after the application is closed.

The program can be modified for arbitrary applications with minor modifications.

About

Mutef: Mutually exclusive file access for applications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published