[DRBD-cvs] svn commit by phil - r2758 - branches/drbd-0.7/user - Improvements to DRBD's device guessing by Iustin Pop.

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Fri Feb 16 12:26:04 CET 2007


Author: phil
Date: 2007-02-16 12:26:03 +0100 (Fri, 16 Feb 2007)
New Revision: 2758

Modified:
   branches/drbd-0.7/user/drbdsetup.c
Log:
Improvements to DRBD's device guessing by Iustin Pop.


Modified: branches/drbd-0.7/user/drbdsetup.c
===================================================================
--- branches/drbd-0.7/user/drbdsetup.c	2007-02-16 11:06:59 UTC (rev 2757)
+++ branches/drbd-0.7/user/drbdsetup.c	2007-02-16 11:26:03 UTC (rev 2758)
@@ -1220,13 +1220,17 @@
   struct stat sb;
   static char dev_name[50];
 
+  if(major==0 && minor==0)
+    return NULL;
+
   device_dir=opendir(dir);
 
   if(!device_dir) goto err_out;
 
   while((dde=readdir(device_dir)))
     {
-      snprintf(dev_name,50,"%s/%s",dir,dde->d_name);
+      if(snprintf(dev_name,50,"%s/%s",dir,dde->d_name)>=50)
+	continue;
       if(stat(dev_name,&sb)) continue;
 
       if(S_ISBLK(sb.st_mode))
@@ -1244,7 +1248,8 @@
 
   while((dde=readdir(device_dir)))
     {
-      snprintf(dev_name,50,"%s/%s",dir,dde->d_name);
+      if(snprintf(dev_name,50,"%s/%s",dir,dde->d_name)>=50)
+	continue;
       if(stat(dev_name,&sb)) continue;
 
       if(!strcmp(dde->d_name,".")) continue;
@@ -1257,11 +1262,8 @@
 	{
 	  char subdir[50];
 
-	  if(snprintf(subdir,50,"%s/%s",dir,dde->d_name)==49)
-	    { /* recursion is too deep */
-	      strcpy(dev_name,"can not guess name");
-	      return dev_name;
-	    }
+	  if(snprintf(subdir,50,"%s/%s",dir,dde->d_name)>=50)
+	    continue;
 
 	  if(guess_dev_name(subdir,major,minor)) return dev_name;
 	}



More information about the drbd-cvs mailing list