Am 21.09.2015 um 23:29 schrieb Jan Kandziora:
> Am 21.09.2015 um 07:28 schrieb Sven Giermann:
>> Well, I would like to...
>> But I've no experience in debugging on linux, so I had no luck to get it
>> running. My "solution" now is to switch all I/O ports to pure 1-Wire, but I
>> would still be interested in getting this to work!
>>
Sven, Paul, and all who are interested:

I think I have this finally fixed. Please test the latest version from
the git archive. I've tested it, it works and it seems my changes have
no bad side effects. The mutex crash has vanished, too.


Paul, if you think it is fine I would suggest to release v3.1p1.


And, for completeness, I have attached patch 3/3.

Kind regards

        Jan

diff --git a/module/owlib/src/c/ow_get.c b/module/owlib/src/c/ow_get.c
index 26fc2f6..3689769 100644
--- a/module/owlib/src/c/ow_get.c
+++ b/module/owlib/src/c/ow_get.c
@@ -38,13 +38,15 @@ static void getdircallback( void * v, const struct parsedname * const pn_entry )
 	}
 }
 
-static void getdir( struct charblob * cb, struct one_wire_query * owq ) 
-{  
-	if ( FS_dir( getdircallback, cb, PN(owq) ) != 0 ) {
+static int getdir( struct charblob * cb, struct one_wire_query * owq ) 
+{
+	int ret = 0;
+	if ( (ret = FS_dir( getdircallback, cb, PN(owq) )) != 0 ) {
 		CharblobClear( cb ) ;
 	} else if ( CharblobLength(cb) == 0 ) {
 		CharblobAddChar( '\0', cb) ;
 	}
+	return ret;
 }
 
 static char * copy_buffer( char * data, int size )
@@ -83,19 +85,42 @@ SIZE_OR_ERROR FS_get(const char *path, char **return_buffer, size_t * buffer_len
 		return -ENOENT;
 	}
 
-	if ( IsDir( PN(owq) ) ) { /* A directory of some kind */
+	// Check for known type.
+	if ( (PN(owq)->selected_filetype) != NO_FILETYPE ) { 
+		// local owlib knows the type. 
+		if ( IsDir( PN(owq) ) ) { /* A directory of some kind */
+			struct charblob cb ;
+			CharblobInit(&cb) ;
+			getdir( &cb, owq ) ;
+			size = CharblobLength(&cb) ;
+			*return_buffer = copy_buffer( CharblobData(&cb), size ) ;
+			CharblobClear(&cb) ;
+		} else { /* A regular file  -- so read */
+			if ( GOOD(OWQ_allocate_read_buffer(owq)) ) { // make the space in the buffer
+				size = FS_read_postparse(owq) ;
+				*return_buffer = copy_buffer( OWQ_buffer(owq), size ) ;
+			}
+		}
+	} else {
+		// local owlib doesn't know the type.
 		struct charblob cb ;
 		CharblobInit(&cb) ;
-		getdir( &cb, owq ) ;
-		size = CharblobLength(&cb) ;
-		*return_buffer = copy_buffer( CharblobData(&cb), size ) ;
-		CharblobClear( &cb ) ;
-	} else { /* A regular file  -- so read */
-		if ( GOOD(OWQ_allocate_read_buffer(owq)) ) { // make the space in the buffer
-			size = FS_read_postparse(owq) ;
-			*return_buffer = copy_buffer( OWQ_buffer(owq), size ) ;
+
+		// Try directory first.
+		if (getdir( &cb, owq ) != -ENOTDIR) {
+			// Is a directory.
+			size = CharblobLength(&cb) ;
+			*return_buffer = copy_buffer( CharblobData(&cb), size ) ;
+		} else {
+			// Is not a directory. Try file.
+			if ( GOOD(OWQ_allocate_read_buffer(owq)) ) { // make the space in the buffer
+				size = FS_read_postparse(owq) ;
+				*return_buffer = copy_buffer( OWQ_buffer(owq), size ) ;
+			}
 		}
-	}
+		CharblobClear(&cb) ;
+	}	
+
 	// the buffer is allocated by getdir or getval
 	OWQ_destroy(owq);
 
diff --git a/module/owlib/src/c/ow_parseinput.c b/module/owlib/src/c/ow_parseinput.c
index 220dacb..7294369 100644
--- a/module/owlib/src/c/ow_parseinput.c
+++ b/module/owlib/src/c/ow_parseinput.c
@@ -80,7 +80,7 @@ ZERO_OR_ERROR OWQ_parse_input(struct one_wire_query *owq)
 	default:
 		// Sort out locally unknown filetype.
 		if (OWQ_pn(owq).selected_filetype == NO_FILETYPE) {
-			return -ENOENT;
+			return FS_input_ascii(owq);
 		}
 
 		// Switch by known filetype.
diff --git a/module/owlib/src/c/ow_parsename.c b/module/owlib/src/c/ow_parsename.c
index b0a6c1b..973ff24 100644
--- a/module/owlib/src/c/ow_parsename.c
+++ b/module/owlib/src/c/ow_parsename.c
@@ -751,8 +751,8 @@ static enum parse_enum Parse_Property(char *filename, struct parsedname *pn)
 
 	// Special case for remote device. Use distant data
 	if ( pdev == &RemoteDevice ) {
-		// remote device, no known sn, can't handle a property
-		return parse_error ;
+		// remote device, no known sn, handle property in server.
+		return parse_done ;
 	}
 
 	// separate filename.dot
diff --git a/module/owlib/src/c/ow_read.c b/module/owlib/src/c/ow_read.c
index cd8efcd..8324544 100644
--- a/module/owlib/src/c/ow_read.c
+++ b/module/owlib/src/c/ow_read.c
@@ -68,11 +68,6 @@ SIZE_OR_ERROR FS_read_postparse(struct one_wire_query *owq)
 	struct parsedname *pn = PN(owq);
 	SIZE_OR_ERROR read_or_error;
 
-	// ServerRead jumps in here, perhaps with non-file entry
-	if (pn->selected_device == NO_DEVICE || pn->selected_filetype == NO_FILETYPE) {
-		return -EISDIR;
-	}
-
 	/* Normal read. Try three times */
 	LEVEL_DEBUG("%s", pn->path);
 	STATLOCK;
@@ -83,7 +78,12 @@ SIZE_OR_ERROR FS_read_postparse(struct one_wire_query *owq)
 	/* First try */
 	STAT_ADD1(read_tries[0]);
 
-	read_or_error = (pn->type == ePN_real) ? FS_read_real(owq) : FS_r_virtual(owq);
+	// ServerRead jumps in here, perhaps with non-file entry
+	if (pn->selected_device == NO_DEVICE || pn->selected_filetype == NO_FILETYPE) {
+		read_or_error = FS_r_given_bus(owq);
+	} else {
+		read_or_error = (pn->type == ePN_real) ? FS_read_real(owq) : FS_r_virtual(owq);
+	}
 
 	STATLOCK;
 	if (read_or_error >= 0) {
diff --git a/module/owlib/src/c/ow_write.c b/module/owlib/src/c/ow_write.c
index 2b5817a..8db2a6f 100644
--- a/module/owlib/src/c/ow_write.c
+++ b/module/owlib/src/c/ow_write.c
@@ -91,7 +91,7 @@ SIZE_OR_ERROR FS_write_postparse(struct one_wire_query *owq)
 		return -EROFS;			// read-only invokation
 	}
 
-	if (IsDir(pn)) {
+	if (IsDir(pn) && !(BusIsServer(pn->selected_connection))) {
 		LEVEL_DEBUG("Attempt to write to a directory.");
 		return -EISDIR;			// not a file
 	}
------------------------------------------------------------------------------
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to