summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorRichard Sharpe <sharpe@samba.org>2001-01-12 12:48:55 +0000
committerRichard Sharpe <sharpe@samba.org>2001-01-12 12:48:55 +0000
commit338fd23290cb0770b59cb77ef4733bb8da6d3164 (patch)
tree5582d4cd7f8d9a055a6e9926c828824f5d8cf412 /source3
parentfb4013444677629af4b663a61da3b575bba49195 (diff)
downloadsamba-338fd23290cb0770b59cb77ef4733bb8da6d3164.tar.gz
samba-338fd23290cb0770b59cb77ef4733bb8da6d3164.tar.bz2
samba-338fd23290cb0770b59cb77ef4733bb8da6d3164.zip
Some more bug fixes plus implementations of smbc_mkdir and smbc_rmdir,
both tested ... More later. (This used to be commit 66bb40153a9ff38692356cadfad89cf91439032e)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/libsmbclient.h12
-rw-r--r--source3/libsmb/libsmbclient.c157
2 files changed, 169 insertions, 0 deletions
diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h
index 34e9405ff5..5889502ae2 100644
--- a/source3/include/libsmbclient.h
+++ b/source3/include/libsmbclient.h
@@ -173,6 +173,18 @@ struct smbc_dirent *smbc_readdir(unsigned int fd);
int smbc_mkdir(const char *fname, mode_t mode);
+/*
+ * Remove a directory on a server
+ */
+
+int smbc_rmdir(const char *fname);
+
+/*
+ * Get the current directory offset
+ */
+
+off_t smbc_telldir(int fd);
+
/*
* lseek on directories, rewind by smbc_lseekdir(fd, 0, SEEK_SET)
*/
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c
index 807dfb987c..de0653588c 100644
--- a/source3/libsmb/libsmbclient.c
+++ b/source3/libsmb/libsmbclient.c
@@ -1828,6 +1828,9 @@ int smbc_getdents(unsigned int fd, struct smbc_dirent *dirp, int count)
int smbc_mkdir(const char *fname, mode_t mode)
{
+ struct smbc_server *srv;
+ fstring server, share, user, password;
+ pstring path;
if (!smbc_initialized) {
@@ -1836,11 +1839,165 @@ int smbc_mkdir(const char *fname, mode_t mode)
}
+ if (!fname) {
+
+ errno = EINVAL;
+ return -1;
+
+ }
+
+ DEBUG(4, ("stat(%s)\n", fname));
+
+ smbc_parse_path(fname, server, share, path, user, password); /*FIXME, errors*/
+
+ if (user[0] == (char)0) pstrcpy(user, smbc_user);
+
+ srv = smbc_server(server, share, lp_workgroup(), user, password);
+
+ if (!srv) {
+
+ return -1; /* errno set by smbc_server */
+
+ }
+
+ /* if (strncmp(srv->cli.dev, "IPC", 3) == 0) {
+
+ mode = aDIR | aRONLY;
+
+ }
+ else if (strncmp(srv->cli.dev, "LPT", 3) == 0) {
+
+ if (strcmp(path, "\\") == 0) {
+
+ mode = aDIR | aRONLY;
+
+ }
+ else {
+
+ mode = aRONLY;
+ smbc_stat_printjob(srv, path, &size, &m_time);
+ c_time = a_time = m_time;
+
+ }
+ else { */
+
+ if (!cli_mkdir(&srv->cli, path)) {
+
+ errno = smbc_errno(&srv->cli);
+ return -1;
+
+ }
+
+ return 0;
+
+}
+
+/*
+ * Routine to remove a directory
+ */
+
+int smbc_rmdir(const char *fname)
+{
+ struct smbc_server *srv;
+ fstring server, share, user, password;
+ pstring path;
+
+ if (!smbc_initialized) {
+
+ errno = EUCLEAN;
+ return -1;
+
+ }
+
+ if (!fname) {
+
+ errno = EINVAL;
+ return -1;
+
+ }
+
+ DEBUG(4, ("stat(%s)\n", fname));
+
+ smbc_parse_path(fname, server, share, path, user, password); /*FIXME, errors*/
+
+ if (user[0] == (char)0) pstrcpy(user, smbc_user);
+
+ srv = smbc_server(server, share, lp_workgroup(), user, password);
+
+ if (!srv) {
+
+ return -1; /* errno set by smbc_server */
+
+ }
+
+ /* if (strncmp(srv->cli.dev, "IPC", 3) == 0) {
+
+ mode = aDIR | aRONLY;
+
+ }
+ else if (strncmp(srv->cli.dev, "LPT", 3) == 0) {
+
+ if (strcmp(path, "\\") == 0) {
+
+ mode = aDIR | aRONLY;
+
+ }
+ else {
+
+ mode = aRONLY;
+ smbc_stat_printjob(srv, path, &size, &m_time);
+ c_time = a_time = m_time;
+
+ }
+ else { */
+
+ if (!cli_rmdir(&srv->cli, path)) {
+
+ errno = smbc_errno(&srv->cli);
+ return -1;
+
+ }
+
return 0;
}
/*
+ * Routine to return the current directory position
+ */
+
+off_t smbc_telldir(int fd)
+{
+ struct smbc_file *fe;
+
+ if (!smbc_initialized) {
+
+ errno = EUCLEAN;
+ 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->file != False) { /* FIXME, should be dir, perhaps */
+
+ errno = ENOTDIR;
+ return -1;
+
+ }
+
+ return (off_t) fe->dir_next;
+
+}
+
+/*
* Routine to seek on a directory
*/