File Functions
[Libsmbclient]

Functions used to access individual file contents [詳細]

関数

int smbc_open (const char *furl, int flags, mode_t mode)
 Open a file on an SMB server.
int smbc_creat (const char *furl, mode_t mode)
 Create a file on an SMB server.
ssize_t smbc_read (int fd, void *buf, size_t bufsize)
 Read from a file using an opened file handle.
ssize_t smbc_write (int fd, void *buf, size_t bufsize)
 Write to a file using an opened file handle.
off_t smbc_lseek (int fd, off_t offset, int whence)
 Seek to a specific location in a file.
int smbc_close (int fd)
 Close an open file handle.

説明

Functions used to access individual file contents


関数

int smbc_open ( const char *  furl,
int  flags,
mode_t  mode 
)

Open a file on an SMB server.

引数:
furl The smb url of the file to be opened.
flags Is one of O_RDONLY, O_WRONLY or O_RDWR which request opening the file read-only,write-only or read/write. flags may also be bitwise-or'd with one or more of the following: O_CREAT - If the file does not exist it will be created. O_EXCL - When used with O_CREAT, if the file already exists it is an error and the open will fail. O_TRUNC - If the file already exists it will be truncated. O_APPEND The file is opened in append mode
mode mode specifies the permissions to use if a new file is created. It is modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask)
Not currently use, but there for future use. We will map this to SYSTEM, HIDDEN, etc bits that reverses the mapping that smbc_fstat does.

戻り値:
Valid file handle, < 0 on error with errno set:
  • ENOMEM Out of memory
  • EINVAL if an invalid parameter passed, like no file, or smbc_init not called.
  • EEXIST pathname already exists and O_CREAT and O_EXCL were used.
  • EISDIR pathname refers to a directory and the access requested involved writing.
  • EACCES The requested access to the file is not allowed
  • ENODEV The requested share does not exist
  • ENOTDIR A file on the path is not a directory
  • ENOENT A directory component in pathname does not exist.
参照:
smbc_creat()
覚え書き:
This call uses an underlying routine that may create a new connection to the server specified in the URL. If the credentials supplied in the URL, or via the auth_fn in the smbc_init call, fail, this call will try again with an empty username and password. This often gets mapped to the guest account on some machines.

libsmb_compat.c155 行で定義されています。

参照先 add_fd()_SMBCCTX::close_fnfdsmbc_compat_fdlist::file_SMBCCTX::openstatcont.

参照元 do_get()do_put()smb_download_file().

00156 {
00157         SMBCFILE * file;
00158         int fd;
00159 
00160         file = (statcont->open)(statcont, furl, flags, mode);
00161         if (!file)
00162                 return -1;
00163 
00164         fd = add_fd(file);
00165         if (fd == -1) 
00166                 (statcont->close_fn)(statcont, file);
00167         return fd;
00168 }

int smbc_creat ( const char *  furl,
mode_t  mode 
)

Create a file on an SMB server.

Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC

引数:
furl The smb url of the file to be created
mode mode specifies the permissions to use if a new file is created. It is modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask)
NOTE, the above is not true. We are dealing with an SMB server, which has no concept of a umask!

戻り値:
Valid file handle, < 0 on error with errno set:
  • ENOMEM Out of memory
  • EINVAL if an invalid parameter passed, like no file, or smbc_init not called.
  • EEXIST pathname already exists and O_CREAT and O_EXCL were used.
  • EISDIR pathname refers to a directory and the access requested involved writing.
  • EACCES The requested access to the file is not allowed
  • ENOENT A directory component in pathname does not exist.
  • ENODEV The requested share does not exist.
参照:
smbc_open()

libsmb_compat.c171 行で定義されています。

参照先 add_fd()_SMBCCTX::close_fn_SMBCCTX::creatfdsmbc_compat_fdlist::filestatcont_SMBCCTX::unlink.

参照元 do_put().

00172 {
00173         SMBCFILE * file;
00174         int fd;
00175 
00176         file = (statcont->creat)(statcont, furl, mode);
00177         if (!file)
00178                 return -1;
00179 
00180         fd = add_fd(file);
00181         if (fd == -1) {
00182                 /* Hmm... should we delete the file too ? I guess we could try */
00183                 (statcont->close_fn)(statcont, file);
00184                 (statcont->unlink)(statcont, furl);
00185         }
00186         return fd;
00187 }

ssize_t smbc_read ( int  fd,
void *  buf,
size_t  bufsize 
)

Read from a file using an opened file handle.

引数:
fd Open file handle from smbc_open() or smbc_creat()
buf Pointer to buffer to recieve read data
bufsize Size of buf in bytes
戻り値:
Number of bytes read, < 0 on error with errno set:
  • EISDIR fd refers to a directory
  • EBADF fd is not a valid file descriptor or is not open for reading.
  • EINVAL fd is attached to an object which is unsuitable for reading, or no buffer passed or smbc_init not called.
参照:
smbc_open(), smbc_write()

libsmb_compat.c190 行で定義されています。

参照先 smbc_compat_fdlist::filefind_fd()_SMBCCTX::readstatcont.

参照元 do_get()smb_download_file().

00191 {
00192         SMBCFILE * file = find_fd(fd);
00193         return (statcont->read)(statcont, file, buf, bufsize);
00194 }

ssize_t smbc_write ( int  fd,
void *  buf,
size_t  bufsize 
)

Write to a file using an opened file handle.

引数:
fd Open file handle from smbc_open() or smbc_creat()
buf Pointer to buffer to recieve read data
bufsize Size of buf in bytes
戻り値:
Number of bytes written, < 0 on error with errno set:
  • EISDIR fd refers to a directory.
  • EBADF fd is not a valid file descriptor or is not open for reading.
  • EINVAL fd is attached to an object which is unsuitable for reading, or no buffer passed or smbc_init not called.
参照:
smbc_open(), smbc_read()

libsmb_compat.c196 行で定義されています。

参照先 smbc_compat_fdlist::filefind_fd()statcont_SMBCCTX::write.

参照元 do_put().

00197 {
00198         SMBCFILE * file = find_fd(fd);
00199         return (statcont->write)(statcont, file, buf, bufsize);
00200 }

off_t smbc_lseek ( int  fd,
off_t  offset,
int  whence 
)

Seek to a specific location in a file.

引数:
fd Open file handle from smbc_open() or smbc_creat()
offset Offset in bytes from whence
whence A location in the file:
  • SEEK_SET The offset is set to offset bytes from the beginning of the file
  • SEEK_CUR The offset is set to current location plus offset bytes.
  • SEEK_END The offset is set to the size of the file plus offset bytes.
戻り値:
Upon successful completion, lseek returns the resulting offset location as measured in bytes from the beginning of the file. Otherwise, a value of (off_t)-1 is returned and errno is set to indicate the error:
  • EBADF Fildes is not an open file descriptor.
  • EINVAL Whence is not a proper value or smbc_init not called.
TODO:
Are all the whence values really supported?
TODO:
Are errno values complete and correct?

libsmb_compat.c202 行で定義されています。

参照先 smbc_compat_fdlist::filefind_fd()_SMBCCTX::lseekstatcont.

参照元 do_get()do_put()smb_download_file().

00203 {
00204         SMBCFILE * file = find_fd(fd);
00205         return (statcont->lseek)(statcont, file, offset, whence);
00206 }

int smbc_close ( int  fd  ) 

Close an open file handle.

引数:
fd The file handle to close
戻り値:
0 on success, < 0 on error with errno set:
  • EBADF fd isn't a valid open file descriptor
  • EINVAL smbc_init() failed or has not been called
参照:
smbc_open(), smbc_creat()

libsmb_compat.c208 行で定義されています。

参照先 _SMBCCTX::close_fndel_fd()smbc_compat_fdlist::filefind_fd()statcont.

参照元 do_get()do_put()smb_download_file().

00209 {
00210         SMBCFILE * file = find_fd(fd);
00211         del_fd(fd);
00212         return (statcont->close_fn)(statcont, file);
00213 }


Sambaに対してSat Aug 29 21:24:39 2009に生成されました。  doxygen 1.4.7