2013-07-16 39 views
0

我已經在Linux編寫的一個小型的開放和關閉文件的程序,請在下面找到它:未知文件的權限 - Linux的

#include <stdio.h> 
#include <sys/types.h> 
#include <sys/stat.h> 
#include <fcntl.h> 

int main() 
{ 

int fd; 

fd = open("/home/jeshwanth/junk/text",O_WRONLY | O_CREAT); 

if (fd == -1) 
    printf("Error in opening \n"); 

close(fd); 
return 0; 
} 

該項目被執行後,我發現可執行位正顯示出一些未知permision -rwsrwSr-T。有人可以解釋我嗎?
在此先感謝

回答

2

什麼是他們未知的?從ls手冊頁:

The next three fields are three characters each: owner permissions, group 
permissions, and other permissions. Each field has three character positions: 

    1. If r, the file is readable; if -, it is not readable. 

    2. If w, the file is writable; if -, it is not writable. 

    3. The first of the following that applies: 

        S  If in the owner permissions, the file is not exe- 
         cutable and set-user-ID mode is set. If in the 
         group permissions, the file is not executable and 
         set-group-ID mode is set. 

        s  If in the owner permissions, the file is exe- 
         cutable and set-user-ID mode is set. If in the 
         group permissions, the file is executable and set- 
         group-ID mode is set. 

        x  The file is executable or the directory is search- 
         able. 

        -  The file is neither readable, writable, exe- 
         cutable, nor set-user-ID nor set-group-ID mode, 
         nor sticky. (See below.) 

      These next two apply only to the third character in the last 
      group (other permissions). 

        T  The sticky bit is set (mode 1000), but not execute 
         or search permission. (See chmod(1) or 
         sticky(8).) 

        t  The sticky bit is set (mode 1000), and is search- 
         able or executable. (See chmod(1) or sticky(8).) 
+0

謝謝:),忘了看到ls手冊頁;) –