Revert all 6 merged PRs (#80-#85) #86
@@ -56,7 +56,6 @@ static void print_usage(void) {
|
|||||||
printf(" --key <path> TLS private key file (PEM)\n");
|
printf(" --key <path> TLS private key file (PEM)\n");
|
||||||
printf(" --ca <path> TLS CA certificate file (PEM)\n");
|
printf(" --ca <path> TLS CA certificate file (PEM)\n");
|
||||||
printf(" --help Show this help\n");
|
printf(" --help Show this help\n");
|
||||||
printf(" -V, --version Show version and exit\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
@@ -81,9 +80,6 @@ int main(int argc, char* argv[]) {
|
|||||||
if (strcmp(argv[i], "--help") == 0) {
|
if (strcmp(argv[i], "--help") == 0) {
|
||||||
print_usage();
|
print_usage();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) {
|
|
||||||
printf("fastsync version %s\n", PROTOCOL_VERSION);
|
|
||||||
goto cleanup;
|
|
||||||
} else if (strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "--archive") == 0) {
|
} else if (strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "--archive") == 0) {
|
||||||
config->use_compression = true;
|
config->use_compression = true;
|
||||||
config->use_multithreading = true;
|
config->use_multithreading = true;
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ static void print_server_usage(void) {
|
|||||||
printf(" --ca <path> TLS CA certificate file (PEM)\n");
|
printf(" --ca <path> TLS CA certificate file (PEM)\n");
|
||||||
printf(" -v, --verbose Enable debug logging\n");
|
printf(" -v, --verbose Enable debug logging\n");
|
||||||
printf(" --help Show this help\n");
|
printf(" --help Show this help\n");
|
||||||
printf(" -V, --version Show version and exit\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
@@ -150,9 +149,6 @@ int main(int argc, char* argv[]) {
|
|||||||
if (strcmp(argv[i], "--help") == 0) {
|
if (strcmp(argv[i], "--help") == 0) {
|
||||||
print_server_usage();
|
print_server_usage();
|
||||||
return 0;
|
return 0;
|
||||||
} else if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) {
|
|
||||||
printf("fastsync-server version %s\n", PROTOCOL_VERSION);
|
|
||||||
return 0;
|
|
||||||
} else if (strcmp(argv[i], "--stdio") == 0) {
|
} else if (strcmp(argv[i], "--stdio") == 0) {
|
||||||
io_set_fds(STDIN_FILENO, STDOUT_FILENO);
|
io_set_fds(STDIN_FILENO, STDOUT_FILENO);
|
||||||
handler(STDIN_FILENO);
|
handler(STDIN_FILENO);
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#ifndef DATA_H
|
#ifndef DATA_H
|
||||||
#define DATA_H
|
#define DATA_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include "stdlib.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void* data;
|
void* data;
|
||||||
|
|||||||
+42
-93
@@ -4,7 +4,6 @@
|
|||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -12,80 +11,60 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
void metadata_to_buf(char** buf, const FileMetadata* m) {
|
void metadata_to_buf(char** buf, const FileMetadata* m) {
|
||||||
int32_t present = (m != NULL) ? 1 : 0;
|
int present = (m != NULL) ? 1 : 0;
|
||||||
memcpy(*buf, &present, sizeof(present));
|
memcpy(*buf, &present, sizeof(int));
|
||||||
*buf += sizeof(present);
|
*buf += sizeof(int);
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return;
|
return;
|
||||||
int32_t mode = (int32_t)m->mode;
|
memcpy(*buf, &m->mode, sizeof(mode_t));
|
||||||
memcpy(*buf, &mode, sizeof(mode));
|
*buf += sizeof(mode_t);
|
||||||
*buf += sizeof(mode);
|
memcpy(*buf, &m->uid, sizeof(uid_t));
|
||||||
int32_t uid = (int32_t)m->uid;
|
*buf += sizeof(uid_t);
|
||||||
memcpy(*buf, &uid, sizeof(uid));
|
memcpy(*buf, &m->gid, sizeof(gid_t));
|
||||||
*buf += sizeof(uid);
|
*buf += sizeof(gid_t);
|
||||||
int32_t gid = (int32_t)m->gid;
|
memcpy(*buf, &m->mtime_sec, sizeof(time_t));
|
||||||
memcpy(*buf, &gid, sizeof(gid));
|
*buf += sizeof(time_t);
|
||||||
*buf += sizeof(gid);
|
memcpy(*buf, &m->mtime_nsec, sizeof(long));
|
||||||
int64_t mtime_sec = (int64_t)m->mtime_sec;
|
*buf += sizeof(long);
|
||||||
memcpy(*buf, &mtime_sec, sizeof(mtime_sec));
|
|
||||||
*buf += sizeof(mtime_sec);
|
|
||||||
int64_t mtime_nsec = (int64_t)m->mtime_nsec;
|
|
||||||
memcpy(*buf, &mtime_nsec, sizeof(mtime_nsec));
|
|
||||||
*buf += sizeof(mtime_nsec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileMetadata* metadata_from_buf(char** buf) {
|
FileMetadata* metadata_from_buf(char** buf) {
|
||||||
int32_t present;
|
int present;
|
||||||
memcpy(&present, *buf, sizeof(present));
|
memcpy(&present, *buf, sizeof(int));
|
||||||
*buf += sizeof(present);
|
*buf += sizeof(int);
|
||||||
if (!present)
|
if (!present)
|
||||||
return NULL;
|
return NULL;
|
||||||
FileMetadata* m = malloc(sizeof(FileMetadata));
|
FileMetadata* m = malloc(sizeof(FileMetadata));
|
||||||
int32_t mode;
|
memcpy(&m->mode, *buf, sizeof(mode_t));
|
||||||
memcpy(&mode, *buf, sizeof(mode));
|
*buf += sizeof(mode_t);
|
||||||
*buf += sizeof(mode);
|
memcpy(&m->uid, *buf, sizeof(uid_t));
|
||||||
m->mode = (mode_t)mode;
|
*buf += sizeof(uid_t);
|
||||||
int32_t uid;
|
memcpy(&m->gid, *buf, sizeof(gid_t));
|
||||||
memcpy(&uid, *buf, sizeof(uid));
|
*buf += sizeof(gid_t);
|
||||||
*buf += sizeof(uid);
|
memcpy(&m->mtime_sec, *buf, sizeof(time_t));
|
||||||
m->uid = (uid_t)uid;
|
*buf += sizeof(time_t);
|
||||||
int32_t gid;
|
memcpy(&m->mtime_nsec, *buf, sizeof(long));
|
||||||
memcpy(&gid, *buf, sizeof(gid));
|
*buf += sizeof(long);
|
||||||
*buf += sizeof(gid);
|
|
||||||
m->gid = (gid_t)gid;
|
|
||||||
int64_t mtime_sec;
|
|
||||||
memcpy(&mtime_sec, *buf, sizeof(mtime_sec));
|
|
||||||
*buf += sizeof(mtime_sec);
|
|
||||||
m->mtime_sec = (time_t)mtime_sec;
|
|
||||||
int64_t mtime_nsec;
|
|
||||||
memcpy(&mtime_nsec, *buf, sizeof(mtime_nsec));
|
|
||||||
*buf += sizeof(mtime_nsec);
|
|
||||||
m->mtime_nsec = (long)mtime_nsec;
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool metadata_send(int file_descriptor, FileMetadata* m) {
|
bool metadata_send(int file_descriptor, FileMetadata* m) {
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
int32_t zero = 0;
|
int zero = 0;
|
||||||
return send_n_data(file_descriptor, &zero, sizeof(zero));
|
return send_n_data(file_descriptor, &zero, sizeof(int));
|
||||||
}
|
}
|
||||||
int32_t present = 1;
|
int present = 1;
|
||||||
int32_t mode = (int32_t)m->mode;
|
return send_n_data(file_descriptor, &present, sizeof(int)) &&
|
||||||
int32_t uid = (int32_t)m->uid;
|
send_n_data(file_descriptor, &m->mode, sizeof(mode_t)) &&
|
||||||
int32_t gid = (int32_t)m->gid;
|
send_n_data(file_descriptor, &m->uid, sizeof(uid_t)) &&
|
||||||
int64_t mtime_sec = (int64_t)m->mtime_sec;
|
send_n_data(file_descriptor, &m->gid, sizeof(gid_t)) &&
|
||||||
int64_t mtime_nsec = (int64_t)m->mtime_nsec;
|
send_n_data(file_descriptor, &m->mtime_sec, sizeof(time_t)) &&
|
||||||
return send_n_data(file_descriptor, &present, sizeof(present)) &&
|
send_n_data(file_descriptor, &m->mtime_nsec, sizeof(long));
|
||||||
send_n_data(file_descriptor, &mode, sizeof(mode)) &&
|
|
||||||
send_n_data(file_descriptor, &uid, sizeof(uid)) &&
|
|
||||||
send_n_data(file_descriptor, &gid, sizeof(gid)) &&
|
|
||||||
send_n_data(file_descriptor, &mtime_sec, sizeof(mtime_sec)) &&
|
|
||||||
send_n_data(file_descriptor, &mtime_nsec, sizeof(mtime_nsec));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileMetadata* metadata_receive(int file_descriptor, int* ok) {
|
FileMetadata* metadata_receive(int file_descriptor, int* ok) {
|
||||||
int32_t present;
|
int present;
|
||||||
if (!receive_n_data(file_descriptor, &present, sizeof(present))) {
|
if (!receive_n_data(file_descriptor, &present, sizeof(int))) {
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = 0;
|
*ok = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -101,46 +80,16 @@ FileMetadata* metadata_receive(int file_descriptor, int* ok) {
|
|||||||
*ok = 0;
|
*ok = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
int32_t mode;
|
if (!receive_n_data(file_descriptor, &m->mode, sizeof(mode_t)) ||
|
||||||
if (!receive_n_data(file_descriptor, &mode, sizeof(mode))) {
|
!receive_n_data(file_descriptor, &m->uid, sizeof(uid_t)) ||
|
||||||
|
!receive_n_data(file_descriptor, &m->gid, sizeof(gid_t)) ||
|
||||||
|
!receive_n_data(file_descriptor, &m->mtime_sec, sizeof(time_t)) ||
|
||||||
|
!receive_n_data(file_descriptor, &m->mtime_nsec, sizeof(long))) {
|
||||||
free(m);
|
free(m);
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = 0;
|
*ok = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
m->mode = (mode_t)mode;
|
|
||||||
int32_t uid;
|
|
||||||
if (!receive_n_data(file_descriptor, &uid, sizeof(uid))) {
|
|
||||||
free(m);
|
|
||||||
if (ok)
|
|
||||||
*ok = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
m->uid = (uid_t)uid;
|
|
||||||
int32_t gid;
|
|
||||||
if (!receive_n_data(file_descriptor, &gid, sizeof(gid))) {
|
|
||||||
free(m);
|
|
||||||
if (ok)
|
|
||||||
*ok = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
m->gid = (gid_t)gid;
|
|
||||||
int64_t mtime_sec;
|
|
||||||
if (!receive_n_data(file_descriptor, &mtime_sec, sizeof(mtime_sec))) {
|
|
||||||
free(m);
|
|
||||||
if (ok)
|
|
||||||
*ok = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
m->mtime_sec = (time_t)mtime_sec;
|
|
||||||
int64_t mtime_nsec;
|
|
||||||
if (!receive_n_data(file_descriptor, &mtime_nsec, sizeof(mtime_nsec))) {
|
|
||||||
free(m);
|
|
||||||
if (ok)
|
|
||||||
*ok = 0;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
m->mtime_nsec = (long)mtime_nsec;
|
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = 1;
|
*ok = 1;
|
||||||
return m;
|
return m;
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define FILE_METADATA_WIRE_SIZE (sizeof(int32_t) * 3 + sizeof(int64_t) * 2)
|
#define FILE_METADATA_WIRE_SIZE \
|
||||||
|
(sizeof(mode_t) + sizeof(uid_t) + sizeof(gid_t) + sizeof(time_t) + sizeof(long))
|
||||||
|
|
||||||
void metadata_to_buf(char** buf, const FileMetadata* m);
|
void metadata_to_buf(char** buf, const FileMetadata* m);
|
||||||
FileMetadata* metadata_from_buf(char** buf);
|
FileMetadata* metadata_from_buf(char** buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user