Recreate the SMB context after rmdir. - susmb - mounting of SMB/CIFS shares via FUSE
(HTM) git clone git://git.codemadness.org/susmb
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 28181b82defdd54e029e6c8fbb574df2b4179403
(DIR) parent 961d7b55bb0eaca2712282c4b374c61c481df2c0
(HTM) Author: Geoff Johnstone <geoffSHEEP.johnstoneFROG@googlemail.com>
Date: Thu, 26 Feb 2009 22:11:05 +0000
Recreate the SMB context after rmdir.
Diffstat:
M Makefile | 2 +-
M conffile.c | 2 +-
M conffile.h | 2 +-
M options.c | 2 +-
M options.h | 2 +-
M password.c | 2 +-
M password.h | 2 +-
M samba30-compat.h | 2 +-
M usmb.c | 22 +++++++++++++++++++++-
M usmb.h | 4 +++-
M usmb_dir.c | 8 +++++++-
M usmb_dir.h | 2 +-
M usmb_file.c | 5 +++--
M usmb_file.h | 2 +-
M utils.c | 2 +-
M utils.h | 2 +-
M version.c | 4 ++--
M version.h | 4 ++--
M xml.c | 2 +-
M xml.h | 2 +-
20 files changed, 52 insertions(+), 23 deletions(-)
---
(DIR) diff --git a/Makefile b/Makefile
@@ -1,5 +1,5 @@
# usmb - mount SMB shares via FUSE and Samba
-# Copyright (C) 2006-2008 Geoff Johnstone
+# Copyright (C) 2006-2009 Geoff Johnstone
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/conffile.c b/conffile.c
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/conffile.h b/conffile.h
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/options.c b/options.c
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/options.h b/options.h
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/password.c b/password.c
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/password.h b/password.h
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/samba30-compat.h b/samba30-compat.h
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* Portions of this file are taken from Samba 3.2's libsmbclient.h:
* Copyright (C) Andrew Tridgell 1998
(DIR) diff --git a/usmb.c b/usmb.c
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
@@ -279,6 +279,26 @@ static bool get_context (void)
}
+bool renew_smb_context (void)
+{
+ SMBCCTX *newctx;
+
+ DEBUG (fputs ("renew_smb_context()\n", stderr));
+
+ if (!create_smb_context (domain, username, &newctx))
+ {
+ fputs ("Failed to create new SMB context.\n", stderr);
+ return false;
+ }
+
+ if (NULL != ctx)
+ destroy_smb_context (ctx, 0);
+
+ ctx = newctx;
+ return true;
+}
+
+
int main (int argc, char **argv)
{
const char *conffile, *mountid;
(DIR) diff --git a/usmb.h b/usmb.h
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
@@ -17,12 +17,14 @@
#ifndef USMB_H
#define USMB_H
+ #include <stdbool.h>
#include <libsmbclient.h>
extern SMBCCTX *ctx;
char * make_url (const char *path) MUSTCHECK;
+ bool renew_smb_context (void);
/* fuse_file_info uses a uint64_t for a "File handle" */
static inline uint64_t smbcfile_to_fd (SMBCFILE *file)
(DIR) diff --git a/usmb_dir.c b/usmb_dir.c
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
@@ -52,6 +52,10 @@ int usmb_rmdir (const char *dirname)
DEBUG (fprintf (stderr, "rmdir (%s)\n", url));
int ret = smbc_getFunctionRmdir (ctx) (ctx, url) ? -errno : 0;
free (url);
+
+ if (0 == ret)
+ (void)renew_smb_context();
+
return ret;
}
@@ -82,6 +86,7 @@ int usmb_readdir (const char *path UNUSED, void *h, fuse_fill_dir_t filler,
SMBCFILE *file = fd_to_smbcfile (fi->fh);
DEBUG (fprintf (stderr, "readdir (%s, %p)\n", path, (void *)file));
+ smbc_getFunctionLseekdir (ctx) (ctx, file, 0);
while (NULL != (dirent = smbc_getFunctionReaddir (ctx) (ctx, file)))
{
@@ -105,6 +110,7 @@ int usmb_readdir (const char *path UNUSED, void *h, fuse_fill_dir_t filler,
break;
}
+ DEBUG (fprintf (stderr, " %s\n", dirent->name));
if (1 == filler (h, dirent->name, &stbuf, 0)) /* if error */
return -1;
}
(DIR) diff --git a/usmb_dir.h b/usmb_dir.h
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/usmb_file.c b/usmb_file.c
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
@@ -44,7 +44,8 @@ static bool fix_nlink (const char *url, struct stat *st)
if (NULL == file)
return false;
- st->st_nlink = 2;
+ // st->st_nlink = 2;
+ st->st_nlink = 0;
errno = ERANGE;
struct smbc_dirent *dirent;
(DIR) diff --git a/usmb_file.h b/usmb_file.h
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/utils.c b/utils.c
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/utils.h b/utils.h
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/version.c b/version.c
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
@@ -33,7 +33,7 @@ void show_about (FILE *fp)
{
fprintf (fp, "usmb - mount SMB shares via FUSE and Samba\n"
"\n"
- "Copyright (C) 2006-2008 Geoff Johnstone.\n"
+ "Copyright (C) 2006-2009 Geoff Johnstone.\n"
"Licensed under the GNU General Public License.\n"
"usmb comes with ABSOLUTELY NO WARRANTY; "
"for details please see\n"
(DIR) diff --git a/version.h b/version.h
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
@@ -19,7 +19,7 @@
#include <stdio.h>
- #define USMB_VERSION 0x20081220
+ #define USMB_VERSION 0x20090227
// a - alpha, b - beta, p - pre-release, s - stable
#define USMB_VERSION_STATUS 's'
(DIR) diff --git a/xml.c b/xml.c
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
(DIR) diff --git a/xml.h b/xml.h
@@ -1,5 +1,5 @@
/* usmb - mount SMB shares via FUSE and Samba
- * Copyright (C) 2006-2008 Geoff Johnstone
+ * Copyright (C) 2006-2009 Geoff Johnstone
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as