Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit b6f4bee0 authored by M. Mohan Kumar's avatar M. Mohan Kumar Committed by Eric Van Hensbergen
Browse files

fs/9p: Fix atomic_open



Return EEXISTS if requested file already exists, without this patch open
call will always succeed even if the file exists and user specified
O_CREAT|O_EXCL.

Following test code can be used to verify this patch. Without this patch
executing following test code on 9p mount will result in printing 'test case
failed' always.

main()
{
        int fd;

        /* first create the file */
        fd = open("./file", O_CREAT|O_WRONLY);
        if (fd < 0) {
                perror("open");
                return -1;
        }
        close(fd);

        /* Now opening same file with O_CREAT|O_EXCL should fail */
        fd = open("./file", O_CREAT|O_EXCL);
        if (fd < 0 && errno == EEXIST)
	        printf("test case pass\n");
        else
	        printf("test case failed\n");
        close(fd);
        return 0;
}

Signed-off-by: default avatarM. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
parent 03f0e022
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment