diff options
Diffstat (limited to 'lib/libshare')
-rw-r--r-- | lib/libshare/libshare.c | 58 | ||||
-rw-r--r-- | lib/libshare/libshare_impl.h | 2 | ||||
-rw-r--r-- | lib/libshare/nfs.c | 126 | ||||
-rw-r--r-- | lib/libshare/smb.c | 136 | ||||
-rw-r--r-- | lib/libshare/smb.h | 10 |
5 files changed, 168 insertions, 164 deletions
diff --git a/lib/libshare/libshare.c b/lib/libshare/libshare.c index 6b39ba872..6625a1b0c 100644 --- a/lib/libshare/libshare.c +++ b/lib/libshare/libshare.c @@ -64,7 +64,7 @@ register_fstype(const char *name, const sa_share_ops_t *ops) fstype = calloc(sizeof (sa_fstype_t), 1); if (fstype == NULL) - return NULL; + return (NULL); fstype->name = name; fstype->ops = ops; @@ -75,7 +75,7 @@ register_fstype(const char *name, const sa_share_ops_t *ops) fstype->next = fstypes; fstypes = fstype; - return fstype; + return (fstype); } sa_handle_t @@ -86,7 +86,7 @@ sa_init(int init_service) impl_handle = calloc(sizeof (struct sa_handle_impl), 1); if (impl_handle == NULL) - return NULL; + return (NULL); impl_handle->zfs_libhandle = libzfs_init(); @@ -243,30 +243,30 @@ update_zfs_shares_cb(zfs_handle_t *zhp, void *pcookie) if (type == ZFS_TYPE_FILESYSTEM && zfs_iter_filesystems(zhp, update_zfs_shares_cb, pcookie) != 0) { zfs_close(zhp); - return 1; + return (1); } if (type != ZFS_TYPE_FILESYSTEM) { zfs_close(zhp); - return 0; + return (0); } if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint, sizeof (mountpoint), NULL, NULL, 0, B_FALSE) != 0) { zfs_close(zhp); - return 0; + return (0); } dataset = (char *)zfs_get_name(zhp); if (dataset == NULL) { zfs_close(zhp); - return 0; + return (0); } if (!zfs_is_mounted(zhp, NULL)) { zfs_close(zhp); - return 0; + return (0); } if ((udata->proto == NULL || strcmp(udata->proto, "nfs") == 0) && @@ -287,7 +287,7 @@ update_zfs_shares_cb(zfs_handle_t *zhp, void *pcookie) zfs_close(zhp); - return 0; + return (0); } static int @@ -298,7 +298,7 @@ update_zfs_share(sa_share_impl_t impl_share, const char *proto) update_cookie_t udata; if (impl_handle->zfs_libhandle == NULL) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); assert(impl_share->dataset != NULL); @@ -306,13 +306,13 @@ update_zfs_share(sa_share_impl_t impl_share, const char *proto) ZFS_TYPE_FILESYSTEM); if (zhp == NULL) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); udata.handle = impl_handle; udata.proto = proto; (void) update_zfs_shares_cb(zhp, &udata); - return SA_OK; + return (SA_OK); } static int @@ -321,14 +321,14 @@ update_zfs_shares(sa_handle_impl_t impl_handle, const char *proto) update_cookie_t udata; if (impl_handle->zfs_libhandle == NULL) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); udata.handle = impl_handle; udata.proto = proto; (void) zfs_iter_root(impl_handle->zfs_libhandle, update_zfs_shares_cb, &udata); - return SA_OK; + return (SA_OK); } static int @@ -351,7 +351,7 @@ process_share(sa_handle_impl_t impl_handle, sa_share_impl_t impl_share, if (impl_share == NULL) { if (lstat(pathname, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) - return SA_BAD_PATH; + return (SA_BAD_PATH); impl_share = alloc_share(pathname); @@ -421,7 +421,7 @@ err: free_share(impl_share); } - return rc; + return (rc); } void @@ -487,13 +487,13 @@ find_share(sa_handle_impl_t impl_handle, const char *sharepath) impl_share = impl_share->next; } - return impl_share; + return (impl_share); } sa_share_t sa_find_share(sa_handle_t handle, char *sharepath) { - return (sa_share_t)find_share((sa_handle_impl_t)handle, sharepath); + return ((sa_share_t)find_share((sa_handle_impl_t)handle, sharepath)); } int @@ -715,16 +715,16 @@ sa_parse_legacy_options(sa_group_t group, char *options, char *proto) continue; } - return fstype->ops->validate_shareopts(options); + return (fstype->ops->validate_shareopts(options)); } - return SA_INVALID_PROTOCOL; + return (SA_INVALID_PROTOCOL); } boolean_t sa_needs_refresh(sa_handle_t handle) { - return B_TRUE; + return (B_TRUE); } libzfs_handle_t * @@ -733,9 +733,9 @@ sa_get_zfs_handle(sa_handle_t handle) sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle; if (impl_handle == NULL) - return NULL; + return (NULL); - return impl_handle->zfs_libhandle; + return (impl_handle->zfs_libhandle); } static sa_share_impl_t @@ -746,13 +746,13 @@ alloc_share(const char *sharepath) impl_share = calloc(sizeof (struct sa_share_impl), 1); if (impl_share == NULL) - return NULL; + return (NULL); impl_share->sharepath = strdup(sharepath); if (impl_share->sharepath == NULL) { free(impl_share); - return NULL; + return (NULL); } impl_share->fsinfo = calloc(sizeof (sa_share_fsinfo_t), fstypes_count); @@ -760,10 +760,10 @@ alloc_share(const char *sharepath) if (impl_share->fsinfo == NULL) { free(impl_share->sharepath); free(impl_share); - return NULL; + return (NULL); } - return impl_share; + return (impl_share); } static void @@ -799,8 +799,8 @@ sa_zfs_process_share(sa_handle_t handle, sa_group_t group, sa_share_t share, shareopts, sourcestr, dataset); #endif - return process_share(impl_handle, impl_share, mountpoint, NULL, - proto, shareopts, NULL, dataset, B_FALSE); + return (process_share(impl_handle, impl_share, mountpoint, NULL, + proto, shareopts, NULL, dataset, B_FALSE)); } void diff --git a/lib/libshare/libshare_impl.h b/lib/libshare/libshare_impl.h index dfcec2ff9..18d619b10 100644 --- a/lib/libshare/libshare_impl.h +++ b/lib/libshare/libshare_impl.h @@ -43,7 +43,7 @@ typedef struct sa_share_impl { sa_share_fsinfo_t *fsinfo; /* per-fstype information */ } *sa_share_impl_t; -#define FSINFO(impl_share, fstype) (&(impl_share->fsinfo[fstype->fsinfo_index])) +#define FSINFO(impl_share, fstype) (&(impl_share->fsinfo[fstype->fsinfo_index])) typedef struct sa_share_ops { int (*enable_share)(sa_share_impl_t share); diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index 00ba0f621..d1b207e65 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -50,7 +50,7 @@ typedef int (*nfs_shareopt_callback_t)(const char *opt, const char *value, typedef int (*nfs_host_callback_t)(const char *sharepath, const char *host, const char *security, const char *access, void *cookie); -/** +/* * Invokes the specified callback function for each Solaris share option * listed in the specified string. */ @@ -62,12 +62,12 @@ foreach_nfs_shareopt(const char *shareopts, int was_nul, rc; if (shareopts == NULL) - return SA_OK; + return (SA_OK); shareopts_dup = strdup(shareopts); if (shareopts_dup == NULL) - return SA_NO_MEMORY; + return (SA_NO_MEMORY); opt = shareopts_dup; was_nul = 0; @@ -95,7 +95,7 @@ foreach_nfs_shareopt(const char *shareopts, if (rc != SA_OK) { free(shareopts_dup); - return rc; + return (rc); } } @@ -107,7 +107,7 @@ foreach_nfs_shareopt(const char *shareopts, free(shareopts_dup); - return 0; + return (0); } typedef struct nfs_host_cookie_s { @@ -117,7 +117,7 @@ typedef struct nfs_host_cookie_s { const char *security; } nfs_host_cookie_t; -/** +/* * Helper function for foreach_nfs_host. This function checks whether the * current share option is a host specification and invokes a callback * function with information about the host. @@ -146,7 +146,7 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie) host_dup = strdup(value); if (host_dup == NULL) - return SA_NO_MEMORY; + return (SA_NO_MEMORY); host = host_dup; @@ -163,7 +163,7 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie) if (rc != SA_OK) { free(host_dup); - return rc; + return (rc); } host = next; @@ -172,10 +172,10 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie) free(host_dup); } - return SA_OK; + return (SA_OK); } -/** +/* * Invokes a callback function for all NFS hosts that are set for a share. */ static int @@ -196,7 +196,7 @@ foreach_nfs_host(sa_share_impl_t impl_share, nfs_host_callback_t callback, &udata); } -/** +/* * Converts a Solaris NFS host specification to its Linux equivalent. */ static int @@ -217,13 +217,13 @@ get_linux_hostspec(const char *solaris_hostspec, char **plinux_hostspec) } if (*plinux_hostspec == NULL) { - return SA_NO_MEMORY; + return (SA_NO_MEMORY); } - return SA_OK; + return (SA_OK); } -/** +/* * Used internally by nfs_enable_share to enable sharing for a single host. */ static int @@ -281,12 +281,12 @@ nfs_enable_share_one(const char *sharepath, const char *host, free(opts); if (rc < 0) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); else - return SA_OK; + return (SA_OK); } -/** +/* * Adds a Linux share option to an array of NFS options. */ static int @@ -302,7 +302,7 @@ add_linux_shareopt(char **plinux_opts, const char *key, const char *value) (value ? 1 + strlen(value) : 0) + 1); if (new_linux_opts == NULL) - return SA_NO_MEMORY; + return (SA_NO_MEMORY); new_linux_opts[len] = '\0'; @@ -318,10 +318,10 @@ add_linux_shareopt(char **plinux_opts, const char *key, const char *value) *plinux_opts = new_linux_opts; - return SA_OK; + return (SA_OK); } -/** +/* * Validates and converts a single Solaris share option to its Linux * equivalent. */ @@ -333,15 +333,15 @@ get_linux_shareopts_cb(const char *key, const char *value, void *cookie) /* host-specific options, these are taken care of elsewhere */ if (strcmp(key, "ro") == 0 || strcmp(key, "rw") == 0 || strcmp(key, "sec") == 0) - return SA_OK; + return (SA_OK); if (strcmp(key, "anon") == 0) key = "anonuid"; - if (strcmp(key, "root_mapping") == 0) { - (void) add_linux_shareopt(plinux_opts, "root_squash", NULL); - key = "anonuid"; - } + if (strcmp(key, "root_mapping") == 0) { + (void) add_linux_shareopt(plinux_opts, "root_squash", NULL); + key = "anonuid"; + } if (strcmp(key, "nosub") == 0) key = "subtree_check"; @@ -364,15 +364,15 @@ get_linux_shareopts_cb(const char *key, const char *value, void *cookie) strcmp(key, "all_squash") != 0 && strcmp(key, "no_all_squash") != 0 && strcmp(key, "fsid") != 0 && strcmp(key, "anonuid") != 0 && strcmp(key, "anongid") != 0) { - return SA_SYNTAX_ERR; + return (SA_SYNTAX_ERR); } (void) add_linux_shareopt(plinux_opts, key, value); - return SA_OK; + return (SA_OK); } -/** +/* * Takes a string containing Solaris share options (e.g. "sync,no_acl") and * converts them to a NULL-terminated array of Linux NFS options. */ @@ -390,17 +390,18 @@ get_linux_shareopts(const char *shareopts, char **plinux_opts) (void) add_linux_shareopt(plinux_opts, "no_root_squash", NULL); (void) add_linux_shareopt(plinux_opts, "mountpoint", NULL); - rc = foreach_nfs_shareopt(shareopts, get_linux_shareopts_cb, plinux_opts); + rc = foreach_nfs_shareopt(shareopts, get_linux_shareopts_cb, + plinux_opts); if (rc != SA_OK) { free(*plinux_opts); *plinux_opts = NULL; } - return rc; + return (rc); } -/** +/* * Enables NFS sharing for the specified share. */ static int @@ -410,27 +411,27 @@ nfs_enable_share(sa_share_impl_t impl_share) int rc; if (!nfs_available()) { - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); } shareopts = FSINFO(impl_share, nfs_fstype)->shareopts; if (shareopts == NULL) - return SA_OK; + return (SA_OK); rc = get_linux_shareopts(shareopts, &linux_opts); if (rc != SA_OK) - return rc; + return (rc); rc = foreach_nfs_host(impl_share, nfs_enable_share_one, linux_opts); free(linux_opts); - return rc; + return (rc); } -/** +/* * Used internally by nfs_disable_share to disable sharing for a single host. */ static int @@ -471,12 +472,12 @@ nfs_disable_share_one(const char *sharepath, const char *host, free(hostpath); if (rc < 0) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); else - return SA_OK; + return (SA_OK); } -/** +/* * Disables NFS sharing for the specified share. */ static int @@ -487,13 +488,13 @@ nfs_disable_share(sa_share_impl_t impl_share) * The share can't possibly be active, so nothing * needs to be done to disable it. */ - return SA_OK; + return (SA_OK); } - return foreach_nfs_host(impl_share, nfs_disable_share_one, NULL); + return (foreach_nfs_host(impl_share, nfs_disable_share_one, NULL)); } -/** +/* * Checks whether the specified NFS share options are syntactically correct. */ static int @@ -505,14 +506,14 @@ nfs_validate_shareopts(const char *shareopts) rc = get_linux_shareopts(shareopts, &linux_opts); if (rc != SA_OK) - return rc; + return (rc); free(linux_opts); - return SA_OK; + return (SA_OK); } -/** +/* * Checks whether a share is currently active. */ static boolean_t @@ -523,17 +524,17 @@ nfs_is_share_active(sa_share_impl_t impl_share) FILE *nfs_exportfs_temp_fp; if (!nfs_available()) - return B_FALSE; + return (B_FALSE); nfs_exportfs_temp_fp = fdopen(dup(nfs_exportfs_temp_fd), "r"); if (nfs_exportfs_temp_fp == NULL || fseek(nfs_exportfs_temp_fp, 0, SEEK_SET) < 0) { fclose(nfs_exportfs_temp_fp); - return B_FALSE; + return (B_FALSE); } - while (fgets(line, sizeof(line), nfs_exportfs_temp_fp) != NULL) { + while (fgets(line, sizeof (line), nfs_exportfs_temp_fp) != NULL) { /* * exportfs uses separate lines for the share path * and the export options when the share path is longer @@ -564,16 +565,16 @@ nfs_is_share_active(sa_share_impl_t impl_share) if (strcmp(line, impl_share->sharepath) == 0) { fclose(nfs_exportfs_temp_fp); - return B_TRUE; + return (B_TRUE); } } fclose(nfs_exportfs_temp_fp); - return B_FALSE; + return (B_FALSE); } -/** +/* * Called to update a share's options. A share's options might be out of * date if the share was loaded from disk (i.e. /etc/dfs/sharetab) and the * "sharenfs" dataset property has changed in the meantime. This function @@ -604,7 +605,7 @@ nfs_update_shareopts(sa_share_impl_t impl_share, const char *resource, shareopts_dup = strdup(shareopts); if (shareopts_dup == NULL) - return SA_NO_MEMORY; + return (SA_NO_MEMORY); if (old_shareopts != NULL) free(old_shareopts); @@ -614,10 +615,10 @@ nfs_update_shareopts(sa_share_impl_t impl_share, const char *resource, if (needs_reshare) nfs_enable_share(impl_share); - return SA_OK; + return (SA_OK); } -/** +/* * Clears a share's NFS options. Used by libshare to * clean up shares that are about to be free()'d. */ @@ -666,7 +667,7 @@ nfs_check_exportfs(void) nfs_exportfs_temp_fd = mkstemp(nfs_exportfs_tempfile); if (nfs_exportfs_temp_fd < 0) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); unlink(nfs_exportfs_tempfile); @@ -677,26 +678,25 @@ nfs_check_exportfs(void) if (pid < 0) { (void) close(nfs_exportfs_temp_fd); nfs_exportfs_temp_fd = -1; - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); } if (pid > 0) { - while ((rc = waitpid(pid, &status, 0)) <= 0 && errno == EINTR) - ; /* empty loop body */ + while ((rc = waitpid(pid, &status, 0)) <= 0 && errno == EINTR); if (rc <= 0) { (void) close(nfs_exportfs_temp_fd); nfs_exportfs_temp_fd = -1; - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); } if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { (void) close(nfs_exportfs_temp_fd); nfs_exportfs_temp_fd = -1; - return SA_CONFIG_ERR; + return (SA_CONFIG_ERR); } - return SA_OK; + return (SA_OK); } /* child */ @@ -724,10 +724,10 @@ nfs_available(void) if (nfs_exportfs_temp_fd == -1) (void) nfs_check_exportfs(); - return (nfs_exportfs_temp_fd != -1) ? B_TRUE : B_FALSE; + return ((nfs_exportfs_temp_fd != -1) ? B_TRUE : B_FALSE); } -/** +/* * Initializes the NFS functionality of libshare. */ void diff --git a/lib/libshare/smb.c b/lib/libshare/smb.c index a545bfb0f..1ac1a8d27 100644 --- a/lib/libshare/smb.c +++ b/lib/libshare/smb.c @@ -26,7 +26,7 @@ * * 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. - + * * TESTING * Make sure that samba listens to 'localhost' (127.0.0.1) and that the options * 'usershare max shares' and 'usershare owner only' have been rewied/set @@ -64,7 +64,7 @@ static boolean_t smb_available(void); static sa_fstype_t *smb_fstype; -/** +/* * Retrieve the list of SMB shares. */ static int @@ -83,7 +83,7 @@ smb_retrieve_shares(void) /* opendir(), stat() */ shares_dir = opendir(SHARE_DIR); if (shares_dir == NULL) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); /* Go through the directory, looking for shares */ while ((directory = readdir(shares_dir))) { @@ -91,7 +91,7 @@ smb_retrieve_shares(void) continue; snprintf(file_path, sizeof (file_path), - "%s/%s", SHARE_DIR, directory->d_name); + "%s/%s", SHARE_DIR, directory->d_name); if (stat(file_path, &eStat) == -1) { rc = SA_SYSTEM_ERR; @@ -108,17 +108,17 @@ smb_retrieve_shares(void) name = strdup(directory->d_name); if (name == NULL) { - rc = SA_NO_MEMORY; - goto out; + rc = SA_NO_MEMORY; + goto out; } - while (fgets(line, sizeof(line), share_file_fp)) { + while (fgets(line, sizeof (line), share_file_fp)) { if (line[0] == '#') continue; /* Trim trailing new-line character(s). */ while (line[strlen(line) - 1] == '\r' || - line[strlen(line) - 1] == '\n') + line[strlen(line) - 1] == '\n') line[strlen(line) - 1] = '\0'; /* Split the line in two, separated by '=' */ @@ -155,24 +155,25 @@ smb_retrieve_shares(void) strncpy(shares->name, name, sizeof (shares->name)); - shares->name [sizeof(shares->name)-1] = '\0'; + shares->name [sizeof (shares->name) - 1] = '\0'; strncpy(shares->path, path, - sizeof (shares->path)); - shares->path [sizeof(shares->path)-1] = '\0'; + sizeof (shares->path)); + shares->path [sizeof (shares->path) - 1] = '\0'; strncpy(shares->comment, comment, - sizeof (shares->comment)); - shares->comment[sizeof(shares->comment)-1]='\0'; + sizeof (shares->comment)); + shares->comment[sizeof (shares->comment)-1] = + '\0'; shares->guest_ok = atoi(guest_ok); shares->next = new_shares; new_shares = shares; - name = NULL; - path = NULL; - comment = NULL; + name = NULL; + path = NULL; + comment = NULL; guest_ok = NULL; } } @@ -190,10 +191,10 @@ out: smb_shares = new_shares; - return rc; + return (rc); } -/** +/* * Used internally by smb_enable_share to enable sharing for a single host. */ static int @@ -204,8 +205,8 @@ smb_enable_share_one(const char *sharename, const char *sharepath) int rc; /* Support ZFS share name regexp '[[:alnum:]_-.: ]' */ - strncpy(name, sharename, sizeof(name)); - name [sizeof(name)-1] = '\0'; + strncpy(name, sharename, sizeof (name)); + name [sizeof (name)-1] = '\0'; pos = name; while (*pos != '\0') { @@ -220,32 +221,34 @@ smb_enable_share_one(const char *sharename, const char *sharepath) ++pos; } - /* CMD: net -S NET_CMD_ARG_HOST usershare add Test1 /share/Test1 \ - * "Comment" "Everyone:F" */ - snprintf(comment, sizeof(comment), "Comment: %s", sharepath); - - argv[0] = NET_CMD_PATH; - argv[1] = (char*)"-S"; - argv[2] = NET_CMD_ARG_HOST; - argv[3] = (char*)"usershare"; - argv[4] = (char*)"add"; - argv[5] = (char*)name; - argv[6] = (char*)sharepath; - argv[7] = (char*)comment; + /* + * CMD: net -S NET_CMD_ARG_HOST usershare add Test1 /share/Test1 \ + * "Comment" "Everyone:F" + */ + snprintf(comment, sizeof (comment), "Comment: %s", sharepath); + + argv[0] = NET_CMD_PATH; + argv[1] = (char *)"-S"; + argv[2] = NET_CMD_ARG_HOST; + argv[3] = (char *)"usershare"; + argv[4] = (char *)"add"; + argv[5] = (char *)name; + argv[6] = (char *)sharepath; + argv[7] = (char *)comment; argv[8] = "Everyone:F"; argv[9] = NULL; rc = libzfs_run_process(argv[0], argv, 0); if (rc < 0) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); /* Reload the share file */ (void) smb_retrieve_shares(); - return SA_OK; + return (SA_OK); } -/** +/* * Enables SMB sharing for the specified share. */ static int @@ -254,20 +257,21 @@ smb_enable_share(sa_share_impl_t impl_share) char *shareopts; if (!smb_available()) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); shareopts = FSINFO(impl_share, smb_fstype)->shareopts; if (shareopts == NULL) /* on/off */ - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); if (strcmp(shareopts, "off") == 0) - return SA_OK; + return (SA_OK); /* Magic: Enable (i.e., 'create new') share */ - return smb_enable_share_one(impl_share->dataset, impl_share->sharepath); + return (smb_enable_share_one(impl_share->dataset, + impl_share->sharepath)); } -/** +/* * Used internally by smb_disable_share to disable sharing for a single host. */ static int @@ -278,21 +282,21 @@ smb_disable_share_one(const char *sharename) /* CMD: net -S NET_CMD_ARG_HOST usershare delete Test1 */ argv[0] = NET_CMD_PATH; - argv[1] = (char*)"-S"; + argv[1] = (char *)"-S"; argv[2] = NET_CMD_ARG_HOST; - argv[3] = (char*)"usershare"; - argv[4] = (char*)"delete"; + argv[3] = (char *)"usershare"; + argv[4] = (char *)"delete"; argv[5] = strdup(sharename); argv[6] = NULL; rc = libzfs_run_process(argv[0], argv, 0); if (rc < 0) - return SA_SYSTEM_ERR; + return (SA_SYSTEM_ERR); else - return SA_OK; + return (SA_OK); } -/** +/* * Disables SMB sharing for the specified share. */ static int @@ -305,20 +309,20 @@ smb_disable_share(sa_share_impl_t impl_share) * The share can't possibly be active, so nothing * needs to be done to disable it. */ - return SA_OK; + return (SA_OK); } while (shares != NULL) { if (strcmp(impl_share->sharepath, shares->path) == 0) - return smb_disable_share_one(shares->name); + return (smb_disable_share_one(shares->name)); shares = shares->next; } - return SA_OK; + return (SA_OK); } -/** +/* * Checks whether the specified SMB share options are syntactically correct. */ static int @@ -326,34 +330,34 @@ smb_validate_shareopts(const char *shareopts) { /* TODO: Accept 'name' and sec/acl (?) */ if ((strcmp(shareopts, "off") == 0) || (strcmp(shareopts, "on") == 0)) - return SA_OK; + return (SA_OK); - return SA_SYNTAX_ERR; + return (SA_SYNTAX_ERR); } -/** +/* * Checks whether a share is currently active. */ static boolean_t smb_is_share_active(sa_share_impl_t impl_share) { if (!smb_available()) - return B_FALSE; + return (B_FALSE); /* Retrieve the list of (possible) active shares */ smb_retrieve_shares(); while (smb_shares != NULL) { if (strcmp(impl_share->sharepath, smb_shares->path) == 0) - return B_TRUE; + return (B_TRUE); smb_shares = smb_shares->next; } - return B_FALSE; + return (B_FALSE); } -/** +/* * Called to update a share's options. A share's options might be out of * date if the share was loaded from disk and the "sharesmb" dataset * property has changed in the meantime. This function also takes care @@ -367,8 +371,8 @@ smb_update_shareopts(sa_share_impl_t impl_share, const char *resource, boolean_t needs_reshare = B_FALSE; char *old_shareopts; - if(!impl_share) - return SA_SYSTEM_ERR; + if (!impl_share) + return (SA_SYSTEM_ERR); FSINFO(impl_share, smb_fstype)->active = smb_is_share_active(impl_share); @@ -384,7 +388,7 @@ smb_update_shareopts(sa_share_impl_t impl_share, const char *resource, shareopts_dup = strdup(shareopts); if (shareopts_dup == NULL) - return SA_NO_MEMORY; + return (SA_NO_MEMORY); if (old_shareopts != NULL) free(old_shareopts); @@ -394,10 +398,10 @@ smb_update_shareopts(sa_share_impl_t impl_share, const char *resource, if (needs_reshare) smb_enable_share(impl_share); - return SA_OK; + return (SA_OK); } -/** +/* * Clears a share's SMB options. Used by libshare to * clean up shares that are about to be free()'d. */ @@ -427,15 +431,15 @@ smb_available(void) if (lstat(SHARE_DIR, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) - return B_FALSE; + return (B_FALSE); if (access(NET_CMD_PATH, F_OK) != 0) - return B_FALSE; + return (B_FALSE); - return B_TRUE; + return (B_TRUE); } -/** +/* * Initializes the SMB functionality of libshare. */ void diff --git a/lib/libshare/smb.h b/lib/libshare/smb.h index f5ac83ace..7a0c0fd16 100644 --- a/lib/libshare/smb.h +++ b/lib/libshare/smb.h @@ -28,12 +28,12 @@ * references are hard to find. */ -#define SMB_NAME_MAX 255 -#define SMB_COMMENT_MAX 255 +#define SMB_NAME_MAX 255 +#define SMB_COMMENT_MAX 255 -#define SHARE_DIR "/var/lib/samba/usershares" -#define NET_CMD_PATH "/usr/bin/net" -#define NET_CMD_ARG_HOST "127.0.0.1" +#define SHARE_DIR "/var/lib/samba/usershares" +#define NET_CMD_PATH "/usr/bin/net" +#define NET_CMD_ARG_HOST "127.0.0.1" typedef struct smb_share_s { char name[SMB_NAME_MAX]; /* Share name */ |