Logo Search packages:      
Sourcecode: samba-doc-ja version File versions

int smbc_fstat ( int  fd,
struct stat *  st 
)

Get file information via an file descriptor.

Parameters:
fd Open file handle from smbc_open() or smbc_creat()
st pointer to a buffer that will be filled with standard Unix struct stat information.
Returns:
EBADF filedes is bad.
  • EACCES Permission denied.
  • EBADF fd is not a valid file descriptor
  • EINVAL Problems occurred in the underlying routines or smbc_init not called.
  • ENOMEM Out of memory
See also:
smbc_stat(), Unix stat()

Definition at line 1316 of file libsmbclient.c.

{
      struct smbc_file *fe;
      time_t c_time, a_time, m_time;
      SMB_BIG_UINT size;
      uint16 mode;
      SMB_INO_T ino = 0;

      if (!smbc_initialized) {

            errno = EINVAL;
            return -1;

      }

      if (fd < smbc_start_fd || fd >= (smbc_start_fd + SMBC_MAX_FD)) {

            errno = EBADF;
            return -1;
    
      }

      fe = smbc_file_table[fd - smbc_start_fd];
      
      if (!fe) {

            errno = EBADF;
            return -1;

      }

      if (!fe->file) {

            return smbc_fstatdir(fd, st);

      }

      if (!cli_qfileinfo(&fe->srv->cli, fe->cli_fd,
                     &mode, &size, &c_time, &a_time, &m_time, NULL, &ino) &&
          !cli_getattrE(&fe->srv->cli, fe->cli_fd,
                    &mode, &size, &c_time, &a_time, &m_time)) {

            errno = EINVAL;
            return -1;

      }

      st->st_ino = ino;

      smbc_setup_stat(st, fe->fname, size, mode);

      st->st_atime = a_time;
      st->st_ctime = c_time;
      st->st_mtime = m_time;
      st->st_dev = fe->srv->dev;

      return 0;

}


Generated by  Doxygen 1.6.0   Back to index