Synchronization speed

Advertisement

Dan Lewis
Joined:
Posts:
2
Location:
California

Synchronization speed

I'm building a program in C that needs to run the stat function on more than 16,000 files stored on a remote fileserver. Using C library functions opendir and readdir, my code takes far longer than the time required to do a synchronization scan with WinSCP.

Perhaps it's an unfair question, but how does WinSCP achieve such speed when comparing local versus remote file attributes?

Thanks,
Dan

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,253
Location:
Prague, Czechia

Re: Synchronization speed

You should get all information you need from the "readdir" already, you do not need to call "stat" for each file.

Reply with quote

Dan Lewis
Joined:
Posts:
2
Location:
California

Synchronization speed

Hi Martin,
You should get all information you need from the "readdir" already, you do not need to call "stat" for each file.
According to the Linux manual page at https://man7.org/linux/man-pages/man3/readdir.3.html, the glibc implementation of readdir doesn't necessarily return modification time:
In the glibc implementation, the dirent structure is defined as follows:
struct dirent {
    ino_t          d_ino;       /* Inode number */
    off_t          d_off;       /* Not an offset; see below */
    unsigned short d_reclen;    /* Length of this record */
    unsigned char  d_type;      /* Type of file; not supported by all filesystem types */
    char           d_name[256]; /* Null-terminated filename */
};
The only fields in the dirent structure that are mandated by POSIX.1 are d_name
and d_ino. The other fields are unstandardized, and not present on all systems.
What am I missing?
Dan

Reply with quote

martin
Site Admin
martin avatar

Re: Synchronization speed

This is WinSCP forum and in your original question you were writing about "remote fileserver". So I have assumed that you are asking about SFTP "readdir" request. If you are asking about local system's readdir function then I cannot help you.

Reply with quote

Advertisement

You can post new topics in this forum