Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

syscall.c File Reference

Syscall wrappers to ensure that nothing gets done in dry_run mode and to handle system peculiarities. More...

Go to the source code of this file.

Functions

int do_unlink (char *fname)
int do_symlink (char *fname1, char *fname2)
int do_link (char *fname1, char *fname2)
int do_lchown (const char *path, uid_t owner, gid_t group)
int do_mknod (char *pathname, mode_t mode, dev_t dev)
int do_rmdir (char *pathname)
int do_open (char *pathname, int flags, mode_t mode)
int do_chmod (const char *path, mode_t mode)
int do_rename (char *fname1, char *fname2)
void trim_trailing_slashes (char *name)
int do_mkdir (char *fname, mode_t mode)
int do_mkstemp (char *template, mode_t perms)
int do_stat (const char *fname, STRUCT_STAT *st)
int do_lstat (const char *fname, STRUCT_STAT *st)
int do_fstat (int fd, STRUCT_STAT *st)
OFF_T do_lseek (int fd, OFF_T offset, int whence)
void * do_mmap (void *start, int len, int prot, int flags, int fd, OFF_T offset)
char * d_name (struct dirent *di)

Variables

int dry_run
int read_only
int list_only


Detailed Description

Syscall wrappers to ensure that nothing gets done in dry_run mode and to handle system peculiarities.

Definition in file syscall.c.


Function Documentation

int do_unlink char *    fname
 

Definition at line 35 of file syscall.c.

Referenced by _exit_cleanup(), finish_transfer(), keep_backup(), robust_move(), and robust_unlink().

00036 {
00037         if (dry_run) return 0;
00038         CHECK_RO
00039         return unlink(fname);
00040 }

int do_symlink char *    fname1,
char *    fname2
 

Definition at line 42 of file syscall.c.

Referenced by keep_backup(), and recv_generator().

00043 {
00044         if (dry_run) return 0;
00045         CHECK_RO
00046         return symlink(fname1, fname2);
00047 }

int do_link char *    fname1,
char *    fname2
 

Definition at line 50 of file syscall.c.

Referenced by hard_link_one().

00051 {
00052         if (dry_run) return 0;
00053         CHECK_RO
00054         return link(fname1, fname2);
00055 }

int do_lchown const char *    path,
uid_t    owner,
gid_t    group
 

Definition at line 58 of file syscall.c.

Referenced by make_bak_dir(), and set_perms().

00059 {
00060         if (dry_run) return 0;
00061         CHECK_RO
00062         return lchown(path, owner, group);
00063 }

int do_mknod char *    pathname,
mode_t    mode,
dev_t    dev
 

Definition at line 66 of file syscall.c.

Referenced by keep_backup(), and recv_generator().

00067 {
00068         if (dry_run) return 0;
00069         CHECK_RO
00070         return mknod(pathname, mode, dev);
00071 }

int do_rmdir char *    pathname
 

Definition at line 74 of file syscall.c.

Referenced by delete_file(), delete_one(), and keep_backup().

00075 {
00076         if (dry_run) return 0;
00077         CHECK_RO
00078         return rmdir(pathname);
00079 }

int do_open char *    pathname,
int    flags,
mode_t    mode
 

Definition at line 81 of file syscall.c.

Referenced by copy_file(), daemon_main(), do_mkstemp(), file_checksum(), read_batch_csums_file(), read_batch_delta_file(), read_batch_flist_file(), recv_files(), recv_generator(), send_files(), write_batch_argvs_file(), write_batch_csums_file(), write_batch_delta_file(), and write_batch_flist_file().

00082 {
00083         if (flags != O_RDONLY) {
00084             if (dry_run) return -1;
00085             CHECK_RO
00086         }
00087 #ifdef O_BINARY
00088         /* for Windows */
00089         flags |= O_BINARY;
00090 #endif
00091         /* some systems can't handle a double / */
00092         if (pathname[0] == '/' && pathname[1] == '/') pathname++;
00093 
00094         return open(pathname, flags, mode);
00095 }

int do_chmod const char *    path,
mode_t    mode
 

Definition at line 98 of file syscall.c.

Referenced by make_bak_dir(), and set_perms().

00099 {
00100         if (dry_run) return 0;
00101         CHECK_RO
00102         return chmod(path, mode);
00103 }

int do_rename char *    fname1,
char *    fname2
 

Definition at line 106 of file syscall.c.

Referenced by make_simple_backup(), robust_rename(), and robust_unlink().

00107 {
00108         if (dry_run) return 0;
00109         CHECK_RO
00110         return rename(fname1, fname2);
00111 }

void trim_trailing_slashes char *    name
 

Definition at line 114 of file syscall.c.

Referenced by do_mkdir(), and main().

00115 {
00116         int l;
00117         /* Some BSD systems cannot make a directory if the name
00118          * contains a trailing slash.
00119          * <http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2734739.html> */
00120         
00121         /* Don't change empty string; and also we can't improve on
00122          * "/" */
00123         
00124         l = strlen(name);
00125         while (l > 1) {
00126                 if (name[--l] != '/')
00127                         break;
00128                 name[l] = '\0';
00129         }
00130 }

int do_mkdir char *    fname,
mode_t    mode
 

Definition at line 133 of file syscall.c.

References trim_trailing_slashes().

Referenced by create_directory_path(), get_local_name(), keep_backup(), make_bak_dir(), make_dir(), and recv_generator().

00134 {
00135         if (dry_run)
00136                 return 0;
00137         CHECK_RO;
00138         trim_trailing_slashes(fname);   
00139         return mkdir(fname, mode);
00140 }

int do_mkstemp char *    template,
mode_t    perms
 

Definition at line 144 of file syscall.c.

References do_open().

Referenced by recv_files().

00145 {
00146         if (dry_run) return -1;
00147         if (read_only) {errno = EROFS; return -1;}
00148 
00149 #if defined(HAVE_SECURE_MKSTEMP) && defined(HAVE_FCHMOD)
00150         {
00151                 int fd = mkstemp(template);
00152                 if (fd == -1) return -1;
00153                 if (fchmod(fd, perms) != 0) {
00154                         close(fd);
00155                         unlink(template);
00156                         return -1;
00157                 }
00158                 return fd;
00159         }
00160 #else
00161         if (!mktemp(template)) return -1;
00162         return do_open(template, O_RDWR|O_EXCL|O_CREAT, perms);
00163 #endif
00164 }

int do_stat const char *    fname,
STRUCT_STAT *    st
 

Definition at line 166 of file syscall.c.

Referenced by delete_file(), get_local_name(), get_secret(), getpassf(), keep_backup(), link_stat(), and readlink_stat().

00167 {
00168 #if HAVE_OFF64_T
00169         return stat64(fname, st);
00170 #else
00171         return stat(fname, st);
00172 #endif
00173 }

int do_lstat const char *    fname,
STRUCT_STAT *    st
 

Definition at line 176 of file syscall.c.

Referenced by delete_file(), keep_backup(), link_stat(), list_file(), make_bak_dir(), and readlink_stat().

00177 {
00178 #if HAVE_OFF64_T
00179         return lstat64(fname, st);
00180 #else
00181         return lstat(fname, st);
00182 #endif
00183 }

int do_fstat int    fd,
STRUCT_STAT *    st
 

Definition at line 186 of file syscall.c.

Referenced by recv_files(), and send_files().

00187 {
00188 #if HAVE_OFF64_T
00189         return fstat64(fd, st);
00190 #else
00191         return fstat(fd, st);
00192 #endif
00193 }

OFF_T do_lseek int    fd,
OFF_T    offset,
int    whence
 

Definition at line 195 of file syscall.c.

Referenced by map_ptr(), sparse_end(), and write_sparse().

00196 {
00197 #if HAVE_OFF64_T
00198         off64_t lseek64();
00199         return lseek64(fd, offset, whence);
00200 #else
00201         return lseek(fd, offset, whence);
00202 #endif
00203 }

void* do_mmap void *    start,
int    len,
int    prot,
int    flags,
int    fd,
OFF_T    offset
 

Definition at line 206 of file syscall.c.

00207 {
00208 #if HAVE_OFF64_T
00209         return mmap64(start, len, prot, flags, fd, offset);
00210 #else
00211         return mmap(start, len, prot, flags, fd, offset);
00212 #endif
00213 }

char* d_name struct dirent *    di
 

Definition at line 216 of file syscall.c.

Referenced by delete_file(), and send_directory().

00217 {
00218 #if HAVE_BROKEN_READDIR
00219         return (di->d_name - 2);
00220 #else
00221         return di->d_name;
00222 #endif
00223 }


Variable Documentation

int dry_run
 

Definition at line 29 of file syscall.c.

int read_only
 

Definition at line 30 of file syscall.c.

int list_only
 

Definition at line 31 of file syscall.c.


Generated on Tue Apr 16 12:37:39 2002 for rsync by doxygen1.2.15