From: Jim Meyering Date: Sat, 15 Sep 2001 12:46:05 +0000 (+0000) Subject: (UNWRITABLE): Define (factored out of copy_internal). X-Git-Tag: TEXTUTILS-2_0_15~102 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e1e70abfabc69205aa2572a07316256fab4ce072;p=thirdparty%2Fcoreutils.git (UNWRITABLE): Define (factored out of copy_internal). (copy_internal): Use UNWRITABLE. --- diff --git a/src/copy.c b/src/copy.c index ae9d6ad1d4..c3135ab879 100644 --- a/src/copy.c +++ b/src/copy.c @@ -49,6 +49,11 @@ #define SAME_GROUP(A, B) ((A).st_gid == (B).st_gid) #define SAME_OWNER_AND_GROUP(A, B) (SAME_OWNER (A, B) && SAME_GROUP (A, B)) +#define UNWRITABLE(File_name, File_mode) \ + ( /* euidaccess is not meaningful for symlinks */ \ + ! S_ISLNK (File_mode) \ + && euidaccess (File_name, W_OK) != 0) + struct dir_list { struct dir_list *parent; @@ -696,18 +701,15 @@ copy_internal (const char *src_path, const char *dst_path, if (x->interactive == I_ALWAYS_NO) { - if (! S_ISLNK (dst_sb.st_mode) - && euidaccess (dst_path, W_OK) != 0) + if (UNWRITABLE (dst_path, dst_sb.st_mode)) { do_move = 0; } } else if (x->interactive == I_ASK_USER || (x->interactive == I_UNSPECIFIED - && (x->stdin_tty - /* euidaccess is not meaningful for symlinks */ - && ! S_ISLNK (dst_sb.st_mode) - && euidaccess (dst_path, W_OK) != 0))) + && x->stdin_tty + && UNWRITABLE (dst_path, dst_sb.st_mode))) { overwrite_prompt (dst_path, &dst_sb); if (!yesno ())