to be cached locally on disk through the general filesystem cache
manager. If unsure, say N.
+config CIFS_SYSFS
+ bool "sysfs file system support"
+ depends on CIFS && SYSFS
+ help
+ Say Y to export kernel object attributes, controls, and deliver
+ events to userspace
cifs-$(CONFIG_CIFS_SMB2) += smb2ops.o smb2maperror.o smb2transport.o \
smb2misc.o smb2pdu.o smb2inode.o smb2file.o
+
+cifs-$(CONFIG_CIFS_SYSFS) += sysfs.o
#ifdef CONFIG_CIFS_SMB2
#include "smb2pdu.h"
#endif
+#ifdef CONFIG_CIFS_SYSFS
+#include "sysfs.h"
+#endif
int cifsFYI = 0;
bool traceSMB;
rc = register_filesystem(&cifs_fs_type);
if (rc)
goto out_init_cifs_idmap;
-
+#ifdef CONFIG_CIFS_SYSFS
+ rc = cifs_sysfs_init();
+ if (rc)
+ printk(KERN_WARNING "CIFS: Failed to init sysfs: %d\n", rc);
+#endif
return 0;
+
out_init_cifs_idmap:
#ifdef CONFIG_CIFS_ACL
exit_cifs_idmap();
exit_cifs(void)
{
cifs_dbg(NOISY, "exit_cifs\n");
+#ifdef CONFIG_CIFS_SYSFS
+ cifs_sysfs_exit();
+#endif
unregister_filesystem(&cifs_fs_type);
cifs_dfs_release_automount_timer();
#ifdef CONFIG_CIFS_ACL
#include "smb2proto.h"
#endif
+#ifdef CONFIG_CIFS_SYSFS
+#include "sysfs.h"
+#endif
+
#define CIFS_PORT 445
#define RFC1001_PORT 139
#endif
cifs_dbg(FYI, "Reconnecting tcp session\n");
+#ifdef CONFIG_CIFS_SYSFS
+ cifs_sysfs_notify_change(server->hostname, RECONNECTING);
+#endif
/* before reconnecting the tcp session, mark the smb session (uid)
and the tid bad so they are not used until reconnected */
mutex_unlock(&server->srv_mutex);
msleep(3000);
} else {
+#ifdef CONFIG_CIFS_SYSFS
+ cifs_sysfs_notify_change(server->hostname, RECONNECTED);
+#endif
atomic_inc(&tcpSesReconnectCount);
spin_lock(&GlobalMid_Lock);
if (server->tcpStatus != CifsExiting)
ses->server->ops->tree_disconnect(xid, tcon);
_free_xid(xid);
+#ifdef CONFIG_CIFS_SYSFS
+ cifs_sysfs_notify_change(tcon->treeName, DISCONNECTED);
+#endif
cifs_fscache_release_super_cookie(tcon);
tconInfoFree(tcon);
cifs_put_smb_ses(ses);
if (rc)
goto out_fail;
+#ifdef CONFIG_CIFS_SYSFS
+ cifs_sysfs_notify_change(tcon->treeName, CONNECTED);
+#endif
+
if (volume_info->nodfs) {
tcon->Flags &= ~SMB_SHARE_IS_IN_DFS;
cifs_dbg(FYI, "DFS disabled (%d)\n", tcon->Flags);
--- /dev/null
+/*
+ * sysfs for cifs
+ *
+ * Copyright (c) 2018, NVIDIA Corporation. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <linux/kobject.h>
+#include <linux/slab.h>
+#include "cifsglob.h"
+#include "sysfs.h"
+
+static struct kset *cifs_sysfs_kset;
+static struct kobject *cifs_sysfs_kobj;
+
+static struct kobj_type cifs_uevent_ktype = {
+
+};
+
+void cifs_sysfs_notify_change(const char* source, cifs_event_type event_type) {
+ char env_source[30];
+ char env_state[30];
+ char *envp[3] = { env_source, env_state, NULL };
+ sprintf(env_source, "SOURCE=%s", source);
+ sprintf(env_state, "STATE=%d", event_type);
+ kobject_uevent_env(cifs_sysfs_kobj, KOBJ_CHANGE, envp);
+}
+
+int cifs_sysfs_init(void) {
+ int ret;
+ cifs_sysfs_kset = kset_create_and_add("cifs", NULL, fs_kobj);
+ if (!cifs_sysfs_kset) {
+ return -ENOMEM;
+ }
+ cifs_sysfs_kobj = kzalloc(sizeof(*cifs_sysfs_kobj),
+ GFP_KERNEL);
+ if (!cifs_sysfs_kobj) {
+ return -ENOMEM;
+ }
+ cifs_sysfs_kobj->kset = cifs_sysfs_kset;
+ ret = kobject_init_and_add(cifs_sysfs_kobj, &cifs_uevent_ktype, NULL, "uevent");
+ if (!ret) {
+ kobject_uevent(cifs_sysfs_kobj, KOBJ_ADD);
+ } else {
+ kfree(cifs_sysfs_kobj);
+ }
+ return ret;
+}
+
+void cifs_sysfs_exit(void) {
+ kobject_uevent(cifs_sysfs_kobj, KOBJ_REMOVE);
+ kobject_put(cifs_sysfs_kobj);
+ kset_unregister(cifs_sysfs_kset);
+}
--- /dev/null
+/*
+ * sysfs header for cifs
+ *
+ * Copyright (c) 2018, NVIDIA Corporation. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _CIFS_SYSFS_H
+#define _CIFS_SYSFS_H
+
+typedef enum {
+ CONNECTED = 1,
+ DISCONNECTED,
+ RECONNECTING,
+ RECONNECTED,
+} cifs_event_type;
+
+void cifs_sysfs_notify_change(const char* source, cifs_event_type type);
+int cifs_sysfs_init(void);
+void cifs_sysfs_exit(void);
+#endif