stat

    1熱度

    1回答

    我試圖創建一個方法,將執行一些系統調用。它應該顯示每個文件的所有者和八進制代碼。但不知何故,我不能走。它顯示的用戶名登錄,因爲每個文件的所有者 listContents(char * dir) { struct dirent *direntp; DIR *dirp; if ((dirp = opendir(dir)) == NULL) { p

    1熱度

    1回答

    我將提供以下腳本重現該問題「上次更改的時間」指令「STAT」: mkdir a touch a/f sleep 1 cp -a a b stat --printf="%u %g %a %z\n" a/f stat --printf="%u %g %a %z\n" b/f 結果爲兩個stat通話將在時間戳不同: 1000 100 644 2015-04-05 10:53:35.7363

    -1熱度

    2回答

    我一直在尋找一段代碼here我是要去使用: #include <sys/stat.h> struct stat sb; if (stat(pathname, &sb) == 0 && S_ISDIR(sb.st_mode)) { ...it is a directory... } 我想,如果我要使用它,我也許應該明白它能做什麼。我的問題是關於行 struct stat s

    0熱度

    1回答

    我想通過功能opendir()命令行的目錄名稱,但我不知道如何... 我已經實現了功能do_ls,我想通過命令給命令的名稱線作爲論點。 #include <stdio.h> #include <sys/types.h> #include <dirent.h> #include <sys/stat.h> #include <string.h> void do_ls(char *); v

    0熱度

    1回答

    我正在從標準輸入讀取文件名,並且該函數返回的是完全錯誤的內容。下面的代碼返回4294967296,而不是應該是7.我在linux上運行這樣的文件: echo「p3test.txt」| ./totalsize #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys

    1熱度

    2回答

    我想通過使用stat來檢查給定的參數是否是目錄。該程序需要2個參數:當第一個參數不是目錄或它不存在代碼工作正常。 但是,當第一個參數是一個目錄並存在,並且第二個參數不存在時,程序會說它們都存在 - 錯誤的結果。我想知道爲什麼它不起作用。 #include <stdio.h> #include <sys/stat.h> int main(int n, char **argv) {

    0熱度

    1回答

    我必須做一個項目,但我遇到了問題。 我從閱讀中收到一個字符串,但是當我看到緩衝區中有什麼數據時,它會在文件末尾顯示「\ n」。但是我不需要它來處理函數中的一個參數。 我的代碼: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #i

    0熱度

    1回答

    我在linux上使用了stat()函數來檢索有關文件的詳細信息。 其中一個細節是上次訪問時間存儲在變量「st_atime」 但是,什麼是格式說明符來顯示這個detail.My程序不斷拋出錯誤。 #include<stdio.h> #include<sys/stat.h> int main() { struct stat buf; stat("reversi.py",&b

    0熱度

    1回答

    1,創建文件: touch 1.txt 2.Loop for i in {0..1000}; do fuser 1.txt;done 3.Watch〜50次失敗: ... Cannot stat file /proc/16927/fd/0: No such file or directory Cannot stat file /proc/17821/fd/0: No such file

    2熱度

    1回答

    我在哪裏可以找到STAT系列調用系列期望的結構的精確定義? 請注意,我指的是原系統調用一個會在組裝調用(系統調用號4,5和6在x86_64),而不是那些通常由libc中提供的包裝。 手冊頁,stat(2),以及我能夠從linux和glibc源代碼中挖掘出的內容給出了令人困惑和矛盾的結果(不同的結構字段排序,Extra字段,填充)。 我敢肯定,我沒有找到我應該在哪裏,但我似乎無法找到我所追求的信息。