Skip to content

ramfs: Fix duplicated files bug

Joshua Abraham requested to merge jabedude/ramfs:fix-duplicate-files into master

Previously ramfs allowed identical filenames to be created if the O_CREAT flag was used. This patch fixes the behavior and instead opens the existing file as long as O_EXCL is not specified.

Repro behavior:

root:~# echo "test" > logging:/testfile
root:~# echo "test" > logging:/testfile
root:~# echo "test" > logging:/testfile
root:~# ls -la logging:/
drwxr-xr-x 1 0 0 31 2021-04-01 00:22 .
drwxr-xr-x 1 0 0 31 2021-04-01 00:22 ..
drwxr-xr-x 2 0 0  3 2021-04-01 00:22 bus
drwxr-xr-x 2 0 0  4 2021-04-01 00:22 init
-rw-r--r-- 1 0 0  5 2021-04-01 00:22 testfile
-rw-r--r-- 1 0 0  5 2021-04-01 00:22 testfile
-rw-r--r-- 1 0 0  5 2021-04-01 00:22 testfile

Merge request reports