From 6baf1702ab92deb2aaf850b8dbe19a6f8c42bf03 Mon Sep 17 00:00:00 2001 From: IgnorantGuru Date: Tue, 28 Apr 2015 07:10:59 -0600 Subject: [PATCH] convert mtab literal ipv6 cifs url for unmount from mountpoint #46 --- src/udevil.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/udevil.c b/src/udevil.c index ab1eae3..bf74ce4 100644 --- a/src/udevil.c +++ b/src/udevil.c @@ -1391,7 +1391,7 @@ static char* get_ip( const char* hostname ) struct addrinfo *result; char* ret = NULL; - if ( !hostname ) + if ( !( hostname && hostname[0] ) ) return NULL; memset( &hints, 0, sizeof( struct addrinfo ) ); @@ -3005,7 +3005,27 @@ _get_type: { if ( g_strcmp0( data->device_file, "tmpfs" ) && g_strcmp0( data->device_file, "ramfs" ) ) + { + // found device file of mountpoint + if ( g_str_has_prefix( data->device_file, "//" ) && + strchr( data->device_file, ':' ) && + data->device_file[2] != '[' ) + { + // unmounting mountpoint of cifs with ipv6 literal + // cifs ipv6 mtab format: //::1/share + // add literal brackets: //[::1]/share + str = g_strdup( data->device_file + 2 ); + if ( str2 = strchr( str, '/' ) ) + str2[0] = '\0'; + g_free( data->device_file ); + data->device_file = g_strdup_printf( "//[%s]%s%s", + str, + str2 ? "/" : "", + str2 ? str2 + 1 : "" ); + g_free( str ); + } goto _get_type; + } } else {