MCPcopy Create free account
hub / github.com/RsyncProject/rsync / get_backup_name

Function get_backup_name

backup.c:157–184  ·  view source on GitHub ↗

Make a complete pathname for backup file and verify any new path elements. */

Source from the content-addressed store, hash-verified

155
156/* Make a complete pathname for backup file and verify any new path elements. */
157char *get_backup_name(const char *fname)
158{
159 if (backup_dir) {
160 static int initialized = 0;
161 if (!initialized) {
162 int ret;
163 if (backup_dir_len > 1)
164 backup_dir_buf[backup_dir_len-1] = '\0';
165 ret = make_path(backup_dir_buf, 0);
166 if (backup_dir_len > 1)
167 backup_dir_buf[backup_dir_len-1] = '/';
168 if (ret < 0)
169 return NULL;
170 initialized = 1;
171 }
172 /* copy fname into backup_dir_buf while validating the dirs. */
173 if (copy_valid_path(fname))
174 return backup_dir_buf;
175 /* copy_valid_path() has printed an error message. */
176 return NULL;
177 }
178
179 if (stringjoin(backup_dir_buf, MAXPATHLEN, fname, backup_suffix, NULL) < MAXPATHLEN)
180 return backup_dir_buf;
181
182 rprintf(FERROR, "backup filename too long\n");
183 return NULL;
184}
185
186/* Has same return codes as make_backup(). */
187static inline int link_or_rename(const char *from, const char *to,

Callers 4

make_backupFunction · 0.85
finish_transferFunction · 0.85
recv_generatorFunction · 0.85
recv_filesFunction · 0.85

Calls 4

make_pathFunction · 0.85
copy_valid_pathFunction · 0.85
stringjoinFunction · 0.85
rprintfFunction · 0.70

Tested by

no test coverage detected