mirror of
https://github.com/samba-team/samba.git
synced 2025-01-13 13:18:06 +03:00
Some more bug fixes plus implementations of smbc_mkdir and smbc_rmdir,
both tested ...
More later.
(This used to be commit 66bb40153a
)
This commit is contained in:
parent
fb40134446
commit
338fd23290
@ -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)
|
||||
*/
|
||||
|
@ -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,10 +1839,164 @@ 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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user