views:

23

answers:

2

I have been told that I need to add a new file type to linux. File types are declared in fs.h Relevant part posted here:

* File types
* NOTE! These match bits 12..15 of stat.st_mode
* (ie "(i_mode >> 12) & 15").
*/
#define DT_UNKNOWN      0
#define DT_FIFO         1
#define DT_CHR          2
#define DT_DIR          4
#define DT_BLK          6
#define DT_REG          8
#define DT_LNK          10
#define DT_SOCK         12
#define DT_WHT          14

The problem is, they want me to define a new file type with the value of... 16. How is this even possible when we only get 4 bits to represent the file type?

+1  A: 

It isn't. Pick a different number. Or rewrite the whole VFS. But I'd pick a different number.

Ignacio Vazquez-Abrams
A: 

I assume this is homework, in which case you can probably just use a different number.

Still, you might want to think hard about whether you really need to add a new file type. AFAICT no one has added a new file type for at least five years, and there is obviously not a lot of room left for expansion.

mpe