cluster: STABLE31 - cman: check and set transport only when parsing primary interface
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 90182b28490ec8383e2d45dbab8c23a1d1420bdc
Parent: 8e0caa36fa1a65016757d38f39838f58fca6b030
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Thu Aug 18 09:31:36 2011 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Thu Aug 18 09:31:36 2011 +0200
cman: check and set transport only when parsing primary interface
Fix regression introduced in da36fb6bc9e in combination with altname/RRP support
Resolves: rhbz#695795
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/daemon/cman-preconfig.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
index 0f5f937..99aa532 100644
--- a/cman/daemon/cman-preconfig.c
+++ b/cman/daemon/cman-preconfig.c
@@ -276,7 +276,10 @@ static int add_udpu_members(struct objdb_iface_ver0 *objdb, hdb_handle_t interfa
return 0;
}
-static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr, int port, int ttl, enum tx_mech transport)
+#define PRIMARY_IFACE 0
+#define ALT_IFACE 1
+
+static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr, int port, int ttl, int altiface, enum tx_mech transport)
{
hdb_handle_t totem_object_handle;
hdb_handle_t find_handle;
@@ -310,15 +313,17 @@ static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr,
if (objdb->object_find_next(find_handle, &totem_object_handle)) {
objdb->object_create(OBJECT_PARENT_HANDLE, &totem_object_handle,
"totem", strlen("totem"));
- }
+ }
objdb->object_find_destroy(find_handle);
- if (objdb_get_string(objdb, totem_object_handle, "transport", &transportstr)) {
- objdb->object_key_create_typed(totem_object_handle, "transport",
- tx_mech_to_str[transport], strlen(tx_mech_to_str[transport]) + 1, OBJDB_VALUETYPE_STRING);
- } else {
- sprintf(error_reason, "Transport should not be specified within <totem .../>, use <cman transport=\"...\" /> instead");
- return -1;
+ if (!altiface) {
+ if (objdb_get_string(objdb, totem_object_handle, "transport", &transportstr)) {
+ objdb->object_key_create_typed(totem_object_handle, "transport",
+ tx_mech_to_str[transport], strlen(tx_mech_to_str[transport]) + 1, OBJDB_VALUETYPE_STRING);
+ } else {
+ sprintf(error_reason, "Transport should not be specified within <totem .../>, use <cman transport=\"...\" /> instead");
+ return -1;
+ }
}
if (objdb->object_create(totem_object_handle, &interface_object_handle,
@@ -749,7 +754,8 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
}
}
- if (add_ifaddr(objdb, mcast_name, nodename, portnum, ttl, transport)) {
+ if (add_ifaddr(objdb, mcast_name, nodename, portnum, ttl,
+ PRIMARY_IFACE, transport)) {
write_cman_pipe(error_reason);
return -1;
}
@@ -775,7 +781,8 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
mcast = mcast_name;
}
- if (add_ifaddr(objdb, mcast, node, portnum, altttl, transport)) {
+ if (add_ifaddr(objdb, mcast, node, portnum, altttl,
+ ALT_IFACE, transport)) {
write_cman_pipe(error_reason);
return -1;
}
12 years, 9 months
cluster: RHEL56 - cman: allow init script to pass options to fenced
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: a121a03a7c2e94d47e1bb60cd535cc304b972513
Parent: f0ffdf45b95f891a54aa1b085aa84bd8882974cb
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Fri Jul 23 16:13:31 2010 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Aug 17 12:40:10 2011 +0200
cman: allow init script to pass options to fenced
Use FENCED_OPTS to pass startup options to fenced
Resolves: rhbz#731305
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/init.d/cman | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/cman/init.d/cman b/cman/init.d/cman
index b59216a..2ed83a5 100755
--- a/cman/init.d/cman
+++ b/cman/init.d/cman
@@ -55,6 +55,9 @@
# to join the fence domain (equivalent to "yes").
[ -z "$FENCE_JOIN" ] && FENCE_JOIN="yes"
+# FENCED_OPTS -- allow extra options to be passed to fence daemon.
+[ -z "$FENCED_OPTS" ] && FENCED_OPTS=""
+
# NETWORK_BRIDGE_SCRIPT -- script to use for xen network bridging.
# This script must exist in the /etc/xen/scripts directory.
# The default script is "network-bridge".
@@ -163,7 +166,7 @@ start_daemons()
status fenced &> /dev/null
if [ $? -ne 0 ]; then
- errmsg=$( /sbin/fenced 2>&1 ) || return 1
+ errmsg=$( /sbin/fenced "$FENCED_OPTS" 2>&1 ) || return 1
fi
status dlm_controld &> /dev/null
12 years, 9 months
cluster: RHEL57 - cman: allow init script to pass options to fenced
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 103b9e866a82934db4c4443e1ca482aa66ea5b11
Parent: 1f2194c131c4dc6a12c61e7e69b79e27309aa5d1
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Fri Jul 23 16:13:31 2010 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Aug 17 12:36:09 2011 +0200
cman: allow init script to pass options to fenced
Use FENCED_OPTS to pass startup options to fenced
Resolves: rhbz#731306
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/init.d/cman | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/cman/init.d/cman b/cman/init.d/cman
index b59216a..2ed83a5 100755
--- a/cman/init.d/cman
+++ b/cman/init.d/cman
@@ -55,6 +55,9 @@
# to join the fence domain (equivalent to "yes").
[ -z "$FENCE_JOIN" ] && FENCE_JOIN="yes"
+# FENCED_OPTS -- allow extra options to be passed to fence daemon.
+[ -z "$FENCED_OPTS" ] && FENCED_OPTS=""
+
# NETWORK_BRIDGE_SCRIPT -- script to use for xen network bridging.
# This script must exist in the /etc/xen/scripts directory.
# The default script is "network-bridge".
@@ -163,7 +166,7 @@ start_daemons()
status fenced &> /dev/null
if [ $? -ne 0 ]; then
- errmsg=$( /sbin/fenced 2>&1 ) || return 1
+ errmsg=$( /sbin/fenced "$FENCED_OPTS" 2>&1 ) || return 1
fi
status dlm_controld &> /dev/null
12 years, 9 months
cluster: RHEL58 - cman: allow init script to pass options to fenced
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 81ee84ff36b08e9ff35d1c47daf087f9c37f9fe8
Parent: 587c2f737a9a0b2f2339b10651a998ddae48f892
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Fri Jul 23 16:13:31 2010 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Tue Aug 16 07:49:59 2011 +0200
cman: allow init script to pass options to fenced
Use FENCED_OPTS to pass startup options to fenced
Resolves: rhbz#730639
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/init.d/cman | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/cman/init.d/cman b/cman/init.d/cman
index b59216a..2ed83a5 100755
--- a/cman/init.d/cman
+++ b/cman/init.d/cman
@@ -55,6 +55,9 @@
# to join the fence domain (equivalent to "yes").
[ -z "$FENCE_JOIN" ] && FENCE_JOIN="yes"
+# FENCED_OPTS -- allow extra options to be passed to fence daemon.
+[ -z "$FENCED_OPTS" ] && FENCED_OPTS=""
+
# NETWORK_BRIDGE_SCRIPT -- script to use for xen network bridging.
# This script must exist in the /etc/xen/scripts directory.
# The default script is "network-bridge".
@@ -163,7 +166,7 @@ start_daemons()
status fenced &> /dev/null
if [ $? -ne 0 ]; then
- errmsg=$( /sbin/fenced 2>&1 ) || return 1
+ errmsg=$( /sbin/fenced "$FENCED_OPTS" 2>&1 ) || return 1
fi
status dlm_controld &> /dev/null
12 years, 9 months
cluster: STABLE31 - Revert "cman: do not free shutdown connection till the last message is sent"
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 8e0caa36fa1a65016757d38f39838f58fca6b030
Parent: 0d05c47540f783587edbcb6b1c227aed2caf9fde
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Mon Aug 15 10:48:12 2011 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Mon Aug 15 10:48:12 2011 +0200
Revert "cman: do not free shutdown connection till the last message is sent"
This reverts commit 0d05c47540f783587edbcb6b1c227aed2caf9fde.
---
cman/daemon/cnxman-private.h | 2 +-
cman/daemon/commands.c | 1 -
cman/daemon/daemon.c | 7 -------
3 files changed, 1 insertions(+), 9 deletions(-)
diff --git a/cman/daemon/cnxman-private.h b/cman/daemon/cnxman-private.h
index c2fd4b5..002480d 100644
--- a/cman/daemon/cnxman-private.h
+++ b/cman/daemon/cnxman-private.h
@@ -107,7 +107,7 @@ struct connection
uint32_t confchg; /* Registered for confchg */
struct list write_msgs; /* Queued messages to go to data clients */
uint32_t num_write_msgs; /* Count of messages */
- uint32_t shutdown_con;
+ struct connection *next;
struct list list; /* when on the client_list */
};
diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
index 781e193..2948952 100644
--- a/cman/daemon/commands.c
+++ b/cman/daemon/commands.c
@@ -1060,7 +1060,6 @@ static int do_cmd_try_shutdown(struct connection *con, char *cmdbuf)
shutdown_yes = 0;
shutdown_no = 0;
shutdown_expected = num_listeners();
- shutdown_con->shutdown_con = 1;
/* If no-one is listening for events then we can just go down now */
if (shutdown_expected == 0) {
diff --git a/cman/daemon/daemon.c b/cman/daemon/daemon.c
index 3da476b..92cfd47 100644
--- a/cman/daemon/daemon.c
+++ b/cman/daemon/daemon.c
@@ -112,12 +112,6 @@ static void remove_client(hdb_handle_t handle, struct connection *con)
struct queued_reply *qm;
int msgs=0;
- if (con->shutdown_con) {
- P_DAEMON("Delay removal of shutdown connection\n");
- con->shutdown_con = 0;
- return;
- }
-
poll_dispatch_delete(handle, con->fd);
close(con->fd);
if (con->type == CON_CLIENT)
@@ -348,7 +342,6 @@ static int process_rendezvous(hdb_handle_t handle, int fd, int revent, void *dat
newcon->port = 0;
newcon->events = 0;
newcon->num_write_msgs = 0;
- newcon->shutdown_con = 0;
list_init(&newcon->write_msgs);
fcntl(client_fd, F_SETFL, fcntl(client_fd, F_GETFL, 0) | O_NONBLOCK);
12 years, 9 months
fence-agents: RHEL6 - fence_drac5: drac5 firmware does not close ssh session correctly
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/fence-agents.git?p=fence-agents.git;a=com...
Commit: 68001a547dca906c708917e1caf15e53a63547df
Parent: 4b90f43b77f9a44e6239d0d3b6a02cfccf4ee1f5
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon Aug 15 09:35:11 2011 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Aug 15 09:41:28 2011 +0200
fence_drac5: drac5 firmware does not close ssh session correctly
Attempt to close connection right after sending 'exit' command does
not close session correctly.
Resolves: rhbz#718924
---
fence/agents/drac5/fence_drac5.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index 5e72e42..f3102cd 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -12,7 +12,7 @@
## @note: drac_version was removed
#####
-import sys, re, pexpect, exceptions
+import sys, re, pexpect, exceptions, time
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
@@ -134,6 +134,7 @@ By default, the telnet interface is not enabled."
######
try:
conn.sendline("exit")
+ time.sleep(1)
conn.close()
except exceptions.OSError:
pass
12 years, 9 months
fence-agents: master - fence_drac5: drac5 firmware does not close ssh session correctly
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/fence-agents.git?p=fence-agents.git;a=com...
Commit: 1a961801928dd0f79991e5bf0e81483aeaf7351a
Parent: 412aa5cd03d6ef556997294f8f1346795f93ffd1
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon Aug 15 09:35:11 2011 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Aug 15 09:35:11 2011 +0200
fence_drac5: drac5 firmware does not close ssh session correctly
Attempt to close connection right after sending 'exit' command does
not close session correctly.
Resolves: rhbz#718924
---
fence/agents/drac5/fence_drac5.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index 5e72e42..f3102cd 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -12,7 +12,7 @@
## @note: drac_version was removed
#####
-import sys, re, pexpect, exceptions
+import sys, re, pexpect, exceptions, time
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
@@ -134,6 +134,7 @@ By default, the telnet interface is not enabled."
######
try:
conn.sendline("exit")
+ time.sleep(1)
conn.close()
except exceptions.OSError:
pass
12 years, 9 months
cluster: STABLE31 - cman: do not free shutdown connection till the last message is sent
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 0d05c47540f783587edbcb6b1c227aed2caf9fde
Parent: da36fb6bc9e7a8908011e41ef78235f6c0160ca6
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Fri Aug 12 16:00:00 2011 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Fri Aug 12 16:08:16 2011 +0200
cman: do not free shutdown connection till the last message is sent
the shutdown connection was incorrectly freed too early in the process
and re-used again after free, sometimes sending random bytes to fd 0 (syslog).
Resolves: rhbz#727215
Reviewed-by: Christine Caulfield <ccaulfie(a)redhat.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/daemon/cnxman-private.h | 2 +-
cman/daemon/commands.c | 1 +
cman/daemon/daemon.c | 7 +++++++
3 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/cman/daemon/cnxman-private.h b/cman/daemon/cnxman-private.h
index 002480d..c2fd4b5 100644
--- a/cman/daemon/cnxman-private.h
+++ b/cman/daemon/cnxman-private.h
@@ -107,7 +107,7 @@ struct connection
uint32_t confchg; /* Registered for confchg */
struct list write_msgs; /* Queued messages to go to data clients */
uint32_t num_write_msgs; /* Count of messages */
- struct connection *next;
+ uint32_t shutdown_con;
struct list list; /* when on the client_list */
};
diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
index 2948952..781e193 100644
--- a/cman/daemon/commands.c
+++ b/cman/daemon/commands.c
@@ -1060,6 +1060,7 @@ static int do_cmd_try_shutdown(struct connection *con, char *cmdbuf)
shutdown_yes = 0;
shutdown_no = 0;
shutdown_expected = num_listeners();
+ shutdown_con->shutdown_con = 1;
/* If no-one is listening for events then we can just go down now */
if (shutdown_expected == 0) {
diff --git a/cman/daemon/daemon.c b/cman/daemon/daemon.c
index 92cfd47..3da476b 100644
--- a/cman/daemon/daemon.c
+++ b/cman/daemon/daemon.c
@@ -112,6 +112,12 @@ static void remove_client(hdb_handle_t handle, struct connection *con)
struct queued_reply *qm;
int msgs=0;
+ if (con->shutdown_con) {
+ P_DAEMON("Delay removal of shutdown connection\n");
+ con->shutdown_con = 0;
+ return;
+ }
+
poll_dispatch_delete(handle, con->fd);
close(con->fd);
if (con->type == CON_CLIENT)
@@ -342,6 +348,7 @@ static int process_rendezvous(hdb_handle_t handle, int fd, int revent, void *dat
newcon->port = 0;
newcon->events = 0;
newcon->num_write_msgs = 0;
+ newcon->shutdown_con = 0;
list_init(&newcon->write_msgs);
fcntl(client_fd, F_SETFL, fcntl(client_fd, F_GETFL, 0) | O_NONBLOCK);
12 years, 9 months
cluster: RHEL58 - cman: do not free shutdown connection till the last message is sent
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 587c2f737a9a0b2f2339b10651a998ddae48f892
Parent: d1495ea6d49bf7f9fb481bbc408483a3e0ffb900
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Fri Aug 12 16:00:00 2011 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Fri Aug 12 16:00:00 2011 +0200
cman: do not free shutdown connection till the last message is sent
the shutdown connection was incorrectly freed too early in the process
and re-used again after free, sometimes sending random bytes to fd 0 (syslog).
Resolves: rhbz#727215
Reviewed-by: Christine Caulfield <ccaulfie(a)redhat.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/daemon/cnxman-private.h | 2 +-
cman/daemon/commands.c | 1 +
cman/daemon/daemon.c | 7 +++++++
3 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/cman/daemon/cnxman-private.h b/cman/daemon/cnxman-private.h
index c823a70..f12bca9 100644
--- a/cman/daemon/cnxman-private.h
+++ b/cman/daemon/cnxman-private.h
@@ -133,7 +133,7 @@ struct connection
uint32_t confchg; /* Registered for confchg */
struct list write_msgs; /* Queued messages to go to data clients */
uint32_t num_write_msgs; /* Count of messages */
- struct connection *next;
+ uint32_t shutdown_con;
struct list list; /* when on the client_list */
};
diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
index 6c91d7a..6e0160b 100644
--- a/cman/daemon/commands.c
+++ b/cman/daemon/commands.c
@@ -944,6 +944,7 @@ static int do_cmd_try_shutdown(struct connection *con, char *cmdbuf)
shutdown_yes = 0;
shutdown_no = 0;
shutdown_expected = num_listeners();
+ shutdown_con->shutdown_con = 1;
/* If no-one is listening for events then we can just go down now */
if (shutdown_expected == 0) {
diff --git a/cman/daemon/daemon.c b/cman/daemon/daemon.c
index 08aeb80..c1250e7 100644
--- a/cman/daemon/daemon.c
+++ b/cman/daemon/daemon.c
@@ -116,6 +116,12 @@ static void remove_client(poll_handle handle, struct connection *con)
struct queued_reply *qm;
int msgs=0;
+ if (con->shutdown_con) {
+ P_DAEMON("Delay removal of shutdown connection\n");
+ con->shutdown_con = 0;
+ return;
+ }
+
poll_dispatch_delete(handle, con->fd);
close(con->fd);
if (con->type == CON_CLIENT)
@@ -340,6 +346,7 @@ static int process_rendezvous(poll_handle handle, int fd, int revent, void *data
newcon->port = 0;
newcon->events = 0;
newcon->num_write_msgs = 0;
+ newcon->shutdown_con = 0;
list_init(&newcon->write_msgs);
fcntl(client_fd, F_SETFL, fcntl(client_fd, F_GETFL, 0) | O_NONBLOCK);
12 years, 9 months
cluster: RHEL58 - mkfs: Handle gfs2 creation on regular files
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: d1495ea6d49bf7f9fb481bbc408483a3e0ffb900
Parent: 1c9c96f17d03c51fd875eea94f14f517f2c2c446
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Aug 10 14:43:53 2011 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Aug 10 16:36:16 2011 +0100
mkfs: Handle gfs2 creation on regular files
mkfs.gfs2 previously exited if the target volume was a regular file.
This patch allows creation of gfs2 file systems on regular files by
removing an exiting check. It also removes the check_mount() function and
replaces it with an fstat() call after opening the file to avoid races.
This patch is based on commit 9e213f6 upstream.
rhbz#720935
Signed-off-by: Andrew Price <anprice(a)redhat.com>
Reviewed-by: Steven Whitehouse <swhiteho(a)redhat.com>
---
gfs2/mkfs/main_mkfs.c | 39 +++++++--------------------------------
1 files changed, 7 insertions(+), 32 deletions(-)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 80126d1..35d10ea 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -295,36 +295,6 @@ static void are_you_sure(struct gfs2_sbd *sdp)
}
/**
- * check_mount - check to see if device is mounted/busy
- * @device: the device to create the filesystem on
- *
- */
-
-static void check_mount(char *device)
-{
- struct stat st_buf;
- int fd;
-
- if (stat(device, &st_buf) < 0)
- die( _("could not stat device %s\n"), device);
- if (!S_ISBLK(st_buf.st_mode))
- die( _("%s is not a block device\n"), device);
-
- fd = open(device, O_RDONLY | O_NONBLOCK | O_EXCL);
-
- if (fd < 0) {
- if (errno == EBUSY) {
- die( _("device %s is busy\n"), device);
- }
- }
- else {
- close(fd);
- }
-
- return;
-}
-
-/**
* print_results - print out summary information
* @sdp: the command line
*
@@ -381,6 +351,7 @@ main_mkfs(int argc, char *argv[])
int rgsize_specified = 0;
uint64_t real_device_size;
unsigned char uuid[16];
+ struct stat st_buf;
memset(sdp, 0, sizeof(struct gfs2_sbd));
sdp->bsize = GFS2_DEFAULT_BSIZE;
@@ -400,13 +371,17 @@ main_mkfs(int argc, char *argv[])
verify_arguments(sdp);
- check_mount(sdp->device_name);
-
sdp->device_fd = open(sdp->device_name, O_RDWR);
if (sdp->device_fd < 0)
die( _("can't open device %s: %s\n"),
sdp->device_name, strerror(errno));
+ if (fstat(sdp->device_fd, &st_buf) < 0) {
+ fprintf(stderr, _("could not fstat fd %d: %s\n"),
+ sdp->device_fd, strerror(errno));
+ exit(-1);
+ }
+
if (!sdp->override)
are_you_sure(sdp);
12 years, 9 months