/* * linkFile() * * Creates a hard link between the given relation files. We use * this function to perform a true in-place update. If the on-disk * format of the new cluster is bit-for-bit compatible with the on-disk * format of the old cluster, we can simply link each relation * instead of copying the data from the old cluster to the new cluster. */ const char * linkFile(const char *src, const char *dst) { if (pg_link_file(src, dst) == -1) return getErrorText(); else return NULL; }
/* * linkAndUpdateFile() * * Creates a symbolic link between the given relation files. We use * this function to perform a true in-place update. If the on-disk * format of the new cluster is bit-for-bit compatible with the on-disk * format of the old cluster, we can simply symlink each relation * instead of copying the data from the old cluster to the new cluster. */ const char * linkAndUpdateFile(pageCnvCtx *pageConverter, const char *src, const char *dst) { if (pageConverter != NULL) return "Can't in-place update this cluster, page-by-page conversion is required"; if (pg_link_file(src, dst) == -1) return getErrorText(errno); else return NULL; }
/* * linkAndUpdateFile() * * Creates a hard link between the given relation files. We use * this function to perform a true in-place update. If the on-disk * format of the new cluster is bit-for-bit compatible with the on-disk * format of the old cluster, we can simply link each relation * instead of copying the data from the old cluster to the new cluster. */ const char * linkAndUpdateFile(pageCnvCtx *pageConverter, const char *src, const char *dst) { report_progress(NULL, FILE_COPY, "Link \"%s\" to \"%s\"", src, dst); if (pageConverter != NULL) return "Cannot in-place update this cluster, page-by-page conversion is required"; if (pg_link_file(src, dst) == -1) return getErrorText(); else return NULL; }
void check_hard_link(void) { char existing_file[MAXPGPATH]; char new_link_file[MAXPGPATH]; snprintf(existing_file, sizeof(existing_file), "%s/PG_VERSION", old_cluster.pgdata); snprintf(new_link_file, sizeof(new_link_file), "%s/PG_VERSION.linktest", new_cluster.pgdata); unlink(new_link_file); /* might fail */ if (pg_link_file(existing_file, new_link_file) == -1) { pg_fatal("Could not create hard link between old and new data directories: %s\n" "In link mode the old and new data directories must be on the same file system volume.\n", getErrorText()); } unlink(new_link_file); }
void check_hard_link(migratorContext *ctx) { char existing_file[MAXPGPATH]; char new_link_file[MAXPGPATH]; snprintf(existing_file, sizeof(existing_file), "%s/PG_VERSION", ctx->old.pgdata); snprintf(new_link_file, sizeof(new_link_file), "%s/PG_VERSION.linktest", ctx->new.pgdata); unlink(new_link_file); /* might fail */ if (pg_link_file(existing_file, new_link_file) == -1) { pg_log(ctx, PG_FATAL, "Could not create hard link between old and new data directories: %s\n" "In link mode the old and new data directories must be on the same file system volume.\n", getErrorText(errno)); } unlink(new_link_file); }