Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/0909/2

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Close fdf before removing it, to work around Steve Simon's cifs.
Making spacing more consistent too.
 [rsc] --rw-rw-r-- M 383570 glenda sys 4241 Sep  9 11:01 sys/src/cmd/mv.c
	/n/sourcesdump/2005/0909/plan9/sys/src/cmd/mv.c:37,43 - 
	/n/sourcesdump/2005/0910/plan9/sys/src/cmd/mv.c:37,43
	  	}
	  	failed = 0;
	  	for(i=1; i < argc-1; i++)
	- 		if (mv(argv[i], todir, toelem) < 0)
	+ 		if(mv(argv[i], todir, toelem) < 0)
	  			failed++;
	  	if(failed)
	  		exits("failure");
	/n/sourcesdump/2005/0909/plan9/sys/src/cmd/mv.c:117,135 - 
	/n/sourcesdump/2005/0910/plan9/sys/src/cmd/mv.c:117,134
	  		close(fdf);
	  		return -1;
	  	}
	- 	if ((stat = copy1(fdf, fdt, fromname, toname)) != -1) {
	+ 	stat = copy1(fdf, fdt, fromname, toname);
	+ 	close(fdf);
	+ 	if(stat >= 0){
	  		nulldir(&null);
	  		null.mtime = dirb->mtime;
	  		null.mode = dirb->mode;
	  		dirfwstat(fdt, &null);	/* ignore errors; e.g. user none always fails */
	- 		if (remove(fromname) < 0) {
	+ 		if(remove(fromname) < 0){
	  			fprint(2, "mv: can't remove %s: %r\n", fromname);
	- 			close(fdf);
	- 			close(fdt);
	- 			return -1;
	+ 			stat = -1;
	  		}
	  	}
	- 	close(fdf);
	  	close(fdt);
	  	return stat;
	  }
	/n/sourcesdump/2005/0909/plan9/sys/src/cmd/mv.c:140,158 - 
	/n/sourcesdump/2005/0910/plan9/sys/src/cmd/mv.c:139,157
	  	char buf[8192];
	  	long n, n1;
	  
	- 	for(;;) {
	+ 	for(;;){
	  		n = read(fdf, buf, sizeof buf);
	- 		if(n >= 0) {
	+ 		if(n >= 0){
	  			if(n == 0)
	  				break;
	  			n1 = write(fdt, buf, n);
	- 			if(n1 != n) {
	+ 			if(n1 != n){
	  				fprint(2, "mv: error writing %s: %r\n", to);
	  				return -1;
	  			}
	  		}
	  	}
	- 	if(n < 0) {
	+ 	if(n < 0){
	  		fprint(2, "mv: error reading %s: %r\n", from);
	  		return -1;
	  	}
 [sys] --rwxrwxr-x M 383570 glenda sys 65489 Sep  9 23:08 386/bin/mv
	/sys/src/cmd/mv.c:mv


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.