[linux-cifs-client] Re: patch for mount.cifs

Steve French smfrench at austin.rr.com
Mon Oct 11 01:10:59 GMT 2004


Thanks for pointing this out -
I did a slightly different implementation which should be equivalent for 
your purposes.  Let me know if you see any problems and if not I will 
check it into samba's mount.cifs.c

--- /home/sfrench/mount.cifs.c.org    2004-10-10 10:47:50.000000000 -0500
+++ mount.cifs.c    2004-10-10 18:50:19.139066912 -0500
@@ -344,6 +344,8 @@
             if (!value || !*value) {
                 printf("target ip address argument missing");
             } else if (strnlen(value, 35) < 35) {
+                if(verboseflag)
+                    printf("ip address %s override specified\n",value);
                 got_ip = 1;
             } else {
                 printf("ip address too long\n");
@@ -553,15 +555,20 @@
                 (share = strchr(unc_name,'\\'))) {
                 *share = 0;  /* temporarily terminate the string */
                 share += 1;
-                host_entry = gethostbyname(unc_name);
+                if(got_ip == 0) {
+                    host_entry = gethostbyname(unc_name);
+                }
                 *(share - 1) = '/'; /* put the slash back */
-/*                rc = getipnodebyname(unc_name, AF_INET, AT_ADDRCONFIG 
,&rc);*/
+                if(got_ip) {
+                    if(verboseflag)
+                        printf("ip address specified explicitly\n");
+                    return 0;
+                }
                 if(host_entry == NULL) {
                     printf("mount error: could not find target server. 
TCP name %s not found ", unc_name);
                     printf(" rc = %d\n",rc);
                     return 0;
-                }
-                else {
+                } else {
                     /* BB should we pass an alternate version of the 
share name as Unicode */
                     /* BB what about ipv6? BB */
                     /* BB add retries with alternate servers in list */
@@ -767,12 +774,15 @@
         get_password_from_file(0, getenv("PASSWD_FILE"));
     }
 
+        if (orgoptions && parse_options(orgoptions, &flags))
+                return -1;
+   
     ipaddr = parse_server(&share_name);
-    if(ipaddr == NULL)
+    if((ipaddr == NULL) && (got_ip == 0)) {
+        printf("No ip address specified and hostname not found\n");
         return -1;
+    }
    
-    if (orgoptions && parse_options(orgoptions, &flags))
-        return -1;
 
     /* BB save off path and pop after mount returns? */
     resolved_path = malloc(PATH_MAX+1);


I also ran Linus's "sparse" syntax parsing utility on the mount.cifs.c 
and will be checking in an updated version of mount.cifs.c that removes 
these minor warnings.





More information about the linux-cifs-client mailing list