Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it better to use fchmod over chmod?

Tags:

c

linux

Is using fchmod(int fildes, mode_t mode) a better idea than using chmod(const char * path, mode_t mode)?

like image 407
PJT Avatar asked Dec 12 '09 05:12

PJT


1 Answers

It's pretty much identical. chmod will take ever so slightly little longer as it has to convert the path to an inode or filenode, whereas fchmod has the inode/filenode already looked up.

Of course, there are fewer error conditions which could occur with fchmod since the file is already known to exist, have permission for open, etc.

like image 148
wallyk Avatar answered Sep 20 '22 18:09

wallyk