Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 May 2019 13:57:40 -0700
From:      Johannes Lundberg <johalun@FreeBSD.org>
To:        Alan Somers <asomers@freebsd.org>
Cc:        Konstantin Belousov <kostikbel@gmail.com>, FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: Weirdness when writing to pseudofs file
Message-ID:  <f1e31c0b-9383-05f9-f1b5-939a586d21d0@FreeBSD.org>
In-Reply-To: <eb0fd852-643d-e399-2988-92de744d6e07@FreeBSD.org>
References:  <6ec62e4d-9f93-ffe1-646c-3846c9308334@FreeBSD.org> <20190522175133.GC2748@kib.kiev.ua> <84e3001b-646d-b1d9-f206-577d63f79bf1@FreeBSD.org> <CAOtMX2i63czMAWmnJik5=gEY=5r4YFhz084zJ8xoThR01POGhQ@mail.gmail.com> <eb0fd852-643d-e399-2988-92de744d6e07@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On 5/22/19 1:53 PM, Johannes Lundberg wrote:
> On 5/22/19 11:03 AM, Alan Somers wrote:
>> On Wed, May 22, 2019 at 11:59 AM Johannes Lundberg <johalun@freebsd.org> wrote:
>>> On 5/22/19 10:51 AM, Konstantin Belousov wrote:
>>>> On Wed, May 22, 2019 at 10:36:34AM -0700, Johannes Lundberg wrote:
>>>>> Hi
>>>>>
>>>>> I'm fiddling with lindebugfs, which is based on pseudofs. When writing
>>>>> to a file,
>>>>>
>>>>> this works: # echo  1 >> /path/to/file
>>>>>
>>>>> but this does not: # echo 1 > /path/to/file
>>>>>
>>>>> "Operation not supported." is returned before the pseudofs code is even
>>>>> entered.
>>>>>
>>>>> Is this expected behavior? (if so, why?)
>>>> Does the file exist ?
>>>>
>>>> Pseudofs does not implement VOP_CREATE(), which is reasonable.
>>> Yes, it exists and my custom write function is receiving the call for
>>> ">>". (which is for example used by drm driver debugfs to do certain
>>> things on demand by accepting write to a debugfs file)
>> First, you need to try ktrace to see exactly which system call is not
>> supported.  If the problem still isn't obvious, then you can try
>> dtrace to see exactly which VOP isn't suppoted.  Do it like this:
>>
>> sudo ktrace /bin/sh -c "echo 1 > /path/to/file"
>> sudo kdump
>> sudo dtrace -i 'fbt:::return /arg1 == 45/ {trace(".")}' -c "/bin/sh -c
>> 'echo 1 > /path/to/file/'"
>>
>> The dtrace command will show you which function returned EOPNOTSUPP.
>> However, it will also show a lot of functions that coincidentally
>> return 45 even though it's not an errno, and even functions that
>> return void.
>>
>> -Alan
>
> Thanks!
>
> It seems, a single '>' will cause it to try to create the file (even
> though it already exists) and that fails (kern_openat).
>
I would guess because of

https://github.com/freebsd/freebsd/blob/master/sys/fs/pseudofs/pseudofs_vnops.c#L1042

struct vop_vector pfs_vnodeops = {
...
.vop_create = VOP_EOPNOTSUPP,
...
}




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f1e31c0b-9383-05f9-f1b5-939a586d21d0>