On 04/15/2016 04:48 AM, Dmitry Mishin wrote:
I am reviewing recent VZ7 libploop commits, in particular, this one:


    https://src.openvz.org/projects/OVZ/repos/ploop/commits/36df847b9

    I left a question there, let me repeat it here in a hope someone
    answers.

    Igor Sukhihcommitted36df847b99c
    
<https://src.openvz.org/projects/OVZ/repos/ploop/commits/36df847b99c92557c69255ebfb00d4cc74cb51ac>Yesterday
    ploop_copy_init(): open folder with O_DIRECTORY flag

    ...
    -        _h->mntfd = open(mnt, O_RDONLY);
    +        _h->mntfd = open(mnt, O_RDONLY|O_NONBLOCK|O_DIRECTORY);

    1. What's the reason for adding O_NONBLOCK here? As far as I can
    see, it doesn't
    change anything at all (neither in this open(), nor in subsequent
    syncfs(), ioctl()
    and close())? I went as far as the kernel sources to check that
    O_NONBLOCK
    doesn't affect syncfs() call, but maybe I'm mistaken?


Added accidentally, you are right, it doesn't change anything.



    2. What's the reason for adding O_DIRECTORY? Ideally, the changelog
    should say why we're doing it, not what we do (as it's pretty clear
    from the patch itself).

It does exactly as specified – enforces open file to be a directory.

See, I am not asking what it does -- it's pretty clear from open(2) man page.

What I am interested in is the reason _why_ it was added. A bug report
this change is trying to fix, or a train of thought leading to this change, etc.
Ideally this is what the changelog message should tell us.

Any problems with this enforcement?

No, I don't foresee any problems, more to say, this extra check might
actually do some good.

Kir.

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to