* Set the default value of --modify-window to 1 on Cygwin. (Lapo
Luchini)
+ * Open config files in text mode when O_TEXT is defined. This helps
+ on Cygwin when the config files are on a filesystem that are mounted
+ in binary mode. (Ville Herva)
+
* Ignore errors from chmod when -p/-a/--preserve-perms is not set.
(Dave Dykstra)
if (!fname || !*fname) return 0;
- fd = open(fname,O_RDONLY);
+ fd = open(fname,O_RDONLY | O_TEXT);
if (fd == -1) return 0;
if (do_stat(fname, &st) == -1) {
if (!filename) return NULL;
- if ( (fd=open(filename,O_RDONLY)) == -1) {
+ if ( (fd=open(filename,O_RDONLY | O_TEXT)) == -1) {
rsyserr(FERROR, errno, "could not open password file \"%s\"",filename);
if (envpw) rprintf(FERROR,"falling back to RSYNC_PASSWORD environment variable.\n");
return NULL;
motd = lp_motd_file();
if (motd && *motd) {
- FILE *f = fopen(motd,"r");
+ FILE *f = fopen(motd,"r" O_TEXT_STR);
while (f && !feof(f)) {
int len = fread(line, 1, sizeof(line)-1, f);
if (len > 0) {
char line[MAXPATHLEN];
if (strcmp(fname, "-")) {
- f = fopen(fname,"r");
+ f = fopen(fname,"r" O_TEXT_STR);
} else {
- f = fdopen(0, "r");
+ f = fdopen(0, "r" O_TEXT_STR);
}
if (!f) {
if (fatal) {
return( NULL );
}
- OpenedFile = fopen( FileName, "r" );
+ OpenedFile = fopen( FileName, "r" O_TEXT_STR );
if( NULL == OpenedFile )
{
rprintf(FERROR,"rsync: unable to open configuration file \"%s\": %s\n",
#define inet_ntoa rep_inet_ntoa
#endif
+/* Compatibility defines so that platforms that don't distinguish between
+ * text and binary files (like Cygwin does) can use the same code. */
+#ifndef O_TEXT
+#define O_TEXT 0
+#define O_TEXT_STR ""
+#else
+#define O_TEXT_STR "t"
+#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#define O_BINARY_STR ""
+#else
+#define O_BINARY_STR "b"
+#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *d, const char *s, size_t bufsize);
if (dry_run) return -1;
CHECK_RO
}
-#ifdef O_BINARY
+
/* for Windows */
flags |= O_BINARY;
-#endif
+
/* some systems can't handle a double / */
if (pathname[0] == '/' && pathname[1] == '/') pathname++;