- if(iflg) {
- printf("rm: remove %s? ", arg);
- if(!yes())
- return;
- }
- else if(!fflg) {
- if ((buf.st_mode&S_IFMT) != S_IFLNK && access(arg, 02) < 0) {
- printf("rm: override protection %o for %s? ", buf.st_mode&0777, arg);
- if(!yes())
- return;
- }
- }
- if(unlink(arg) && (fflg==0 || iflg)) {
- printf("rm: %s not removed\n", arg);
- ++errcode;
+check(path, name, sp)
+ char *path, *name;
+ struct stat *sp;
+{
+ register int first, ch;
+ char modep[15], *user_from_uid(), *group_from_gid();
+
+ /* Check -i first. */
+ if (iflag)
+ (void)fprintf(stderr, "remove %s? ", path);
+ else {
+ /*
+ * If it's not a symbolic link and it's unwritable and we're
+ * talking to a terminal, ask. Symbolic links are excluded
+ * because their permissions are meaningless.
+ */
+ if (S_ISLNK(sp->st_mode) || !stdin_ok || !access(name, W_OK))
+ return(1);
+ strmode(sp->st_mode, modep);
+ (void)fprintf(stderr, "override %s%s%s/%s for %s? ",
+ modep + 1, modep[9] == ' ' ? "" : " ",
+ user_from_uid(sp->st_uid, 0),
+ group_from_gid(sp->st_gid, 0), path);