LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-04-2020, 12:18 AM   #1
Bikku
LQ Newbie
 
Registered: May 2019
Posts: 4

Rep: Reputation: Disabled
fstat() on epoll fd returns a value in st_mode which indicates that it is a regular file. Is this file type correct for an epoll fd?


I am trying to understand file type of an epoll fd returned from epoll_create() system call. When I call fstat() on epoll fd, the value returned in statbuf.st_mode indicates that the epoll fd represents a regular file. Is this a correct behavior?

Thank you in advance.
 
Old 02-04-2020, 05:32 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
I don't have a a definite answer, but what makes you think it's not correct?

First of all, who/what defines what is correct behaviour? The epoll interface is not standardized as far as I know; all we have is the manual page, and it doesn't mention the type of the file descriptor returned by epoll_create.

Next, which of the following types would be better adapted in your opinion (from the inode(7) man page):
Code:
           S_IFSOCK   0140000   socket
           S_IFLNK    0120000   symbolic link
           S_IFREG    0100000   regular file
           S_IFBLK    0060000   block device
           S_IFDIR    0040000   directory
           S_IFCHR    0020000   character device
           S_IFIFO    0010000   FIFO
EDIT: https://idea.popcount.org/2017-02-20...lly-broken-12/ (apart from the title, I did not read the blog post)

Last edited by berndbausch; 02-04-2020 at 05:33 PM.
 
Old 02-04-2020, 11:59 PM   #3
Bikku
LQ Newbie
 
Registered: May 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
When fstat() returns file type as regular file then I interpreted it as disk file. So I thought, epoll fd type should not be a disk file.
ls -l /prod/pid/fd/ shows epoll fd as eventpoll. So, wondering if fstat() returning epoll fd type as a regular file is correct.

[usr1@VFM1012 ~]$ ls -l /proc/99922/fd/5
lrwx------ 1 usr1 group1 64 Feb 5 10:24 5 -> anon_inode:[eventpoll]
 
Old 02-05-2020, 12:13 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
I doubt that the filetype in square brackets [eventpoll] corresponds to the st_mode in the stat structure. In any case, stat.h has no eventpoll type.
 
Old 02-05-2020, 06:59 AM   #5
Bikku
LQ Newbie
 
Registered: May 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
It shows anon_inode:[eventpoll].
This anon_inode's type seems to be S_IFREG. If this is the case, then all pseudo files'fd (like epoll fd) file type appears to be regular file in Linux.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help understadning SFTP logs - invalid st_mode socalheel Linux - Server 6 05-01-2019 07:17 PM
[SOLVED] File Comparison with fstat() calvarado777 Linux - Newbie 8 09-30-2012 01:25 PM
Checking file type with fstat Skyrius Linux - General 1 05-12-2012 06:35 AM
difference between value *value and value * value PoleStar Linux - Newbie 1 11-26-2010 03:37 PM
using lstat st_mode flags and masks smoking81 Programming 1 10-03-2008 05:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration