[Stgt-devel] [PATCH] remove iscsi old files
Pete Wyckoff
pw
Sun Mar 18 16:20:32 CET 2007
Apparently a git conversion error. Remove these old files.
Signed-off-by: Pete Wyckoff <pw at osc.edu>
---
usr/iscsi/libistgt.c | 86 -------------
usr/iscsi/log.c | 345 --------------------------------------------------
usr/iscsi/log.h | 84 ------------
3 files changed, 0 insertions(+), 515 deletions(-)
delete mode 100644 usr/iscsi/libistgt.c
delete mode 100644 usr/iscsi/log.c
delete mode 100644 usr/iscsi/log.h
diff --git a/usr/iscsi/libistgt.c b/usr/iscsi/libistgt.c
deleted file mode 100644
index 50144c8..0000000
--- a/usr/iscsi/libistgt.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2006 FUJITA Tomonori <tomof at acm.org>
- * Copyright (C) 2006 Mike Christie
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that 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.
- *
- * See the file COPYING included with this distribution for more details.
- */
-
-#include <ctype.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <fcntl.h>
-#include <linux/types.h>
-#include <linux/netlink.h>
-
-#include "iscsid.h"
-#include "tgtadm.h"
-
-static int ipc_connect(void)
-{
- int fd, err;
- struct sockaddr_un addr;
-
- fd = socket(AF_LOCAL, SOCK_STREAM, 0);
- if (fd < 0)
- return fd;
-
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_LOCAL;
- memcpy((char *) &addr.sun_path + 1, ISTGT_NAMESPACE, strlen(ISTGT_NAMESPACE));
-
- if ((err = connect(fd, (struct sockaddr *) &addr, sizeof(addr))) < 0)
- fd = err;
-
- return fd;
-}
-
-int ipc_mgmt(char *sbuf, char *rbuf)
-{
- struct nlmsghdr *nlh = (struct nlmsghdr *) sbuf;
- struct tgtadm_req *req;
- int err = -EINVAL, fd;
- char *params;
-
- req = NLMSG_DATA(nlh);
- params = (char *) req + sizeof(*req);
-
- eprintf("%d %d %d %d %d %" PRIx64 " %" PRIx64 " %s\n", nlh->nlmsg_len,
- req->typeid, req->mode, req->op, req->tid, req->sid, req->lun, params);
-
- fd = ipc_connect();
- if (fd < 0) {
- eprintf("cannot connect istgtd\n");
- return fd;
- }
-
- err = write(fd, sbuf, nlh->nlmsg_len);
- if (err < 0) {
- eprintf("cannot connect istgtd\n");
- goto out;
- }
-
-out:
- close(fd);
-
- return err;
-}
diff --git a/usr/iscsi/log.c b/usr/iscsi/log.c
deleted file mode 100644
index c85a967..0000000
--- a/usr/iscsi/log.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Copyright (C) 2002-2003 Ardis Technolgies <roman at ardistech.com>
- *
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <ctype.h>
-#include <string.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <syslog.h>
-#include <signal.h>
-#include <sys/shm.h>
-#include <sys/ipc.h>
-#include <sys/types.h>
-
-#include "log.h"
-
-#define SEMKEY 0xA7L
-#define LOGDBG 0
-
-#if LOGDBG
-#define logdbg(file, fmt, args...) fprintf(file, fmt, ##args)
-#else
-#define logdbg(file, fmt, args...) do {} while (0)
-#endif
-
-static char *log_name;
-static int is_daemon, is_debug;
-
-static int logarea_init (int size)
-{
- int shmid;
-
- logdbg(stderr,"enter logarea_init\n");
-
- if ((shmid = shmget(IPC_PRIVATE, sizeof(struct logarea),
- 0644 | IPC_CREAT | IPC_EXCL)) == -1)
- return 1;
-
- la = shmat(shmid, NULL, 0);
- if (!la)
- return 1;
-
- if (size < MAX_MSG_SIZE)
- size = LOG_SPACE_SIZE;
-
- if ((shmid = shmget(IPC_PRIVATE, size,
- 0644 | IPC_CREAT | IPC_EXCL)) == -1) {
- shmdt(la);
- return 1;
- }
-
- la->start = shmat(shmid, NULL, 0);
- if (!la->start) {
- shmdt(la);
- return 1;
- }
- memset(la->start, 0, size);
-
- la->empty = 1;
- la->end = la->start + size;
- la->head = la->start;
- la->tail = la->start;
-
- if ((shmid = shmget(IPC_PRIVATE, MAX_MSG_SIZE + sizeof(struct logmsg),
- 0644 | IPC_CREAT | IPC_EXCL)) == -1) {
- shmdt(la->start);
- shmdt(la);
- return 1;
- }
- la->buff = shmat(shmid, NULL, 0);
- if (!la->buff) {
- shmdt(la->start);
- shmdt(la);
- return 1;
- }
-
- if ((la->semid = semget(SEMKEY, 1, 0666 | IPC_CREAT)) < 0) {
- shmdt(la->buff);
- shmdt(la->start);
- shmdt(la);
- return 1;
- }
-
- la->semarg.val=1;
- if (semctl(la->semid, 0, SETVAL, la->semarg) < 0) {
- shmdt(la->buff);
- shmdt(la->start);
- shmdt(la);
- return 1;
- }
-
- la->ops[0].sem_num = 0;
- la->ops[0].sem_flg = 0;
-
- return 0;
-
-}
-
-static void free_logarea (void)
-{
- semctl(la->semid, 0, IPC_RMID, la->semarg);
- shmdt(la->buff);
- shmdt(la->start);
- shmdt(la);
- return;
-}
-
-#if LOGDBG
-static void dump_logarea (void)
-{
- struct logmsg * msg;
-
- logdbg(stderr, "\n==== area: start addr = %p, end addr = %p ====\n",
- la->start, la->end);
- logdbg(stderr, "|addr |next |prio|msg\n");
-
- for (msg = (struct logmsg *)la->head; (void *)msg != la->tail;
- msg = msg->next)
- logdbg(stderr, "|%p |%p |%i |%s\n", (void *)msg, msg->next,
- msg->prio, (char *)&msg->str);
-
- logdbg(stderr, "|%p |%p |%i |%s\n", (void *)msg, msg->next,
- msg->prio, (char *)&msg->str);
-
- logdbg(stderr, "\n\n");
-}
-#endif
-
-int log_enqueue (int prio, const char * fmt, va_list ap)
-{
- int len, fwd;
- char buff[MAX_MSG_SIZE];
- struct logmsg * msg;
- struct logmsg * lastmsg;
-
- lastmsg = (struct logmsg *)la->tail;
-
- if (!la->empty) {
- fwd = sizeof(struct logmsg) +
- strlen((char *)&lastmsg->str) * sizeof(char) + 1;
- la->tail += fwd;
- }
- vsnprintf(buff, MAX_MSG_SIZE, fmt, ap);
- len = strlen(buff) * sizeof(char) + 1;
-
- /* not enough space on tail : rewind */
- if (la->head <= la->tail &&
- (len + sizeof(struct logmsg)) > (la->end - la->tail)) {
- logdbg(stderr, "enqueue: rewind tail to %p\n", la->tail);
- la->tail = la->start;
- }
-
- /* not enough space on head : drop msg */
- if (la->head > la->tail &&
- (len + sizeof(struct logmsg)) > (la->head - la->tail)) {
- logdbg(stderr, "enqueue: log area overrun, drop msg\n");
-
- if (!la->empty)
- la->tail = lastmsg;
-
- return 1;
- }
-
- /* ok, we can stage the msg in the area */
- la->empty = 0;
- msg = (struct logmsg *)la->tail;
- msg->prio = prio;
- memcpy((void *)&msg->str, buff, len);
- lastmsg->next = la->tail;
- msg->next = la->head;
-
- logdbg(stderr, "enqueue: %p, %p, %i, %s\n", (void *)msg, msg->next,
- msg->prio, (char *)&msg->str);
-
-#if LOGDBG
- dump_logarea();
-#endif
- return 0;
-}
-
-int log_dequeue (void * buff)
-{
- struct logmsg * src = (struct logmsg *)la->head;
- struct logmsg * dst = (struct logmsg *)buff;
- struct logmsg * lst = (struct logmsg *)la->tail;
-
- if (la->empty)
- return 1;
-
- int len = strlen((char *)&src->str) * sizeof(char) +
- sizeof(struct logmsg) + 1;
-
- dst->prio = src->prio;
- memcpy(dst, src, len);
-
- if (la->tail == la->head)
- la->empty = 1; /* we purge the last logmsg */
- else {
- la->head = src->next;
- lst->next = la->head;
- }
- logdbg(stderr, "dequeue: %p, %p, %i, %s\n",
- (void *)src, src->next, src->prio, (char *)&src->str);
-
- memset((void *)src, 0, len);
-
- return la->empty;
-}
-
-/*
- * this one can block under memory pressure
- */
-static void log_syslog (void * buff)
-{
- struct logmsg * msg = (struct logmsg *)buff;
-
- syslog(msg->prio, "%s", (char *)&msg->str);
-}
-
-static void dolog(int prio, const char *fmt, va_list ap)
-{
- if (is_daemon) {
- la->ops[0].sem_op = -1;
- if (semop(la->semid, la->ops, 1) < 0) {
- syslog(LOG_ERR, "semop up failed");
- return;
- }
-
- log_enqueue(prio, fmt, ap);
-
- la->ops[0].sem_op = 1;
- if (semop(la->semid, la->ops, 1) < 0) {
- syslog(LOG_ERR, "semop down failed");
- return;
- }
- } else {
- fprintf(stderr, "%s: ", log_name);
- vfprintf(stderr, fmt, ap);
- fflush(stderr);
- }
-}
-
-void log_warning(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- dolog(LOG_WARNING, fmt, ap);
- va_end(ap);
-}
-
-void log_error(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- dolog(LOG_ERR, fmt, ap);
- va_end(ap);
-}
-
-void log_debug(const char *fmt, ...)
-{
- if (!is_debug)
- return;
-
- va_list ap;
- va_start(ap, fmt);
- dolog(LOG_DEBUG, fmt, ap);
- va_end(ap);
-}
-
-static void log_flush(void)
-{
- while (!la->empty) {
- la->ops[0].sem_op = -1;
- if (semop(la->semid, la->ops, 1) < 0) {
- syslog(LOG_ERR, "semop up failed");
- exit(1);
- }
- log_dequeue(la->buff);
- la->ops[0].sem_op = 1;
- if (semop(la->semid, la->ops, 1) < 0) {
- syslog(LOG_ERR, "semop down failed");
- exit(1);
- }
- log_syslog(la->buff);
- }
-}
-
-int log_init(char *program_name, int size, int daemon, int debug)
-{
- is_daemon = daemon;
- is_debug = debug;
-
- logdbg(stderr,"enter log_init\n");
- log_name = program_name;
- if (is_daemon) {
- struct sigaction sa_old;
- struct sigaction sa_new;
- pid_t pid;
-
- openlog(log_name, 0, LOG_DAEMON);
- setlogmask (LOG_UPTO (LOG_DEBUG));
-
- if (logarea_init(size)) {
- syslog(LOG_ERR, "failed to initialize the logger\n");
- return 1;
- }
-
- pid = fork();
- if (pid < 0) {
- syslog(LOG_ERR, "fail to fork the logger\n");
- return 1;
- } else if (pid) {
- syslog(LOG_WARNING,
- "Target daemon logger with pid=%d started!\n", pid);
- return 0;
- }
-
- /* flush on daemon's crash */
- sa_new.sa_handler = (void*)log_flush;
- sigemptyset(&sa_new.sa_mask);
- sa_new.sa_flags = 0;
- sigaction(SIGSEGV, &sa_new, &sa_old );
-
- while(1) {
- log_flush();
- sleep(1);
- }
- exit(0);
- }
-
- return 0;
-}
-
-void log_close (void)
-{
- if (is_daemon) {
- closelog();
- free_logarea();
- }
- return;
-}
diff --git a/usr/iscsi/log.h b/usr/iscsi/log.h
deleted file mode 100644
index 35ce374..0000000
--- a/usr/iscsi/log.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * iSCSI Safe Logging and Tracing Library
- *
- * Copyright (C) 2004 Dmitry Yusupov, Alex Aizman
- * maintained by open-iscsi at googlegroups.com
- *
- * circular buffer code based on log.c from dm-multipath project
- *
- * heavily based on code from log.c:
- * Copyright (C) 2002-2003 Ardis Technolgies <roman at ardistech.com>,
- * licensed under the terms of the GNU GPL v2.0,
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that 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.
- *
- * See the file COPYING included with this distribution for more details.
- */
-
-#ifndef LOG_H
-#define LOG_H
-
-#include <sys/sem.h>
-
-union semun {
- int val;
- struct semid_ds *buf;
- unsigned short int *array;
- struct seminfo *__buf;
-};
-
-#define LOG_SPACE_SIZE 16384
-#define MAX_MSG_SIZE 256
-
-extern int log_daemon;
-extern int log_level;
-
-struct logmsg {
- short int prio;
- void *next;
- char *str;
-};
-
-struct logarea {
- int empty;
- void *head;
- void *tail;
- void *start;
- void *end;
- char *buff;
- struct sembuf ops[1];
- int semid;
- union semun semarg;
-};
-
-struct logarea *la;
-
-extern int log_init (char * progname, int size, int daemon, int debug);
-extern void log_close (void);
-extern void dump_logmsg (void *);
-extern void log_warning(const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
-extern void log_error(const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
-extern void log_debug(const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
-
-#define eprintf(fmt, args...) \
-do { \
- log_error("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \
-} while (0)
-
-#define dprintf(fmt, args...) \
-do { \
- log_debug("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \
-} while (0)
-
-#endif /* LOG_H */
--
1.5.0.3
More information about the stgt
mailing list