summaryrefslogtreecommitdiffstats
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
commit66bb40153a9ff38692356cadfad89cf91439032e (patch)
tree61735c604b110ad3c89c60670baf69b7335b8419
parent7f559c1a7307b91218d5984f48f65e7dc0ab66b9 (diff)
downloadsamba-66bb40153a9ff38692356cadfad89cf91439032e.tar.gz
samba-66bb40153a9ff38692356cadfad89cf91439032e.tar.xz
samba-66bb40153a9ff38692356cadfad89cf91439032e.zip
Some more bug fixes plus implementations of smbc_mkdir and smbc_rmdir,
both tested ... More later.
-rw-r--r--source/include/libsmbclient.h12
-rw-r--r--source/libsmb/libsmbclient.c157
2 files changed, 169 insertions, 0 deletions
diff --git a/source/include/libsmbclient.h b/source/include/libsmbclient.h
index 34e9405ff5d..5889502ae25 100644
--- a/source/include/libsmbclient.h
+++ b/source/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/source/libsmb/libsmbclient.c b/source/libsmb/libsmbclient.c
index 807dfb987c3..de0653588cd 100644
--- a/source/libsmb/libsmbclient.c
+++ b/source/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
*/