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

int smbc_lseekdir ( int  fd,
off_t  offset 
)

lseek on directories.

smbc_lseekdir() may be used in conjunction with smbc_readdir() and smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))

Parameters:
fd Valid directory as returned by smbc_opendir()
offset The offset (as returned by smbc_telldir). Can be NULL, in which case we will rewind
Returns:
0 on success, -1 on failure
  • EBADF dh is not a valid directory handle
  • ENOTDIR if dh is not a directory
  • EINVAL offset did not refer to a valid dirent or smbc_init not called.
See also:
smbc_telldir()
Todo:
In what does the reture and errno values mean?

Definition at line 2317 of file libsmbclient.c.

{
      struct smbc_file *fe;
      struct smbc_dirent *dirent = (struct smbc_dirent *)offset;
      struct smbc_dir_list *list_ent = NULL;

      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 != False) { /* FIXME, should be dir, perhaps */

            errno = ENOTDIR;
            return -1;

      }

      /* Now, check what we were passed and see if it is OK ... */

      if (dirent == NULL) {  /* Seek to the begining of the list */

            fe->dir_next = fe->dir_list;
            return 0;

      }

      /* Now, run down the list and make sure that the entry is OK       */
      /* This may need to be changed if we change the format of the list */

      if ((list_ent = smbc_check_dir_ent(fe->dir_list, dirent)) == NULL) {

            errno = EINVAL;   /* Bad entry */
            return -1;

      }

      fe->dir_next = list_ent;

      return 0; 

}


Generated by  Doxygen 1.6.0   Back to index