-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Empty framework created with a little README what's
required and how to test functionality.
- Loading branch information
root
committed
Dec 15, 2011
1 parent
30a9524
commit cb4f9ea
Showing
6 changed files
with
255 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
This is basic information about the 'sharesmb' option in ZFS | ||
On Linux by Turbo Fredriksson <[email protected]>. | ||
|
||
REQUIRENMENTS | ||
============================================================ | ||
1. Samba (doh! :) | ||
* I'm using version 3.3.3, but any 3.x should | ||
probably work. Please update the tracker with | ||
info.. | ||
|
||
2. The following configuration in smb.conf | ||
|
||
add share command = /usr/local/sbin/modify_samba_config.pl | ||
delete share command = /usr/local/sbin/modify_samba_config.pl | ||
change share command = /usr/local/sbin/modify_samba_config.pl | ||
|
||
include = /etc/samba/shares.conf-dynamic | ||
|
||
The script (modify_samba_config.pl) comes in two | ||
versions, one perl and one python and can be found | ||
in the samba source directory: | ||
|
||
./examples/scripts/shares/perl/modify_samba_config.pl | ||
./examples/scripts/shares/python/modify_samba_config.py | ||
|
||
Personaly, I choosed the perl version and modified | ||
it slightly - to not overwrite or modify smb.conf, | ||
but instead the /etc/samba/shares.conf-dynamic file, | ||
which is completely managed by the zfs/net commands. | ||
|
||
3. Samba will need to listen to 'localhost' (127.0.0.1), | ||
because that is hardcoded into the zfs module/libraries. | ||
|
||
4. A workable root password. ZFS is using 'root' as samba | ||
account to add, modify and remove shares so this need | ||
to work. | ||
|
||
5. A ZFS filesystem or more to export. | ||
|
||
|
||
TESTING | ||
============================================================ | ||
Once configuration in samba have been done, test that this | ||
works with the following commands (in this case, my ZFS | ||
filesystem is called 'share/Test1'): | ||
|
||
net -U root -S 127.0.0.1 share add Test1=/share/Test1 | ||
net share list | grep -i test | ||
net -U root -S 127.0.0.1 share delete Test1 | ||
|
||
The first and second command will ask for a root password | ||
and the second (middle) command should give at least one | ||
line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
* CDDL HEADER START | ||
* | ||
* The contents of this file are subject to the terms of the | ||
* Common Development and Distribution License (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* | ||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | ||
* or http://www.opensolaris.org/os/licensing. | ||
* See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
* | ||
* When distributing Covered Code, include this CDDL HEADER in each | ||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. | ||
* If applicable, add the following below this CDDL HEADER, with the | ||
* fields enclosed by brackets "[]" replaced with your own identifying | ||
* information: Portions Copyright [yyyy] [name of copyright owner] | ||
* | ||
* CDDL HEADER END | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2011 Turbo Fredriksson <[email protected]> | ||
* | ||
* This is an addition to the zfs device driver to add, modify and remove SMB | ||
* shares using the 'net share' command that comes with Samba. | ||
*/ | ||
|
||
#include <time.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <strings.h> | ||
#include <fcntl.h> | ||
#include <sys/wait.h> | ||
#include <unistd.h> | ||
#include <libzfs.h> | ||
#include <libshare.h> | ||
#include "libshare_impl.h" | ||
#include "smb.h" | ||
|
||
static sa_fstype_t *smb_fstype; | ||
boolean_t smb_available; | ||
|
||
int | ||
smb_enable_share_one(void) | ||
{ | ||
fprintf(stderr, "smb_enable_share_one()\n"); | ||
return 0; | ||
} | ||
|
||
int | ||
smb_enable_share(sa_share_impl_t impl_share) | ||
{ | ||
fprintf(stderr, "smb_enable_share()\n"); | ||
return 0; | ||
} | ||
|
||
int | ||
smb_disable_share_one(void) | ||
{ | ||
fprintf(stderr, "smb_disable_share_one()\n"); | ||
return 0; | ||
} | ||
|
||
int | ||
smb_disable_share(sa_share_impl_t impl_share) | ||
{ | ||
fprintf(stderr, "smb_disable_share()\n"); | ||
return 0; | ||
} | ||
|
||
static boolean_t | ||
smb_is_share_active(sa_share_impl_t impl_share) | ||
{ | ||
fprintf(stderr, "smb_is_share_active()\n"); | ||
return 0; | ||
} | ||
|
||
static int | ||
smb_validate_shareopts(const char *shareopts) | ||
{ | ||
/* TODO: implement */ | ||
return 0; | ||
} | ||
|
||
static int | ||
smb_update_shareopts(sa_share_impl_t impl_share, const char *resource, | ||
const char *shareopts) | ||
{ | ||
char *shareopts_dup; | ||
boolean_t needs_reshare = B_FALSE; | ||
char *old_shareopts; | ||
fprintf(stderr, "smb_update_shareopts()\n"); | ||
|
||
FSINFO(impl_share, smb_fstype)->active = smb_is_share_active(impl_share); | ||
|
||
old_shareopts = FSINFO(impl_share, smb_fstype)->shareopts; | ||
|
||
if (FSINFO(impl_share, smb_fstype)->active && old_shareopts != NULL && | ||
strcmp(old_shareopts, shareopts) != 0) { | ||
needs_reshare = B_TRUE; | ||
smb_disable_share(impl_share); | ||
} | ||
|
||
shareopts_dup = strdup(shareopts); | ||
|
||
if (shareopts_dup == NULL) | ||
return SA_NO_MEMORY; | ||
|
||
if (old_shareopts != NULL) | ||
free(old_shareopts); | ||
|
||
FSINFO(impl_share, smb_fstype)->shareopts = shareopts_dup; | ||
|
||
if (needs_reshare) | ||
smb_enable_share(impl_share); | ||
|
||
return 0; | ||
} | ||
|
||
static void | ||
smb_clear_shareopts(sa_share_impl_t impl_share) | ||
{ | ||
fprintf(stderr, "smb_clear_shareopts()\n"); | ||
free(FSINFO(impl_share, smb_fstype)->shareopts); | ||
FSINFO(impl_share, smb_fstype)->shareopts = NULL; | ||
} | ||
|
||
static const sa_share_ops_t smb_shareops = { | ||
.enable_share = smb_enable_share, | ||
.disable_share = smb_disable_share, | ||
|
||
.validate_shareopts = smb_validate_shareopts, | ||
.update_shareopts = smb_update_shareopts, | ||
.clear_shareopts = smb_clear_shareopts, | ||
}; | ||
|
||
int | ||
smb_retrieve_shares(void) | ||
{ | ||
fprintf(stderr, " smb_retrieve_shares()\n"); | ||
return 1; | ||
} | ||
|
||
void | ||
libshare_smb_init(void) | ||
{ | ||
fprintf(stderr, "libshare_smb_init()\n"); | ||
smb_available = (smb_retrieve_shares() == SA_OK); | ||
|
||
smb_fstype = register_fstype("smb", &smb_shareops); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* CDDL HEADER START | ||
* | ||
* The contents of this file are subject to the terms of the | ||
* Common Development and Distribution License (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* | ||
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | ||
* or http://www.opensolaris.org/os/licensing. | ||
* See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
* | ||
* When distributing Covered Code, include this CDDL HEADER in each | ||
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. | ||
* If applicable, add the following below this CDDL HEADER, with the | ||
* fields enclosed by brackets "[]" replaced with your own identifying | ||
* information: Portions Copyright [yyyy] [name of copyright owner] | ||
* | ||
* CDDL HEADER END | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2011 Turbo Fredriksson <[email protected]>. | ||
*/ | ||
|
||
void libshare_smb_init(void); |