Questions tagged [stat]

The stat(2) system call on POSIX systems. For statistics, use the statistics instead.

The stat(2) system call is used to retrieve information about a named file (or directory).

Links:

For statistics, use the tag instead.

829 questions
4
votes
2 answers

Python's os stat is returning wrong inode value

I'm running CentOS Linux. I create a directory as follows using a proprietary filesystem: $ mkdir fooDir First, I check the inode value using "ls -ldi": $ ls -ldi total 4 9223372036854783200 drwxrwxrwx 2 root root 4096 Jan 6 20:58 fooDir Then,…
jersey bean
  • 3,321
  • 4
  • 28
  • 43
4
votes
1 answer

race-free directory walk (C++)

I need to walk a directory tree and get stat values for every file. I want to do this safely while the filesystem is being modified. In Python, the best option is os.fwalk, which gives access to the fd for the directory being traversed; I can then…
Gabriel
  • 1,262
  • 12
  • 12
4
votes
3 answers

stat() function doesnt seem to be working in test PAM module

I'm trying to write a PAM module. The PAM module creates a directory on first log in. Very similar to the pam_mkhomedir. Here is the code. PAM_EXTERN int pam_sm_open_session (pam_handle_t *pamh, int flags, int argc, const char…
John Doh
  • 73
  • 4
4
votes
3 answers

How can I get the last modified time of a directory in Perl on Windows?

In Perl (on Windows) how do I determine the last modified time of a directory? Note: opendir my($dirHandle), "$path"; my $modtime = (stat($dirHandle))[9]; results in the following error: The dirfd function is unimplemented at scriptName.pl line…
bob
  • 81
  • 1
  • 5
4
votes
1 answer

Golang exec: stat: no such file or directory after file has been moved there

I have a script that I am using for deployment using the "os/exec" package. One of the commands that I use is as follows: cpInit = exec.Command("cp", "initScripts/nginx", "/etc/init.d/nginx") and another: startNginx =…
Charlie Andrews
  • 1,457
  • 19
  • 28
4
votes
1 answer

How do I get the generation number of an inode in Linux?

Summary: I want to get the generation number (i_generation) of a file in Linux (or at least ext4) from userspace. Or, alternatively, the 'birth time' (file creation time). I am trying to write a bidirectional file synchronisation program (aka…
ayke
  • 1,582
  • 12
  • 14
4
votes
3 answers

postgres could not stat file Permission denied

This is a problem using stats(), or just when calculating the database size. Using postgresql in windows 7, localhost. The problem after doing this is: "could not stat file "base/17436/119145": Permission denied" I spent a lot of time trying to fix…
Ignacio Bustos
  • 1,415
  • 2
  • 17
  • 26
4
votes
1 answer

using st_mode to identify file or directory

is there any way to identify whether an object is file or directory using st_mode value? I'm using paramiko lstat() to retrieve the st_mode information from sftp files.
MikA
  • 5,184
  • 5
  • 33
  • 42
4
votes
1 answer

Static members in VB.NET

I used to write this: Private Sub Example() Static CachedPeople As List(Of MyApp.Person) If CachedPeople Is Nothing Then CachedPeople = New List(Of MyApp.Person) End If ...rest of code... End Sub But then wondered if I could reduce this…
Rob Nicholson
  • 1,943
  • 5
  • 22
  • 37
3
votes
1 answer

Linux, C: access() not catching permission problems, or something

I am writing a program to mimic some of the behavior of find that walks a directory tree and calls lstat on the files it finds there to determine their type. The real find will ignore files where the user does not have R or X access in that…
Sabrina S
  • 337
  • 8
  • 21
3
votes
1 answer

cstime error in /proc/pid/stat file

stime or cstime in /proc/pid/stat file is so huge that doesn't make any sense. But just some processes have this wrong cstime on occasion. Just as following: # ps -eo pid,ppid,stime,etime,time,%cpu,%mem,command |grep nsc 4815 1 Jan08 1-01:20:02…
ShemLiang
  • 33
  • 4
3
votes
2 answers

STAT Block size/blocks used

I have a question which is confusing me and my task is to work out fragmentation. stat() for a file: st_size = 10520 st_blksize = 4096 st_blocks = 24 I have read in some places that st_blksize is the general block size of the file system which in…
Charlie
  • 1,308
  • 5
  • 14
  • 24
3
votes
3 answers

Intercepting stat()

I have successfuly intercepted calls to read(),write(),open(),unlink(),rename(), creat() but somehow with exactly the same semantics intercepting stat() is not taking place. I have changed the execution environmnet using LD_PRELOAD. Am I missing…
Lipika Deka
  • 3,774
  • 6
  • 43
  • 56
3
votes
5 answers

How to generate a NUL-delimited stream of timestamped filenames with BSD `stat` command

Let's suppose that you need to generate a NUL-delimited stream of timestamped filenames. On Linux & Solaris I can do it with: stat --printf '%.9Y %n\0' -- * On BSD, I can get the same info, but delimited by newlines, with: stat -f '%.9Fm %N' --…
Fravadona
  • 13,917
  • 1
  • 23
  • 35
3
votes
3 answers

How to find cause of ClientRead wait_event in Postgresql pg_stat_activity?

I've got an endpoint which receives a lot of data. It inserts it into a table called ingress. I've also written a couple parsers which loop over the messages in the ingress table and parse it into various other tables. I've been having a lot of…
kramer65
  • 50,427
  • 120
  • 308
  • 488