From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Fri, 23 Sep 2005 12:13:25 -0400 From: Russ Cox To: ISHWAR RATTAN Subject: Re: [9fans] deleting files? In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: Cc: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 90cfd69a-ead0-11e9-9d60-3106f5b1d025 > The out put of > > ls | grep H.*test1.c | xd -b -c > is > > 0000000 48 ef bf bd 74 65 73 74 31 2e 63 0a > 0 H ef bf bd t e s t 1 . c \n > 000000c Bad UTF got into the file system some how, and so ls is showing you an FFFD (RuneError) instead. (Now I understand what you meant by [?].) It looks like fossil doesn't check aggressively enough to find bad UTF before using the name. We should fix this, but until then, you can use the program below, fixbadutf, to rename the troublesome files. Russ #include #include void usage(void) { =09fprint(2, "usage: fixbadutf [dir]\n"); =09exits("usage"); } int isbadutf(char *s) { =09Rune r; =09int n; =09r =3D Runeerror; =09for(; *s; s+=3Dn){ =09=09n =3D chartorune(&r, s); =09=09if(r =3D=3D Runeerror && n =3D=3D 1) =09=09=09return 1; =09} =09return 0; } char* mkgoodname(char *name) { =09char *gname, *p, *s; =09int i, n; =09Rune r; =09gname =3D malloc(strlen(name)+20); =09if(gname =3D=3D nil) =09=09sysfatal("out of memory"); =09s =3D gname; =09p =3D name; =09for(; *p; p+=3Dn){ =09=09n =3D chartorune(&r, p); =09=09if(r =3D=3D Runeerror && n =3D=3D 1) =09=09=09*s++ =3D '?'; =09=09else{ =09=09=09for(i=3D0; i 1) =09=09usage(); =09if(argc =3D=3D 1) =09=09dir =3D argv[0]; =09else =09=09dir =3D "."; =09if((fd =3D open(dir, OREAD)) < 0) =09=09sysfatal("open %s: %r", dir); =09errors =3D nil; =09n =3D dirreadall(fd, &d); =09for(i=3D0; i %s\n", oldname, newname); =09=09=09if(dirwstat(oldname, &xd) < 0){ =09=09=09=09fprint(2, "rename %s to %s: %r\n", oldname, newname); =09=09=09=09errors =3D "errors"; =09=09=09} =09=09=09free(oldname); =09=09=09free(newname); =09=09} =09} =09exits(errors); }