diff options
author | Alberto Ruiz <alberto.ruiz@codethink.co.uk> | 2011-10-03 22:47:42 +0100 |
---|---|---|
committer | Alberto Ruiz <alberto.ruiz@codethink.co.uk> | 2011-10-03 22:47:42 +0100 |
commit | e32df33d9074d5d43dbcebbc507377e801018225 (patch) | |
tree | 2f00b40ed654265a35b1e0653fe7a108331a98a9 | |
parent | 6151af767679695f6fd2536b7a82760f8600256e (diff) | |
download | tbdiff-e32df33d9074d5d43dbcebbc507377e801018225.tar.gz |
Fixed problem with dymlink diffs
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | libtbd_apply.c | 34 | ||||
-rw-r--r-- | libtbd_create.c | 3 |
3 files changed, 17 insertions, 22 deletions
@@ -9,7 +9,7 @@ CREATE=tbdiff-create CFLAGS ?= CFLAGS += -g -CFLAGS += -Wall -Wextra -Werror $(OPT) +CFLAGS += -Wall -Wextra -Werror -Wno-unused-result $(OPT) SHARED_SRC := libtbd_stat.c DEPLOY_SRC := tbdiff_deploy.c libtbd_create.c diff --git a/libtbd_apply.c b/libtbd_apply.c index ce113f5..f4d7d1b 100644 --- a/libtbd_apply.c +++ b/libtbd_apply.c @@ -103,9 +103,9 @@ tbd_apply_cmd_dir_create(FILE *stream) // Apply metadata. struct utimbuf timebuff = { time(NULL), mtime }; utime(dname, &timebuff); // Don't care if it succeeds right now. - int ret; - ret = chown(dname, (uid_t)uid, (gid_t)gid); - ret = chmod (dname, mode); + + chown(dname, (uid_t)uid, (gid_t)gid); + chmod (dname, mode); return 0; } @@ -212,9 +212,8 @@ tbd_apply_cmd_file_create(FILE *stream) // Don't care if it succeeds right now. utime(fname, &timebuff); /* Chown ALWAYS have to be done before chmod */ - int err; - err = chown(fname, (uid_t)uid, (gid_t)gid); - err = chmod(fname, mode); + chown(fname, (uid_t)uid, (gid_t)gid); + chmod(fname, mode); return 0; } @@ -308,16 +307,15 @@ tbd_apply_cmd_file_delta(FILE *stream) fclose(op); // Apply metadata. - int ret; if(mdata_mask & TBD_METADATA_MTIME) { struct utimbuf timebuff = { time(NULL), mtime }; utime(fname, &timebuff); // Don't care if it succeeds right now. } if(mdata_mask & TBD_METADATA_UID || mdata_mask & TBD_METADATA_GID) - ret = chown(fname, (uid_t)uid, (gid_t)gid); + chown(fname, (uid_t)uid, (gid_t)gid); if(mdata_mask | TBD_METADATA_MODE) - ret = chmod(fname, mode); + chmod(fname, mode); return 0; } @@ -417,14 +415,13 @@ tbd_apply_cmd_symlink_create(FILE *stream) if(symlink(linkpath, linkname)) return TBD_ERROR_UNABLE_TO_CREATE_SYMLINK; - int ret; struct timeval tv[2]; gettimeofday(&tv[0], NULL); tv[1].tv_sec = (long) mtime; tv[1].tv_usec = 0; lutimes(linkname, tv); // Don't care if it succeeds right now. - ret = lchown(linkname, (uid_t)uid, (uid_t)gid); + lchown(linkname, (uid_t)uid, (uid_t)gid); return TBD_ERROR_SUCCESS; } @@ -459,9 +456,8 @@ tbd_apply_cmd_special_create(FILE *stream) struct utimbuf timebuff = { time(NULL), mtime }; utime(name, &timebuff); // Don't care if it succeeds right now. - int ret; - ret = chown(name, (uid_t)uid, (gid_t)gid); - ret = chmod(name, mode); + chown(name, (uid_t)uid, (gid_t)gid); + chmod(name, mode); free(name); return TBD_ERROR_SUCCESS; @@ -483,7 +479,6 @@ tbd_apply_cmd_dir_delta(FILE *stream) fread(&mode, sizeof(uint32_t), 1, stream) != 1) return tbd_error(TBD_ERROR_UNABLE_TO_READ_STREAM); - int ret; char *dname = tbd_apply_fread_string(stream); if(dname == NULL) return tbd_error(TBD_ERROR_UNABLE_TO_READ_STREAM); @@ -495,9 +490,9 @@ tbd_apply_cmd_dir_delta(FILE *stream) utime(dname, &timebuff); // Don't care if it succeeds right now. } if(metadata_mask & TBD_METADATA_UID || metadata_mask & TBD_METADATA_GID) - ret = chown(dname, (uid_t)uid, (gid_t)gid); + chown(dname, (uid_t)uid, (gid_t)gid); if(metadata_mask | TBD_METADATA_MODE) - ret = chmod(dname, mode); + chmod(dname, mode); free(dname); return TBD_ERROR_SUCCESS; @@ -519,7 +514,6 @@ tbd_apply_cmd_file_mdata_update(FILE *stream) fread(&mode, sizeof(uint32_t), 1, stream) != 1) return tbd_error(TBD_ERROR_UNABLE_TO_READ_STREAM); - int ret; char *dname = tbd_apply_fread_string(stream); if(dname == NULL) return tbd_error(TBD_ERROR_UNABLE_TO_READ_STREAM); @@ -531,9 +525,9 @@ tbd_apply_cmd_file_mdata_update(FILE *stream) utime(dname, &timebuff); // Don't care if it succeeds right now. } if(metadata_mask & TBD_METADATA_UID || metadata_mask & TBD_METADATA_GID) - ret = chown(dname, (uid_t)uid, (gid_t)gid); + chown(dname, (uid_t)uid, (gid_t)gid); if(metadata_mask | TBD_METADATA_MODE) - ret = chmod(dname, mode); + chmod(dname, mode); free(dname); return TBD_ERROR_SUCCESS; diff --git a/libtbd_create.c b/libtbd_create.c index 1ae823c..be5f913 100644 --- a/libtbd_create.c +++ b/libtbd_create.c @@ -475,9 +475,10 @@ tbd_create_cmd_symlink_delta(FILE *stream, path_a[len_a] = path_b[len_b] = '\0'; int pathcmp = strcmp(path_a, path_b); + printf ("readlink %s %s - %d", path_a, path_b, pathcmp); /* If both symlinks are equal, we quit */ - if((b->mtime == a->mtime) && (pathcmp != 0)) + if((b->mtime == a->mtime) && (pathcmp == 0)) return 0; /* TODO: If only mtime changes, use a mtime update cmd */ |