<varlistentry>
<term>fileid:algorithm = ALGORITHM</term>
<listitem>
- <para>Available algorithms are <command>fsname</command>
- and <command>fsid</command>. The default value is
- <command>fsname</command>.
+ <para>Available algorithms are <command>fsname</command>,
+ <command>fsid</command> and <command>hostname</command>. The
+ default value is <command>fsname</command>.
</para>
<para>The <command>fsname</command> algorithm generates
device id by hashing the kernel device name.
the device id from the <command>f_fsid</command> returned
from the <command>statfs()</command> syscall.
</para>
+ <para>The <command>hostname</command> algorithm generates device
+ id by hashing the hostname. This can be used to deliberately
+ break lock coherency in a cluster.
+ </para>
</listitem>
</varlistentry>
return m->devid;
}
+/* a device mapping using a hostname */
+static uint64_t fileid_device_mapping_hostname(struct fileid_handle_data *data,
+ const SMB_STRUCT_STAT *sbuf)
+{
+ char hostname[HOST_NAME_MAX+1];
+ char *devname = NULL;
+ uint64_t id;
+ size_t devname_len;
+ int rc;
+
+ rc = gethostname(hostname, HOST_NAME_MAX+1);
+ if (rc != 0) {
+ DBG_ERR("gethostname failed\n");
+ return UINT64_MAX;
+ }
+
+ devname = talloc_asprintf(talloc_tos(), "%s%lu",
+ hostname, sbuf->st_ex_dev);
+ if (devname == NULL) {
+ DBG_ERR("talloc_asprintf failed\n");
+ return UINT64_MAX;
+ }
+ devname_len = talloc_array_length(devname) - 1;
+ TALLOC_FREE(devname);
+
+ id = fileid_uint64_hash((uint8_t *)devname, devname_len);
+ return id;
+}
+
/* device mapping functions using a fsid */
static uint64_t fileid_device_mapping_fsid(struct fileid_handle_data *data,
const SMB_STRUCT_STAT *sbuf)
data->device_mapping_fn = fileid_device_mapping_fsname;
} else if (strcmp("fsid", algorithm) == 0) {
data->device_mapping_fn = fileid_device_mapping_fsid;
+ } else if (strcmp("hostname", algorithm) == 0) {
+ data->device_mapping_fn = fileid_device_mapping_hostname;
} else {
SMB_VFS_NEXT_DISCONNECT(handle);
DEBUG(0,("fileid_connect(): unknown algorithm[%s]\n", algorithm));