poking around proc file headers and sources for purposes of documentation and noticed something that seems odd. the standard way to create a proc file is: proc_create(char* name, umode_t mode, ... *parent, etc); again, that's for creating *files* -- directories under /proc are typically created with something like proc_mkdir(). so far, so good. what this means so far is that the "mode" parameter to proc_create() should represent simple file permissions -- there should be no bit setting indicating a directory. in proc_fs.h, we see the wrapper: static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops) { return proc_create_data(name, mode, parent, proc_fops, NULL); } so proc_create() turns around and calls proc_create_data(), again with a "mode" value that should represent the mode for only a file, not a directory. and yet, when we get to proc_create_data() in fs/proc/generic.c, we read: struct proc_dir_entry *proc_create_data(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops, void *data) { struct proc_dir_entry *pde; nlink_t nlink; if (S_ISDIR(mode)) { <----- ???????? if proc_create() and, subsequently, proc_create_data() are called for *only* files, when will that test ever succeed? it's not hurting anything, but it seems completely redundant. eventually, that routine calls the internal routine __proc_create(), and it's *that* routine that appears to be the central point for all proc file creation, files and directories both. but the directory test in proc_create_data() seems to be some sort of historical holdover. just for fun, i went looking for any call to proc_create_data() that somehow specified a directory, and this is what i got: $ grep -r "proc_create_data.*DIR" * $ in other words, nothing. admittedly, i haven't searched as thoroughly as i might have, but ... thoughts? is that S_ISDIR test as redundant as i think it is? rday -- ======================================================================== Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ======================================================================== _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies