- if (strcmp(source, target) == 0) {
- fprintf(stderr, "mv: ?? source == target, source exists and target doesnt\n");
- return(1);
- }
- p = dname(source);
- if (!strcmp(p, DOT) || !strcmp(p, DOTDOT) || !strcmp(p, "") || p[strlen(p)-1]=='/') {
- fprintf(stderr, "mv: cannot rename %s\n", p);
- return(1);
- }
- if (stat(pname(source), &s1) < 0 || stat(pname(target), &s2) < 0) {
- fprintf(stderr, "mv: cannot locate parent\n");
- return(1);
- }
- if (access(pname(target), 2) < 0) {
- fprintf(stderr, "mv: no write access to %s\n", pname(target));
- return(1);
- }
- if (access(pname(source), 2) < 0) {
- fprintf(stderr, "mv: no write access to %s\n", pname(source));
- return(1);
- }
- if (s1.st_dev != s2.st_dev) {
- fprintf(stderr, "mv: cannot move directories across devices\n");
- return(1);
- }
- if (s1.st_ino != s2.st_ino) {
- char dst[MAXN+5];