diff options
| author | Eli Zaretskii | 2005-07-02 08:16:24 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2005-07-02 08:16:24 +0000 |
| commit | b016179b58efb59ba177cafdaea6bdee2d23e0e0 (patch) | |
| tree | 24307eca53233481030b83499ccacfe177b71bf3 /src | |
| parent | 7d0c69befb28dfe1b2fe1745de7a7ba7dea905ef (diff) | |
| download | emacs-b016179b58efb59ba177cafdaea6bdee2d23e0e0.tar.gz emacs-b016179b58efb59ba177cafdaea6bdee2d23e0e0.zip | |
(Fcopy_file): Rearrange the code that calls fchown and
fchmod so that chmod doesn't get called on MSDOS before the file
is closed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/fileio.c | 37 |
2 files changed, 26 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 950a0414047..81610b5e646 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2005-07-02 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * fileio.c (Fcopy_file): Rearrange the code that calls fchown and | ||
| 4 | fchmod so that chmod doesn't get called on MSDOS before the file | ||
| 5 | is closed. | ||
| 6 | |||
| 1 | 2005-07-01 Jason Rumney <jasonr@gnu.org> | 7 | 2005-07-01 Jason Rumney <jasonr@gnu.org> |
| 2 | 8 | ||
| 3 | * w32term.c (cleartype_active): New flag for enabling sub-pixel | 9 | * w32term.c (cleartype_active): New flag for enabling sub-pixel |
diff --git a/src/fileio.c b/src/fileio.c index c4a267f4ea1..898dc0705d2 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2521,7 +2521,7 @@ uid and gid of FILE to NEWNAME. */) | |||
| 2521 | copyable by us. */ | 2521 | copyable by us. */ |
| 2522 | input_file_statable_p = (fstat (ifd, &st) >= 0); | 2522 | input_file_statable_p = (fstat (ifd, &st) >= 0); |
| 2523 | 2523 | ||
| 2524 | #if !defined (DOS_NT) || __DJGPP__ > 1 | 2524 | #if !defined (MSDOS) || __DJGPP__ > 1 |
| 2525 | if (out_st.st_mode != 0 | 2525 | if (out_st.st_mode != 0 |
| 2526 | && st.st_dev == out_st.st_dev && st.st_ino == out_st.st_ino) | 2526 | && st.st_dev == out_st.st_dev && st.st_ino == out_st.st_ino) |
| 2527 | { | 2527 | { |
| @@ -2574,25 +2574,16 @@ uid and gid of FILE to NEWNAME. */) | |||
| 2574 | report_file_error ("I/O error", Fcons (newname, Qnil)); | 2574 | report_file_error ("I/O error", Fcons (newname, Qnil)); |
| 2575 | immediate_quit = 0; | 2575 | immediate_quit = 0; |
| 2576 | 2576 | ||
| 2577 | /* Preserve the owner and group, if requested. */ | 2577 | #ifndef MSDOS |
| 2578 | if (input_file_statable_p && ! NILP (preserve_uid_gid)) | 2578 | /* Preserve the original file modes, and if requested, also its |
| 2579 | fchown (ofd, st.st_uid, st.st_gid); | 2579 | owner and group. */ |
| 2580 | |||
| 2581 | if (input_file_statable_p) | 2580 | if (input_file_statable_p) |
| 2582 | { | 2581 | { |
| 2583 | #ifndef MSDOS | 2582 | if (! NILP (preserve_uid_gid)) |
| 2583 | fchown (ofd, st.st_uid, st.st_gid); | ||
| 2584 | fchmod (ofd, st.st_mode & 07777); | 2584 | fchmod (ofd, st.st_mode & 07777); |
| 2585 | #else /* MSDOS */ | ||
| 2586 | #if defined (__DJGPP__) && __DJGPP__ > 1 | ||
| 2587 | /* In DJGPP v2.0 and later, fstat usually returns true file mode bits, | ||
| 2588 | and if it can't, it tells so. Otherwise, under MSDOS we usually | ||
| 2589 | get only the READ bit, which will make the copied file read-only, | ||
| 2590 | so it's better not to chmod at all. */ | ||
| 2591 | if ((_djstat_flags & _STFAIL_WRITEBIT) == 0) | ||
| 2592 | chmod (SDATA (encoded_newname), st.st_mode & 07777); | ||
| 2593 | #endif /* DJGPP version 2 or newer */ | ||
| 2594 | #endif /* MSDOS */ | ||
| 2595 | } | 2585 | } |
| 2586 | #endif /* not MSDOS */ | ||
| 2596 | 2587 | ||
| 2597 | /* Closing the output clobbers the file times on some systems. */ | 2588 | /* Closing the output clobbers the file times on some systems. */ |
| 2598 | if (emacs_close (ofd) < 0) | 2589 | if (emacs_close (ofd) < 0) |
| @@ -2614,7 +2605,19 @@ uid and gid of FILE to NEWNAME. */) | |||
| 2614 | } | 2605 | } |
| 2615 | 2606 | ||
| 2616 | emacs_close (ifd); | 2607 | emacs_close (ifd); |
| 2617 | #endif /* WINDOWSNT */ | 2608 | |
| 2609 | #if defined (__DJGPP__) && __DJGPP__ > 1 | ||
| 2610 | if (input_file_statable_p) | ||
| 2611 | { | ||
| 2612 | /* In DJGPP v2.0 and later, fstat usually returns true file mode bits, | ||
| 2613 | and if it can't, it tells so. Otherwise, under MSDOS we usually | ||
| 2614 | get only the READ bit, which will make the copied file read-only, | ||
| 2615 | so it's better not to chmod at all. */ | ||
| 2616 | if ((_djstat_flags & _STFAIL_WRITEBIT) == 0) | ||
| 2617 | chmod (SDATA (encoded_newname), st.st_mode & 07777); | ||
| 2618 | } | ||
| 2619 | #endif /* DJGPP version 2 or newer */ | ||
| 2620 | #endif /* not WINDOWSNT */ | ||
| 2618 | 2621 | ||
| 2619 | /* Discard the unwind protects. */ | 2622 | /* Discard the unwind protects. */ |
| 2620 | specpdl_ptr = specpdl + count; | 2623 | specpdl_ptr = specpdl + count; |