| 1254 | |
| 1255 | #ifdef SUPPORT_CRTIMES |
| 1256 | int do_setattrlist_crtime(const char *path, time_t crtime) |
| 1257 | { |
| 1258 | extern int am_daemon, am_chrooted; |
| 1259 | struct attrlist attrList; |
| 1260 | struct timespec ts; |
| 1261 | |
| 1262 | if (dry_run) return 0; |
| 1263 | RETURN_ERROR_IF_RO_OR_LO; |
| 1264 | |
| 1265 | /* Same path-follows-parent-symlinks concern as |
| 1266 | * do_setattrlist_times. There is no portable at-aware variant |
| 1267 | * of setattrlist that targets ATTR_CMN_CRTIME, so on a |
| 1268 | * daemon-no-chroot deployment we return -1 and accept that |
| 1269 | * crtime preservation is silently dropped for that file (the |
| 1270 | * caller treats this as "crtime not updated"). The transfer |
| 1271 | * itself continues normally. */ |
| 1272 | if (am_daemon && !am_chrooted) { |
| 1273 | errno = ENOSYS; |
| 1274 | return -1; |
| 1275 | } |
| 1276 | |
| 1277 | ts.tv_sec = crtime; |
| 1278 | ts.tv_nsec = 0; |
| 1279 | |
| 1280 | memset(&attrList, 0, sizeof attrList); |
| 1281 | attrList.bitmapcount = ATTR_BIT_MAP_COUNT; |
| 1282 | attrList.commonattr = ATTR_CMN_CRTIME; |
| 1283 | return setattrlist(path, &attrList, &ts, sizeof ts, FSOPT_NOFOLLOW); |
| 1284 | } |
| 1285 | #endif |
| 1286 | #endif /* HAVE_SETATTRLIST */ |
| 1287 | |