Skip to content

Commit

Permalink
Clean up adb Win32 symlink #ifdefs.
Browse files Browse the repository at this point in the history
Change-Id: I83ef30e82d820f91960c29f6b737e6e900caaca6
  • Loading branch information
enh-google authored and Chairshot215 committed Jan 23, 2015
1 parent 44c1c32 commit 6fe9c73
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 35 deletions.
6 changes: 3 additions & 3 deletions adb/file_sync_client.c
Expand Up @@ -309,7 +309,9 @@ static int write_data_buffer(int fd, char* file_buffer, int size, syncsendbuf *s
return err;
}

#ifdef HAVE_SYMLINKS
#if defined(_WIN32)
extern int write_data_link(int fd, const char *path, syncsendbuf *sbuf) __attribute__((error("no symlinks on Windows")));
#else
static int write_data_link(int fd, const char *path, syncsendbuf *sbuf)
{
int len, ret;
Expand Down Expand Up @@ -364,10 +366,8 @@ static int sync_send(int fd, const char *lpath, const char *rpath,
free(file_buffer);
} else if (S_ISREG(mode))
write_data_file(fd, lpath, sbuf, show_progress);
#ifdef HAVE_SYMLINKS
else if (S_ISLNK(mode))
write_data_link(fd, lpath, sbuf);
#endif
else
goto fail;

Expand Down
55 changes: 23 additions & 32 deletions adb/file_sync_service.c
Expand Up @@ -270,7 +270,9 @@ static int handle_send_file(int s, char *path, uid_t uid,
return -1;
}

#ifdef HAVE_SYMLINKS
#if defined(_WIN32)
extern int handle_send_link(int s, char *path, char *buffer) __attribute__((error("no symlinks on Windows")));
#else
static int handle_send_link(int s, char *path, char *buffer)
{
syncmsg msg;
Expand Down Expand Up @@ -321,25 +323,20 @@ static int handle_send_link(int s, char *path, char *buffer)

return 0;
}
#endif /* HAVE_SYMLINKS */
#endif

static int do_send(int s, char *path, char *buffer)
{
char *tmp;
unsigned int mode;
int is_link, ret;
bool is_link = false;
bool do_unlink;

tmp = strrchr(path,',');
char* tmp = strrchr(path,',');
if(tmp) {
*tmp = 0;
errno = 0;
mode = strtoul(tmp + 1, NULL, 0);
#ifndef HAVE_SYMLINKS
is_link = 0;
#else
is_link = S_ISLNK((mode_t) mode);
#endif
mode &= 0777;
}
if(!tmp || errno) {
Expand All @@ -355,32 +352,26 @@ static int do_send(int s, char *path, char *buffer)
}
}

#ifdef HAVE_SYMLINKS
if(is_link)
ret = handle_send_link(s, path, buffer);
else {
#else
{
#endif
uid_t uid = -1;
gid_t gid = -1;
uint64_t cap = 0;
if (is_link) {
return handle_send_link(s, path, buffer);
}

/* copy user permission bits to "group" and "other" permissions */
mode |= ((mode >> 3) & 0070);
mode |= ((mode >> 3) & 0007);
uid_t uid = -1;
gid_t gid = -1;
uint64_t cap = 0;

tmp = path;
if(*tmp == '/') {
tmp++;
}
if (is_on_system(path) || is_on_vendor(path)) {
fs_config(tmp, 0, &uid, &gid, &mode, &cap);
}
ret = handle_send_file(s, path, uid, gid, mode, buffer, do_unlink);
}
/* copy user permission bits to "group" and "other" permissions */
mode |= ((mode >> 3) & 0070);
mode |= ((mode >> 3) & 0007);

return ret;
tmp = path;
if(*tmp == '/') {
tmp++;
}
if (is_on_system(path) || is_on_vendor(path)) {
fs_config(tmp, 0, &uid, &gid, &mode, &cap);
}
return handle_send_file(s, path, uid, gid, mode, buffer, do_unlink);
}

static int do_recv(int s, const char *path, char *buffer)
Expand Down

0 comments on commit 6fe9c73

Please sign in to comment.