All of lore.kernel.org
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/ricci/modules/storage MountHandler.cpp
Date: 24 Aug 2007 22:06:30 -0000	[thread overview]
Message-ID: <20070824220630.31374.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-08-24 22:06:29

Modified files:
	ricci/modules/storage: MountHandler.cpp 

Log message:
	Better error messages

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/MountHandler.cpp.diff?cvsroot=cluster&r1=1.6&r2=1.7

--- conga/ricci/modules/storage/MountHandler.cpp	2006/10/23 18:43:36	1.6
+++ conga/ricci/modules/storage/MountHandler.cpp	2007/08/24 22:06:29	1.7
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2005
+  Copyright Red Hat, Inc. 2005-2007
 
   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
@@ -95,7 +95,7 @@
   
   struct stat st;
   if (stat(path.c_str(), &st)) 
-    throw String("stat(") + path + ") failed";
+    throw String("stat(") + path + ") failed: " + String(strerror(errno));
   if (!S_ISBLK(st.st_mode)) 
     throw path + " is not a block device";
   
@@ -115,7 +115,7 @@
   
   FILE* fstab = setmntent(filename.c_str(), "r");
   if (!fstab)
-    throw String("unable to open ") + filename;
+    throw String("unable to open ") + filename + ": " + String(strerror(errno));
   try {
     while (getmntent_r(fstab, &mntbuff, buff, sizeof(buff)))
       try {
@@ -143,7 +143,7 @@
   
   FILE* file = fopen("/proc/swaps", "r");
   if (!file)
-    throw String("unable to open /proc/swaps");
+    throw String("unable to open /proc/swaps: ") + String(strerror(errno));
   try {
     bool done = false;
     while (!done) {
@@ -157,7 +157,7 @@
 	  continue;
 	} else {
 	  free(ptr);
-	  throw String("error reading /proc/swaps");
+	  throw String("error reading /proc/swaps: ") + String(strerror(errno));
 	}
       }
       String line;
@@ -321,12 +321,12 @@
 	return true;
       else
 	if (mnt != "swap")
-	  throw String("dir already in fstab");
+	  throw mnt + String("is already in fstab");
     }
   
   FILE* fstab = setmntent(fstab_path.c_str(), "r+");
   if (!fstab)
-    throw String("unable to open ") + fstab_path;
+    throw String("unable to open ") + fstab_path + ": " + String(strerror(errno));
   bool success;
   try {
     struct mntent st;
@@ -360,7 +360,7 @@
   bool modified = false;
   FILE* fstab = fopen(fstab_path.c_str(), "r");
   if (!fstab)
-    throw String("unable to open ") + fstab_path;
+    throw String("unable to open ") + fstab_path + ": " + String(strerror(errno));
   try {
     bool done = false;
     while (!done) {
@@ -375,7 +375,7 @@
 	  continue;
 	} else {
 	  free(ptr);
-	  throw String("error reading fstab");
+	  throw String("error reading fstab: ") + String(strerror(errno));
 	}
       }
       try {
@@ -410,10 +410,10 @@
   if (modified) {
     fstab = fopen(fstab_path.c_str(), "w");
     if (!fstab)
-      throw String("unable to open ") + fstab_path;
+      throw String("unable to open ") + fstab_path + " for writing: " + String(strerror(errno));
     try {
       if (!fwrite(buff.c_str(), buff.size(), 1, fstab))
-	throw String("error writing fstab");
+	throw String("error writing fstab: ") + String(strerror(errno));
       while (fclose(fstab) && errno == EINTR)
 	;
     } catch ( ... ) {
@@ -434,7 +434,7 @@
   
   FILE* file = fopen("/proc/filesystems", "r");
   if (!file)
-    throw String("unable to open /proc/filesystems");
+    throw String("unable to open /proc/filesystems: " + String(strerror(errno)));
   try {
     bool done = false;
     while (!done) {
@@ -449,7 +449,7 @@
 	  continue;
 	} else {
 	  free(ptr);
-	  throw String("error reading /proc/filesystems");
+	  throw String("error reading /proc/filesystems: ") + String(strerror(errno));
 	}
       }
       try {
@@ -488,7 +488,7 @@
   
   FILE* fstab = setmntent(filename.c_str(), "r");
   if (!fstab)
-    throw String("unable to open ") + filename;
+    throw String("unable to open ") + filename + ": " + String(strerror(errno));
   try {
     while (getmntent_r(fstab, &mntbuff, buff, sizeof(buff))) {
       String mp(mntbuff.mnt_dir);
@@ -539,14 +539,14 @@
   if (locker_counter == 0) {
     locker_fd = open(fstab_path.c_str(), O_RDWR);
     if (locker_fd == -1)
-      throw String("unable to open fstab");
+      throw String("unable to open fstab: ") + String(strerror(errno));
     int ret;
     while ((ret = flock(locker_fd, LOCK_EX)) && errno == EINTR)
       ;
     if (ret) {
       while (close(locker_fd) == -1 && errno == EINTR)
 	;
-      throw String("unable to flock fstab");
+      throw String("unable to flock fstab: ") + String(strerror(errno));
     }
   }
   
@@ -619,9 +619,9 @@
   MutexLocker l1(mutex);
   
   if (path.empty())
-    throw String("dir path is empty :-/");
+    throw String("dir path is empty");
   if (path[0] != '/')
-    throw String("dir has to be an absolute path");
+    throw String("dir must be an absolute path");
   
   String out, err, bin;
   int status;
@@ -636,5 +636,5 @@
 		     false))
     throw command_not_found_error_msg("mkdir");
   if (status)
-    throw String("creation of ") + path + " failed";
+    throw String("creation of ") + path + " failed: " + err;
 }



                 reply	other threads:[~2007-08-24 22:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070824220630.31374.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.