All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mgmt: Create ipc socket parent dir if does not exists
@ 2015-04-12 15:11 Roi Dayan
  2015-04-13  5:56 ` FUJITA Tomonori
  0 siblings, 1 reply; 2+ messages in thread
From: Roi Dayan @ 2015-04-12 15:11 UTC (permalink / raw)
  To: fujita.tomonori; +Cc: stgt, Roi Dayan

If the parent dir doesn't exists then tgtd will fail to create the
socket and exit.
This commit will check if the folder doesn't exists and create it.

Signed-off-by: Roi Dayan <roid@mellanox.com>
---
 usr/mgmt.c   | 5 +++++
 usr/tgtadm.h | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/usr/mgmt.c b/usr/mgmt.c
index c2bd176..18fbfc1 100644
--- a/usr/mgmt.c
+++ b/usr/mgmt.c
@@ -765,6 +765,11 @@ int ipc_init(void)
 	extern short control_port;
 	int fd = 0, err;
 	struct sockaddr_un addr;
+	struct stat st = {0};
+
+	if (stat(TGT_IPC_DIR, &st) == -1) {
+		mkdir(TGT_IPC_DIR, 0755);
+	}
 
 	sprintf(mgmt_lock_path, "%s.%d.lock", TGT_IPC_NAMESPACE, control_port);
 	ipc_lock_fd = open(mgmt_lock_path, O_WRONLY | O_CREAT,
diff --git a/usr/tgtadm.h b/usr/tgtadm.h
index 866aac9..e3fda6a 100644
--- a/usr/tgtadm.h
+++ b/usr/tgtadm.h
@@ -1,7 +1,8 @@
 #ifndef TGTADM_H
 #define TGTADM_H
 
-#define TGT_IPC_NAMESPACE	"/var/run/tgtd/socket"
+#define TGT_IPC_DIR		"/var/run/tgtd"
+#define TGT_IPC_NAMESPACE	TGT_IPC_DIR"/socket"
 #define TGT_LLD_NAME_LEN	64
 
 #define GLOBAL_TID (~0U)
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mgmt: Create ipc socket parent dir if does not exists
  2015-04-12 15:11 [PATCH] mgmt: Create ipc socket parent dir if does not exists Roi Dayan
@ 2015-04-13  5:56 ` FUJITA Tomonori
  0 siblings, 0 replies; 2+ messages in thread
From: FUJITA Tomonori @ 2015-04-13  5:56 UTC (permalink / raw)
  To: roid; +Cc: stgt

On Sun, 12 Apr 2015 18:11:06 +0300
Roi Dayan <roid@mellanox.com> wrote:

> If the parent dir doesn't exists then tgtd will fail to create the
> socket and exit.
> This commit will check if the folder doesn't exists and create it.
> 
> Signed-off-by: Roi Dayan <roid@mellanox.com>
> ---
>  usr/mgmt.c   | 5 +++++
>  usr/tgtadm.h | 3 ++-
>  2 files changed, 7 insertions(+), 1 deletion(-)

Looks good. Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-13  5:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-12 15:11 [PATCH] mgmt: Create ipc socket parent dir if does not exists Roi Dayan
2015-04-13  5:56 ` FUJITA Tomonori

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.