site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Z2sXZi5dtZcqVVgB4nsx/gteEVJ+HsGGuJOgquC7eB4=; b=uYsZLDdwp6vERJD25e4LZ/obgU00eHWBakWKdnffc4aWqtUVs/3A0LrkjzshReGAVE bAmL7WEEygwP5C2bor77md46lFkaafM2HMHsGT9kUsO+eFzWvaPxDjk9QI9gv7BvRovS rFEZQTU7XQDkoEN8J8talxGR00CWW6Zncs688qPpnxfc5bTRegqs/B2DzBIQLtr6P0dR leRZNUUi6YmzyW+dOmfB4eXe4CQhT8jGNNH1eXZunABiO4jnBk0KIj1/Iy7Po06xA8Oz AFxwc6IcvBE6o5zBy6IDGCPwfxfGc69xaVtBNmcugQq+4V0IlZVPV+V522ESCqHf7cO/ WWFw== On Sun, Sep 10, 2017 at 8:13 AM, Stephane Sudre <dev.iceberg@gmail.com> wrote: So now, it looks like the problem is earlier in the code and it comes
from the value returned by getattrlist(2).
If I run the code (*) for a file on a HFS+ volume, the value looks correct. If I run the code for a file on a APFS volume, the value looks incorrect.
I just made a quick test app from the xar code you mentioned. One thing to keep in mind is to use a "pack" instruction with the attribute struct returned by getattrlist. With this code, it works on both 10.13 and 10.12.6, on APFS and HFS, correctly: #include <unistd.h> #include <time.h> #include <string.h> #include <stdio.h> #include <sys/attr.h> int main(int argc, const char * argv[]) { if (argc < 2) { fprintf(stderr, "Must provide a file path\n"); } else { const char *path = argv[1]; struct fits { uint32_t length; struct timespec ts; } __attribute__((packed)); struct fits fts; struct attrlist attrs; memset(&attrs, 0, sizeof(attrs)); attrs.bitmapcount = ATTR_BIT_MAP_COUNT; attrs.commonattr = ATTR_CMN_CRTIME; int ret = getattrlist(path, &attrs, &fts, sizeof(fts), 0); if (ret) { perror(argv[0]); } else { char tmpc[64]; struct tm tm; gmtime_r(&fts.ts.tv_sec, &tm); strftime(tmpc, sizeof(tmpc), "%FT%T", &tm); printf("crtime: %s and %ld ns\n",tmpc, fts.ts.tv_nsec); } } return 0; } So, based on this, there's no bug in the API. If you find a specific case where this still doesn't work for you, please let us know. Thomas _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.app... This email sent to site_archiver@lists.apple.com