Re: For the condition "file->f_mode", when it failed, it should return EACCES rather than EBADF.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux