Patchwork spu-tools: Handle chdir return code

login
register
mail settings
Submitter Andre Detsch
Date Dec. 9, 2008, 6:58 p.m.
Message ID <200812091658.17374.adetsch@br.ibm.com>
Download mbox | patch
Permalink /patch/13028/
State Not Applicable
Headers show

Comments

Andre Detsch - Dec. 9, 2008, 6:58 p.m.
Handle chdir return code to avoid trying to access
tid, phys-id and stat files in the wrong location.

Signed-off-by: Andre Detsch <adetsch@br.ibm.com>

--
Dirk, can you please apply it to SVN?

Thanks,
D. Herrendoerfer - Dec. 10, 2008, 3:10 p.m.
Added, thank you very much !

D. Herrendoerfer

On Tue, 2008-12-09 at 16:58 -0200, Andre Detsch wrote:
> Handle chdir return code to avoid trying to access
> tid, phys-id and stat files in the wrong location.
> 
> Signed-off-by: Andre Detsch <adetsch@br.ibm.com>
> 
> --
> Dirk, can you please apply it to SVN?
> 
> Thanks,
> 
> Index: spu-tools/src/ctx-info.c
> ===================================================================
> --- spu-tools.orig/src/ctx-info.c
> +++ spu-tools/src/ctx-info.c
> @@ -340,7 +340,9 @@ process_ctx_entry(struct dirent *entry, 
>  		sprintf(buf, "%s/%s/%s", SPUFS_PATH, gang_name, entry->d_name);
>  	else
>  		sprintf(buf, "%s/%s", SPUFS_PATH, entry->d_name);
> -	chdir(buf);
> +
> +	if (chdir(buf))
> +		return 0;
>  
>  	fp = fopen("tid", "r");
>  	if (fp) {
> Index: spu-tools/src/ChangeLog
> ===================================================================
> --- spu-tools.orig/src/ChangeLog
> +++ spu-tools/src/ChangeLog
> @@ -1,3 +1,7 @@
> +2008-12-09 Andre Detsch <adetsch@br.ibm.com>
> +	* ctx-info.c: Handle chdir return code, to avoid trying to access
> +	tid, phys-id and stat files in the wrong location.
> +
>  2008-09-02 Andre Detsch <adetsch@br.ibm.com>
>  	* ctx-info.c: Enhanced PID retrieval.
>  
> _______________________________________________
> cbe-oss-dev mailing list
> cbe-oss-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/cbe-oss-dev

Patch

Index: spu-tools/src/ctx-info.c
===================================================================
--- spu-tools.orig/src/ctx-info.c
+++ spu-tools/src/ctx-info.c
@@ -340,7 +340,9 @@  process_ctx_entry(struct dirent *entry, 
 		sprintf(buf, "%s/%s/%s", SPUFS_PATH, gang_name, entry->d_name);
 	else
 		sprintf(buf, "%s/%s", SPUFS_PATH, entry->d_name);
-	chdir(buf);
+
+	if (chdir(buf))
+		return 0;
 
 	fp = fopen("tid", "r");
 	if (fp) {
Index: spu-tools/src/ChangeLog
===================================================================
--- spu-tools.orig/src/ChangeLog
+++ spu-tools/src/ChangeLog
@@ -1,3 +1,7 @@ 
+2008-12-09 Andre Detsch <adetsch@br.ibm.com>
+	* ctx-info.c: Handle chdir return code, to avoid trying to access
+	tid, phys-id and stat files in the wrong location.
+
 2008-09-02 Andre Detsch <adetsch@br.ibm.com>
 	* ctx-info.c: Enhanced PID retrieval.