--- samba/source/lib/time.c.orig 2005/01/06 23:22:10 1.1.1.9 +++ samba/source/lib/time.c 2005/03/18 00:59:36 @@ -709,6 +709,33 @@ return(TimeBuf); } +#if defined(ATTR_CMN_CRTIME) +int get_creation_time_attr(char *path, time_t *createTime, int dontFollowSymLink) +{ + int error; + struct attrlist alist; + struct replyBlock { + unsigned long length; + struct timespec createTime; + } reply; + unsigned long options = 0; + + if (dontFollowSymLink) + options |= FSOPT_NOFOLLOW; + + memset( &alist, 0, sizeof(alist)); + memset( &reply, 0, sizeof(reply)); + + alist.bitmapcount = ATTR_BIT_MAP_COUNT; + alist.commonattr = ATTR_CMN_CRTIME; + error = getattrlist( path, &alist, &reply, sizeof(reply), options); + if (error == 0) { + *createTime = reply.createTime.tv_sec; + } + + return (error); +} +#endif /**************************************************************************** return the best approximation to a 'create time' under UNIX from a stat structure. --- samba/source/smbd/nttrans.c.orig 2005/01/06 23:23:12 1.1.1.15 +++ samba/source/smbd/nttrans.c 2005/03/18 00:59:36 @@ -972,7 +972,13 @@ p += 4; /* Create time. */ + #if defined(ATTR_CMN_CRTIME) + if (!(get_creation_time_attr(fname, &c_time, 1) == 0)) { + #endif c_time = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))); + #if defined(ATTR_CMN_CRTIME) + } + #endif if (lp_dos_filetime_resolution(SNUM(conn))) { c_time &= ~1; @@ -1468,7 +1474,13 @@ p += 8; /* Create time. */ + #if defined(ATTR_CMN_CRTIME) + if (!(get_creation_time_attr(fname, &c_time, 1) == 0)) { + #endif c_time = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))); + #if defined(ATTR_CMN_CRTIME) + } + #endif if (lp_dos_filetime_resolution(SNUM(conn))) { c_time &= ~1; Index: samba/source/smbd/reply.c =================================================================== RCS file: /cvs/root/samba/samba/source/smbd/reply.c,v retrieving revision 1.1.1.16 diff -u -d -b -r1.1.1.16 reply.c --- samba/source/smbd/reply.c.orig 2005/01/06 23:23:18 1.1.1.16 +++ samba/source/smbd/reply.c 2005/03/18 00:59:36 @@ -5025,6 +5025,9 @@ int outsize = 0; int mode; files_struct *fsp = file_fsp(inbuf,smb_vwv0); + #if defined(ATTR_CMN_CRTIME) + time_t c_time; + #endif START_PROFILE(SMBgetattrE); outsize = set_message(outbuf,11,0,True); @@ -5047,8 +5050,14 @@ * date to be last modify date as UNIX doesn't save * this. */ - + #if defined(ATTR_CMN_CRTIME) + if (!(get_creation_time_attr(fsp->fsp_name, &c_time, 1) == 0)) { + c_time = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))); + } + put_dos_date2(outbuf,smb_vwv0,c_time); + #else put_dos_date2(outbuf,smb_vwv0,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn)))); + #endif put_dos_date2(outbuf,smb_vwv2,sbuf.st_atime); put_dos_date2(outbuf,smb_vwv4,sbuf.st_mtime); --- samba/source/smbd/trans2.c.orig 2005/01/06 23:37:07 1.7 +++ samba/source/smbd/trans2.c 2005/03/18 00:59:36 @@ -954,8 +954,13 @@ allocation_size = get_allocation_size(NULL,&sbuf); mdate = sbuf.st_mtime; adate = sbuf.st_atime; + #if defined(ATTR_CMN_CRTIME) + if (!(get_creation_time_attr(fname, &cdate, 1) == 0)) { + #endif cdate = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))); - + #if defined(ATTR_CMN_CRTIME) + } + #endif if (lp_dos_filetime_resolution(SNUM(conn))) { cdate &= ~1; mdate &= ~1; @@ -2414,8 +2419,13 @@ memset((char *)pdata,'\0',data_size); +#if defined(ATTR_CMN_CRTIME) + if (!(get_creation_time_attr(fname, &c_time, 1) == 0)) { +#endif c_time = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))); - +#if defined(ATTR_CMN_CRTIME) + } +#endif if (lp_dos_filetime_resolution(SNUM(conn))) { c_time &= ~1; sbuf.st_atime &= ~1;