* For the condition "file->f_mode", when it failed, it should return EACCES rather than EBADF.
@ 2013-02-04 2:07 majianpeng
2013-02-05 13:21 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: majianpeng @ 2013-02-04 2:07 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel, linux-fsdevel
Hi all,
When I wanted to do discard operations,but i set the openflag was O_RDONLY,it returned a EBADF rather than EACCES or EPERM.
I searched the code and found:
>case BLKDISCARD:
>case BLKSECDISCARD: {
> uint64_t range[2];
> if (!(mode & FMODE_WRITE))
> return -EBADF;
Initial i thought there was error.But i searched all code of kernel and found some places like this.
The description of EBADF is "Bad file numbe". There are some places where returned EBADF like,
>if (!f.file)
> return -EBADF;
So i think for checking file->f_mode when failed, it should return EACCESS.
Jianpeng Ma
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: For the condition "file->f_mode", when it failed, it should return EACCES rather than EBADF.
2013-02-04 2:07 For the condition "file->f_mode", when it failed, it should return EACCES rather than EBADF majianpeng
@ 2013-02-05 13:21 ` Jens Axboe
2013-02-05 15:39 ` majianpeng
0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2013-02-05 13:21 UTC (permalink / raw)
To: majianpeng; +Cc: linux-kernel, linux-fsdevel
On Sun, Feb 03 2013, majianpeng wrote:
> Hi all,
> When I wanted to do discard operations,but i set the openflag was O_RDONLY,it returned a EBADF rather than EACCES or EPERM.
> I searched the code and found:
> >case BLKDISCARD:
> >case BLKSECDISCARD: {
> > uint64_t range[2];
>
> > if (!(mode & FMODE_WRITE))
> > return -EBADF;
> Initial i thought there was error.But i searched all code of kernel and found some places like this.
>
> The description of EBADF is "Bad file numbe". There are some places where returned EBADF like,
> >if (!f.file)
> > return -EBADF;
>
> So i think for checking file->f_mode when failed, it should return EACCESS.
But that would break the ABI at this point. I agree with you, though,
EBADF is not the right error for this case.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re: For the condition "file->f_mode", when it failed, it should return EACCES rather than EBADF.
2013-02-05 13:21 ` Jens Axboe
@ 2013-02-05 15:39 ` majianpeng
2013-02-05 20:19 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: majianpeng @ 2013-02-05 15:39 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel, linux-fsdevel
>On Sun, Feb 03 2013, majianpeng wrote:
>> Hi all,
>> When I wanted to do discard operations,but i set the openflag was O_RDONLY,it returned a EBADF rather than EACCES or EPERM.
>> I searched the code and found:
>> >case BLKDISCARD:
>> >case BLKSECDISCARD: {
>> > uint64_t range[2];
>>
>> > if (!(mode & FMODE_WRITE))
>> > return -EBADF;
>> Initial i thought there was error.But i searched all code of kernel and found some places like this.
>>
>> The description of EBADF is "Bad file numbe". There are some places where returned EBADF like,
>> >if (!f.file)
>> > return -EBADF;
>>
>> So i think for checking file->f_mode when failed, it should return EACCESS.
>
>But that would break the ABI at this point. I agree with you, though,
>EBADF is not the right error for this case.
>
>--
>Jens Axboe
>
Sorry, can you explain in detail? Why can it break the ABI ?
Thanks!
Jianpeng Ma
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re: For the condition "file->f_mode", when it failed, it should return EACCES rather than EBADF.
2013-02-05 15:39 ` majianpeng
@ 2013-02-05 20:19 ` Jens Axboe
0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2013-02-05 20:19 UTC (permalink / raw)
To: majianpeng; +Cc: linux-kernel, linux-fsdevel
On Tue, Feb 05 2013, majianpeng wrote:
> >On Sun, Feb 03 2013, majianpeng wrote:
> >> Hi all,
> >> When I wanted to do discard operations,but i set the openflag was O_RDONLY,it returned a EBADF rather than EACCES or EPERM.
> >> I searched the code and found:
> >> >case BLKDISCARD:
> >> >case BLKSECDISCARD: {
> >> > uint64_t range[2];
> >>
> >> > if (!(mode & FMODE_WRITE))
> >> > return -EBADF;
> >> Initial i thought there was error.But i searched all code of kernel and found some places like this.
> >>
> >> The description of EBADF is "Bad file numbe". There are some places where returned EBADF like,
> >> >if (!f.file)
> >> > return -EBADF;
> >>
> >> So i think for checking file->f_mode when failed, it should return EACCESS.
> >
> >But that would break the ABI at this point. I agree with you, though,
> >EBADF is not the right error for this case.
> >
> >--
> >Jens Axboe
> >
> Sorry, can you explain in detail? Why can it break the ABI ?
Applications already depending on EBADF being returned for attempt to
discard on a file descriptor not opened for write. Granted it's a slim
possiblity, but it exists.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-05 20:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-04 2:07 For the condition "file->f_mode", when it failed, it should return EACCES rather than EBADF majianpeng
2013-02-05 13:21 ` Jens Axboe
2013-02-05 15:39 ` majianpeng
2013-02-05 20:19 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).