/*
- * 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 from the top-level
- * OPENSOLARIS.LICENSE or <http://opensource.org/licenses/CDDL-1.0>.
- * 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 from the top-level 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
- */
-
-/*
+ * This file is part of the ZFS Event Daemon (ZED)
+ * for ZFS on Linux (ZoL) <http://zfsonlinux.org/>.
* Developed at Lawrence Livermore National Laboratory (LLNL-CODE-403049).
* Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC.
+ * Refer to the ZoL git commit log for authoritative copyright attribution.
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License Version 1.0 (CDDL-1.0).
+ * You can obtain a copy of the license from the top-level file
+ * "OPENSOLARIS.LICENSE" or at <http://opensource.org/licenses/CDDL-1.0>.
+ * You may not use this file except in compliance with the license.
*/
#include <assert.h>
zed_log_msg(LOG_WARNING,
"Failed to close state file \"%s\": %s",
zcp->state_file, strerror(errno));
+ zcp->state_fd = -1;
}
if (zcp->pid_file) {
if ((unlink(zcp->pid_file) < 0) && (errno != ENOENT))
zcp->pid_file, strerror(errno));
zcp->pid_fd = -1;
}
- if (zcp->conf_file)
+ if (zcp->conf_file) {
free(zcp->conf_file);
-
- if (zcp->pid_file)
+ zcp->conf_file = NULL;
+ }
+ if (zcp->pid_file) {
free(zcp->pid_file);
-
- if (zcp->zedlet_dir)
+ zcp->pid_file = NULL;
+ }
+ if (zcp->zedlet_dir) {
free(zcp->zedlet_dir);
-
- if (zcp->state_file)
+ zcp->zedlet_dir = NULL;
+ }
+ if (zcp->state_file) {
free(zcp->state_file);
-
- if (zcp->zedlets)
+ zcp->state_file = NULL;
+ }
+ if (zcp->zedlets) {
zed_strings_destroy(zcp->zedlets);
-
+ zcp->zedlets = NULL;
+ }
free(zcp);
}
"Run daemon in the foreground.");
fprintf(fp, "%*c%*s %s\n", w1, 0x20, -w2, "-M",
"Lock all pages in memory.");
+ fprintf(fp, "%*c%*s %s\n", w1, 0x20, -w2, "-P",
+ "$PATH for ZED to use (only used by ZTS).");
fprintf(fp, "%*c%*s %s\n", w1, 0x20, -w2, "-Z",
"Zero state file.");
fprintf(fp, "\n");
"The ZFS Event Daemon (ZED) is distributed under the terms of the",
" Common Development and Distribution License (CDDL-1.0)",
" <http://opensource.org/licenses/CDDL-1.0>.",
+ "",
"Developed at Lawrence Livermore National Laboratory"
" (LLNL-CODE-403049).",
- "Copyright (C) 2013-2014"
- " Lawrence Livermore National Security, LLC.",
"",
NULL
};
void
zed_conf_parse_opts(struct zed_conf *zcp, int argc, char **argv)
{
- const char * const opts = ":hLVc:d:p:s:vfFMZ";
+ const char * const opts = ":hLVc:d:p:P:s:vfFMZ";
int opt;
if (!zcp || !argv || !argv[0])
case 'p':
_zed_conf_parse_path(&zcp->pid_file, optarg);
break;
+ case 'P':
+ _zed_conf_parse_path(&zcp->path, optarg);
+ break;
case 's':
_zed_conf_parse_path(&zcp->state_file, optarg);
break;
direntp->d_name);
continue;
}
- if ((st.st_mode & S_IWGRP) & !zcp->do_force) {
+ if ((st.st_mode & S_IWGRP) && !zcp->do_force) {
zed_log_msg(LOG_NOTICE,
"Ignoring \"%s\": writable by group",
direntp->d_name);
continue;
}
- if ((st.st_mode & S_IWOTH) & !zcp->do_force) {
+ if ((st.st_mode & S_IWOTH) && !zcp->do_force) {
zed_log_msg(LOG_NOTICE,
"Ignoring \"%s\": writable by other",
direntp->d_name);
continue;
}
- if (zed_strings_add(zedlets, direntp->d_name) < 0) {
+ if (zed_strings_add(zedlets, NULL, direntp->d_name) < 0) {
zed_log_msg(LOG_WARNING,
"Failed to register \"%s\": %s",
direntp->d_name, strerror(errno));
/*
* Write PID file.
*/
- n = snprintf(buf, sizeof (buf), "%d\n", (int) getpid());
+ n = snprintf(buf, sizeof (buf), "%d\n", (int)getpid());
if ((n < 0) || (n >= sizeof (buf))) {
errno = ERANGE;
zed_log_msg(LOG_ERR, "Failed to write PID file \"%s\": %s",
"Failed to read state file: %s", strerror(errno));
return (-1);
}
- if (lseek(zcp->state_fd, 0, SEEK_SET) == (off_t) -1) {
+ if (lseek(zcp->state_fd, 0, SEEK_SET) == (off_t)-1) {
zed_log_msg(LOG_WARNING,
"Failed to reposition state file offset: %s",
strerror(errno));
"Failed to write state file: %s", strerror(errno));
return (-1);
}
- if (lseek(zcp->state_fd, 0, SEEK_SET) == (off_t) -1) {
+ if (lseek(zcp->state_fd, 0, SEEK_SET) == (off_t)-1) {
zed_log_msg(LOG_WARNING,
"Failed to reposition state file offset: %s",
strerror(errno));