The branch, master has been updated
       via  e17df483fbedb81aededdef5fbb6ae1d034bc2dd (commit)
       via  95e428e2279b706ac590ffb964fda07fd1ee2200 (commit)
       via  7f33b947e3c770f96f46fc9466376cd3c7825cd4 (commit)
       via  01493737c88c0056ca3da5faf43b7bc9b9a2fbcb (commit)
      from  76ca297ecfd1086b38487ac8f53a8392a4a38ad6 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e17df483fbedb81aededdef5fbb6ae1d034bc2dd
Author: Stefan Metzmacher <me...@samba.org>
Date:   Thu Jan 22 10:54:12 2009 +0100

    lib/tdb: if we know pwrite and pread are thread/fork safe tdb_reopen_all() 
should be a noop
    
    The reason for tdb_reopen_all() is that the seek pointer on fds are shared 
between
    parent and child.
    
    metze

commit 95e428e2279b706ac590ffb964fda07fd1ee2200
Author: Tim Prouty <tpro...@samba.org>
Date:   Tue Feb 24 16:42:18 2009 -0800

    s3: Report the correct path when dumping core on FreeBSD
    
    Utilize the kern.corefile sysctl value on FreeBSD

commit 7f33b947e3c770f96f46fc9466376cd3c7825cd4
Author: Tim Prouty <tpro...@samba.org>
Date:   Tue Feb 24 14:45:46 2009 -0800

    s3: Refactor and cleanup the error paths in dump_core_setup

commit 01493737c88c0056ca3da5faf43b7bc9b9a2fbcb
Author: Tim Prouty <tpro...@samba.org>
Date:   Mon Feb 23 14:51:17 2009 -0800

    s3 OneFS: Add .snapshot directory configuration handling

-----------------------------------------------------------------------

Summary of changes:
 lib/tdb/common/open.c           |    5 +
 source3/lib/fault.c             |  173 +++++++++++++++++++++++++++++----------
 source3/modules/onefs.h         |   32 +++++++-
 source3/modules/onefs_streams.c |    2 +-
 source3/modules/onefs_system.c  |   50 +++++++++++
 source3/modules/vfs_onefs.c     |  144 +++++++++++++++++++++++++++-----
 6 files changed, 337 insertions(+), 69 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index b19e4ce..e58c8ca 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -461,6 +461,10 @@ fail:
 /* reopen all tdb's */
 int tdb_reopen_all(int parent_longlived)
 {
+#if defined(LIBREPLACE_PREAD_NOT_REPLACED) && \
+       defined(LIBREPLACE_PWRITE_NOT_REPLACED)
+       return 0;
+#else
        struct tdb_context *tdb;
 
        for (tdb=tdbs; tdb; tdb = tdb->next) {
@@ -483,6 +487,7 @@ int tdb_reopen_all(int parent_longlived)
                if (tdb_reopen(tdb) != 0)
                        return -1;
        }
+#endif
 
        return 0;
 }
diff --git a/source3/lib/fault.c b/source3/lib/fault.c
index 8c4a45b..efd1ddd 100644
--- a/source3/lib/fault.c
+++ b/source3/lib/fault.c
@@ -2,6 +2,7 @@
    Unix SMB/CIFS implementation.
    Critical Fault handling
    Copyright (C) Andrew Tridgell 1992-1998
+   Copyright (C) Tim Prouty 2009
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -87,6 +88,128 @@ void fault_setup(void (*fn)(void *))
 #endif
 }
 
+/**
+ * Build up the default corepath as "<logbase>/cores/<progname>"
+ */
+static char *get_default_corepath(const char *logbase, const char *progname)
+{
+       char *tmp_corepath;
+
+       /* Setup core dir in logbase. */
+       tmp_corepath = talloc_asprintf(NULL, "%s/cores", logbase);
+       if (!tmp_corepath)
+               return NULL;
+
+       if ((mkdir(tmp_corepath, 0700) == -1) && errno != EEXIST)
+               goto err_out;
+
+       if (chmod(tmp_corepath, 0700) == -1)
+               goto err_out;
+
+       talloc_free(tmp_corepath);
+
+       /* Setup progname-specific core subdir */
+       tmp_corepath = talloc_asprintf(NULL, "%s/cores/%s", logbase, progname);
+       if (!tmp_corepath)
+               return NULL;
+
+       if (mkdir(tmp_corepath, 0700) == -1 && errno != EEXIST)
+               goto err_out;
+
+       if (chown(tmp_corepath, getuid(), getgid()) == -1)
+               goto err_out;
+
+       if (chmod(tmp_corepath, 0700) == -1)
+               goto err_out;
+
+       return tmp_corepath;
+
+ err_out:
+       talloc_free(tmp_corepath);
+       return NULL;
+}
+
+/**
+ * Get the FreeBSD corepath.
+ *
+ * On FreeBSD the current working directory is ignored when creating a core
+ * file.  Instead the core directory is controlled via sysctl.  This consults
+ * the value of "kern.corefile" so the correct corepath can be printed out
+ * before dump_core() calls abort.
+ */
+#if (defined(FREEBSD) && defined(HAVE_SYSCTLBYNAME))
+static char *get_freebsd_corepath(void)
+{
+       char *tmp_corepath = NULL;
+       char *end = NULL;
+       size_t len = 128;
+       int ret;
+
+       /* Loop with increasing sizes so we don't allocate too much. */
+       do {
+               if (len > 1024)  {
+                       goto err_out;
+               }
+
+               tmp_corepath = (char *)talloc_realloc(NULL, tmp_corepath,
+                                                     char, len);
+               if (!tmp_corepath) {
+                       return NULL;
+               }
+
+               ret = sysctlbyname("kern.corefile", tmp_corepath, &len, NULL,
+                                  0);
+               if (ret == -1) {
+                       if (errno != ENOMEM) {
+                               DEBUG(0, ("sysctlbyname failed getting "
+                                         "kern.corefile %s\n",
+                                         strerror(errno)));
+                               goto err_out;
+                       }
+
+                       /* Not a large enough array, try a bigger one. */
+                       len = len << 1;
+               }
+       } while (ret == -1);
+
+       /* Strip off the common filename expansion */
+       if ((end = strrchr_m(tmp_corepath, '/'))) {
+               *end = '\0';
+       }
+
+       return tmp_corepath;
+
+ err_out:
+       if (tmp_corepath) {
+               talloc_free(tmp_corepath);
+       }
+       return NULL;
+}
+#endif
+
+/**
+ * Try getting system-specific corepath if one exists.
+ *
+ * If the system doesn't define a corepath, then the default is used.
+ */
+static char *get_corepath(const char *logbase, const char *progname)
+{
+       char *tmp_corepath = NULL;
+
+       /* @todo: Add support for the linux corepath. */
+#if (defined(FREEBSD) && defined(HAVE_SYSCTLBYNAME))
+       tmp_corepath = get_freebsd_corepath();
+#endif
+
+       /* If this has been set correctly, we're done. */
+       if (tmp_corepath) {
+               return tmp_corepath;
+       }
+
+       /* Fall back to the default. */
+       return get_default_corepath(logbase, progname);
+}
+
 /*******************************************************************
 make all the preparations to safely dump a core file
 ********************************************************************/
@@ -104,7 +227,7 @@ void dump_core_setup(const char *progname)
                        *end = '\0';
                }
        } else {
-               /* We will end up here is the log file is given on the command
+               /* We will end up here if the log file is given on the command
                 * line by the -l option but the "log file" option is not set
                 * in smb.conf.
                 */
@@ -115,49 +238,13 @@ void dump_core_setup(const char *progname)
 
        SMB_ASSERT(progname != NULL);
 
-       if (asprintf(&corepath, "%s/cores", logbase) < 0) {
-               SAFE_FREE(logbase);
-               return;
-       }
-       if (mkdir(corepath,0700) == -1) {
-               if (errno != EEXIST) {
-                       SAFE_FREE(corepath);
-                       SAFE_FREE(logbase);
-                       return;
-               }
-       }
-       if (chmod(corepath,0700) == -1) {
-               SAFE_FREE(corepath);
-               SAFE_FREE(logbase);
-               return;
-       }
-
-       SAFE_FREE(corepath);
-       if (asprintf(&corepath, "%s/cores/%s",
-                       logbase, progname) < 0) {
-               SAFE_FREE(logbase);
-               return;
-       }
-       if (mkdir(corepath,0700) == -1) {
-               if (errno != EEXIST) {
-                       SAFE_FREE(corepath);
-                       SAFE_FREE(logbase);
-                       return;
-               }
-       }
-
-       if (chown(corepath,getuid(),getgid()) == -1) {
-               SAFE_FREE(corepath);
-               SAFE_FREE(logbase);
-               return;
-       }
-       if (chmod(corepath,0700) == -1) {
-               SAFE_FREE(corepath);
-               SAFE_FREE(logbase);
-               return;
+       corepath = get_corepath(logbase, progname);
+       if (!corepath) {
+               DEBUG(0, ("Unable to setup corepath for %s: %s\n", progname,
+                         strerror(errno)));
+               goto out;
        }
 
-       SAFE_FREE(logbase);
 
 #ifdef HAVE_GETRLIMIT
 #ifdef RLIMIT_CORE
@@ -184,6 +271,8 @@ void dump_core_setup(const char *progname)
        /* FIXME: if we have a core-plus-pid facility, configurably set
         * this up here.
         */
+ out:
+       SAFE_FREE(logbase);
 }
 
  void dump_core(void)
diff --git a/source3/modules/onefs.h b/source3/modules/onefs.h
index 418e13d..a0f4fe3 100644
--- a/source3/modules/onefs.h
+++ b/source3/modules/onefs.h
@@ -57,6 +57,16 @@ enum onefs_acl_wire_format
 #define PARM_CTIME_NOW_DEFAULT  NULL
 #define PARM_CTIME_SLOP                "ctime now slop"
 #define PARM_CTIME_SLOP_DEFAULT        0
+#define PARM_DOT_SNAP_CHILD_ACCESSIBLE "dot snap child accessible"
+#define PARM_DOT_SNAP_CHILD_ACCESSIBLE_DEFAULT true
+#define PARM_DOT_SNAP_CHILD_VISIBLE "dot snap child visible"
+#define PARM_DOT_SNAP_CHILD_VISIBLE_DEFAULT false
+#define PARM_DOT_SNAP_ROOT_ACCESSIBLE "dot snap root accessible"
+#define PARM_DOT_SNAP_ROOT_ACCESSIBLE_DEFAULT true
+#define PARM_DOT_SNAP_ROOT_VISIBLE "dot snap root visible"
+#define PARM_DOT_SNAP_ROOT_VISIBLE_DEFAULT true
+#define PARM_DOT_SNAP_TILDE "dot snap tilde"
+#define PARM_DOT_SNAP_TILDE_DEFAULT true
 #define PARM_IGNORE_SACLS "ignore sacls"
 #define PARM_IGNORE_SACLS_DEFAULT false
 #define PARM_MTIME_NOW         "mtime now files"
@@ -99,9 +109,9 @@ enum onefs_acl_wire_format
 
 #define ONEFS_VFS_CONFIG_FAKETIMESTAMPS        0x00000001
 
-struct onefs_vfs_config
+struct onefs_vfs_share_config
 {
-       int32 init_flags;
+       uint32_t init_flags;
 
        /* data for fake timestamps */
        int atime_slop;
@@ -127,6 +137,18 @@ struct onefs_vfs_config
        name_compare_entry *atime_static_list;
 };
 
+struct onefs_vfs_global_config
+{
+       uint32_t init_flags;
+
+       /* Snapshot options */
+       bool dot_snap_child_accessible;
+       bool dot_snap_child_visible;
+       bool dot_snap_root_accessible;
+       bool dot_snap_root_visible;
+       bool dot_snap_tilde;
+};
+
 /*
  * vfs interface handlers
  */
@@ -240,7 +262,7 @@ NTSTATUS onefs_split_ntfs_stream_name(TALLOC_CTX *mem_ctx, 
const char *fname,
                                      char **pbase, char **pstream);
 
 bool onefs_get_config(int snum, int config_type,
-                     struct onefs_vfs_config *cfg);
+                     struct onefs_vfs_share_config *cfg);
 
 int onefs_rdp_add_dir_state(connection_struct *conn, SMB_STRUCT_DIR *dirp);
 
@@ -269,4 +291,8 @@ ssize_t onefs_sys_sendfile(connection_struct *conn, int 
tofd, int fromfd,
 ssize_t onefs_sys_recvfile(int fromfd, int tofd, SMB_OFF_T offset,
                           size_t count);
 
+void onefs_sys_config_enc(void);
+void onefs_sys_config_snap_opt(struct onefs_vfs_global_config *global_config);
+void onefs_sys_config_tilde(struct onefs_vfs_global_config *global_config);
+
 #endif /* _ONEFS_H */
diff --git a/source3/modules/onefs_streams.c b/source3/modules/onefs_streams.c
index 2dcd889..6e27943 100644
--- a/source3/modules/onefs_streams.c
+++ b/source3/modules/onefs_streams.c
@@ -230,7 +230,7 @@ static void merge_stat(SMB_STRUCT_STAT *stream_sbuf,
 static void onefs_adjust_stat_time(vfs_handle_struct *handle, const char 
*fname,
                                   SMB_STRUCT_STAT *sbuf)
 {
-       struct onefs_vfs_config cfg;
+       struct onefs_vfs_share_config cfg;
        struct timeval tv_now = {0, 0};
        bool static_mtime = False;
        bool static_atime = False;
diff --git a/source3/modules/onefs_system.c b/source3/modules/onefs_system.c
index 518a398..43ebed8 100644
--- a/source3/modules/onefs_system.c
+++ b/source3/modules/onefs_system.c
@@ -656,3 +656,53 @@ out:
 
        return ret;
 }
+
+/**
+ * Set the per-process encoding, ignoring errors.
+ */
+void onefs_sys_config_enc(void)
+{
+       int ret;
+
+       ret = enc_set_proc(ENC_UTF8);
+       if (ret) {
+               DEBUG(0, ("Setting process encoding failed: %s",
+                       strerror(errno)));
+       }
+}
+
+/**
+ * Set the per-process .snpashot directory options, ignoring errors.
+ */
+void onefs_sys_config_snap_opt(struct onefs_vfs_global_config *global_config)
+{
+       struct ifs_dotsnap_options dso;
+       int ret;
+
+       dso.per_proc = 1;
+       dso.sub_accessible = global_config->dot_snap_child_accessible;
+       dso.sub_visible = global_config->dot_snap_child_visible;
+       dso.root_accessible = global_config->dot_snap_root_accessible;
+       dso.root_visible = global_config->dot_snap_root_visible;
+
+       ret = ifs_set_dotsnap_options(&dso);
+       if (ret) {
+               DEBUG(0, ("Setting snapshot visibility/accessibility "
+                       "failed: %s", strerror(errno)));
+       }
+}
+
+/**
+ * Set the per-process flag saying whether or not to accept ~snapshot
+ * as an alternative name for .snapshot directories.
+ */
+void onefs_sys_config_tilde(struct onefs_vfs_global_config *global_config)
+{
+       int ret;
+
+       ret = ifs_tilde_snapshot(global_config->dot_snap_tilde);
+       if (ret) {
+               DEBUG(0, ("Setting snapshot tilde failed: %s",
+                       strerror(errno)));
+       }
+}
diff --git a/source3/modules/vfs_onefs.c b/source3/modules/vfs_onefs.c
index 60c2c97..f811349 100644
--- a/source3/modules/vfs_onefs.c
+++ b/source3/modules/vfs_onefs.c
@@ -26,14 +26,14 @@
 
 #define ONEFS_DATA_FASTBUF     10
 
-struct onefs_vfs_config share_config[ONEFS_DATA_FASTBUF];
-struct onefs_vfs_config *pshare_config;
+struct onefs_vfs_share_config vfs_share_config[ONEFS_DATA_FASTBUF];
+struct onefs_vfs_share_config *pvfs_share_config;
 
-static void onefs_load_faketimestamp_config(struct vfs_handle_struct *handle,
-                                           struct onefs_vfs_config *cfg)
+static void onefs_load_faketimestamp_config(struct connection_struct *conn,
+                                           struct onefs_vfs_share_config *cfg)
 {
        const char **parm;
-       int snum = SNUM(handle->conn);
+       int snum = SNUM(conn);
 
        parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_ATIME_NOW,
                                   PARM_ATIME_NOW_DEFAULT);
@@ -83,46 +83,141 @@ static void onefs_load_faketimestamp_config(struct 
vfs_handle_struct *handle,
                                      PARM_MTIME_SLOP_DEFAULT);
 }
 
+/**
+ * Set onefs-specific vfs global config parameters.
+ *
+ * Since changes in these parameters require calling syscalls, we only want to
+ * call them when the configuration actually changes.
+ */
+static void onefs_load_global_config(connection_struct *conn)
+{
+       static struct onefs_vfs_global_config global_config;
+       bool dot_snap_child_accessible;
+       bool dot_snap_child_visible;
+       bool dot_snap_root_accessible;
+       bool dot_snap_root_visible;
+       bool dot_snap_tilde;
+       bool reconfig_dso = false;
+       bool reconfig_tilde = false;
+
+       /* Check if this is the first time setting the config options. */
+       if (!(global_config.init_flags & ONEFS_VFS_CONFIG_INITIALIZED)) {
+               global_config.init_flags |= ONEFS_VFS_CONFIG_INITIALIZED;
+
+               /* Set process encoding */
+               onefs_sys_config_enc();
+
+               reconfig_dso = true;
+               reconfig_tilde = true;
+       }
 
-static int onefs_load_config(struct vfs_handle_struct *handle)
+       /* Get the dot snap options from the conf. */
+       dot_snap_child_accessible =
+           lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
+                        PARM_DOT_SNAP_CHILD_ACCESSIBLE,
+                        PARM_DOT_SNAP_CHILD_ACCESSIBLE_DEFAULT);
+       dot_snap_child_visible =
+           lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
+                        PARM_DOT_SNAP_CHILD_VISIBLE,
+                        PARM_DOT_SNAP_CHILD_VISIBLE_DEFAULT);
+       dot_snap_root_accessible =
+           lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
+                        PARM_DOT_SNAP_ROOT_ACCESSIBLE,
+                        PARM_DOT_SNAP_ROOT_ACCESSIBLE_DEFAULT);
+       dot_snap_root_visible =
+           lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
+                        PARM_DOT_SNAP_ROOT_VISIBLE,
+                        PARM_DOT_SNAP_ROOT_VISIBLE_DEFAULT);
+       dot_snap_tilde =
+           lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
+                        PARM_DOT_SNAP_TILDE,
+                        PARM_DOT_SNAP_TILDE_DEFAULT);
+
+       /* Check if any of the dot snap options need updating. */
+       if (dot_snap_child_accessible !=
+           global_config.dot_snap_child_accessible) {
+               global_config.dot_snap_child_accessible =
+                   dot_snap_child_accessible;
+               reconfig_dso = true;
+       }
+       if (dot_snap_child_visible !=
+           global_config.dot_snap_child_visible) {
+               global_config.dot_snap_child_visible =
+                   dot_snap_child_visible;
+               reconfig_dso = true;
+       }
+       if (dot_snap_root_accessible !=
+           global_config.dot_snap_root_accessible) {
+               global_config.dot_snap_root_accessible =
+                   dot_snap_root_accessible;
+               reconfig_dso = true;
+       }
+       if (dot_snap_root_visible !=
+           global_config.dot_snap_root_visible) {
+               global_config.dot_snap_root_visible =
+                   dot_snap_root_visible;
+               reconfig_dso = true;
+       }
+       if (dot_snap_tilde != global_config.dot_snap_tilde) {
+               global_config.dot_snap_tilde = dot_snap_tilde;
+               reconfig_tilde = true;
+       }
+
+       /* If a dot snap option has changed update the process.  */
+       if (reconfig_dso) {
+               onefs_sys_config_snap_opt(&global_config);
+       }
+
+       /* If the dot snap tilde option has changed update the process.  */
+       if (reconfig_tilde) {
+               onefs_sys_config_tilde(&global_config);
+       }
+}
+
+static int onefs_load_config(connection_struct *conn)
 {


-- 
Samba Shared Repository

Reply via email to