SMB_STRUCT_STAT sbuf;
ok = next_token_talloc(ctx, &cmd_ptr,&buf,NULL);
- if (ok && (sys_stat(buf,&sbuf) == 0)) {
+ if (ok && (sys_stat(buf, &sbuf, lp_fake_dir_create_times()) == 0)) {
newer_than = convert_timespec_to_time_t(sbuf.st_ex_mtime);
DEBUG(1,("Getting files newer than %s",
time_to_asc(newer_than)));
(void) dozerobuf(f, TBLOCK);
(void) dozerobuf(f, TBLOCK);
- if (sys_fstat(f, &stbuf) == -1) {
+ if (sys_fstat(f, &stbuf, lp_fake_dir_create_times()) == -1) {
DEBUG(0, ("Couldn't stat file handle\n"));
return;
}
} else {
SMB_STRUCT_STAT stbuf;
- if (sys_stat(argv[Optind], &stbuf) == 0) {
+ if (sys_stat(argv[Optind], &stbuf,
+ lp_fake_dir_create_times()) == 0) {
newer_than = convert_timespec_to_time_t(
stbuf.st_ex_mtime);
DEBUG(1,("Getting files newer than %s",
int sys_fcntl_long(int fd, int cmd, long arg);
void update_stat_ex_mtime(struct stat_ex *dst, struct timespec write_ts);
void update_stat_ex_create_time(struct stat_ex *dst, struct timespec create_time);
-int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf);
-int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf);
-int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf);
+int sys_stat(const char *fname, SMB_STRUCT_STAT *sbuf,
+ bool fake_dir_create_times);
+int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf,
+ bool fake_dir_create_times);
+int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
+ bool fake_dir_create_times);
int sys_ftruncate(int fd, SMB_OFF_T offset);
SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence);
int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence);
maxlog = lp_max_log_size() * 1024;
- if( sys_fstat( x_fileno( dbf ), &st ) == 0 && st.st_ex_size > maxlog ) {
+ if(sys_fstat(x_fileno(dbf), &st,
+ lp_fake_dir_create_times()) == 0
+ && st.st_ex_size > maxlog ) {
(void)reopen_logs();
if( dbf && get_file_size( debugf ) > maxlog ) {
char *name = NULL;
(*bdev) = NULL;
(*fs) = NULL;
- if ( sys_stat(path, &S) == -1 )
+ if ( sys_stat(path, &S, lp_fake_dir_create_times()) == -1 )
return (-1);
devno = S.st_ex_dev ;
}
while ((mnt = getmntent(fp))) {
- if ( sys_stat(mnt->mnt_dir,&S) == -1 )
+ if ( sys_stat(mnt->mnt_dir, &S, lp_fake_dir_create_times())
+ == -1 )
continue ;
if (S.st_ex_dev == devno) {
/* find the block device file */
- if ((ret=sys_stat(path, &S))!=0) {
+ if ((ret=sys_stat(path, &S, lp_fake_dir_create_times()))!=0) {
return ret;
}
use the best approximation.
****************************************************************************/
-static void make_create_timespec(const struct stat *pst, struct stat_ex *dst)
+static void make_create_timespec(const struct stat *pst, struct stat_ex *dst,
+ bool fake_dir_create_times)
{
- if (S_ISDIR(pst->st_mode) && lp_fake_dir_create_times()) {
+ if (S_ISDIR(pst->st_mode) && fake_dir_create_times) {
dst->st_ex_btime.tv_sec = 315493200L; /* 1/1/1980 */
dst->st_ex_btime.tv_nsec = 0;
}
}
static void init_stat_ex_from_stat (struct stat_ex *dst,
- const struct stat *src)
+ const struct stat *src,
+ bool fake_dir_create_times)
{
dst->st_ex_dev = src->st_dev;
dst->st_ex_ino = src->st_ino;
dst->st_ex_atime = get_atimespec(src);
dst->st_ex_mtime = get_mtimespec(src);
dst->st_ex_ctime = get_ctimespec(src);
- make_create_timespec(src, dst);
+ make_create_timespec(src, dst, fake_dir_create_times);
dst->st_ex_blksize = src->st_blksize;
dst->st_ex_blocks = src->st_blocks;
A stat() wrapper that will deal with 64 bit filesizes.
********************************************************************/
-int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf)
+int sys_stat(const char *fname, SMB_STRUCT_STAT *sbuf,
+ bool fake_dir_create_times)
{
int ret;
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_STAT64)
if (S_ISDIR(statbuf.st_mode)) {
statbuf.st_size = 0;
}
- init_stat_ex_from_stat(sbuf, &statbuf);
+ init_stat_ex_from_stat(sbuf, &statbuf, fake_dir_create_times);
}
return ret;
}
An fstat() wrapper that will deal with 64 bit filesizes.
********************************************************************/
-int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf)
+int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf, bool fake_dir_create_times)
{
int ret;
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_FSTAT64)
if (S_ISDIR(statbuf.st_mode)) {
statbuf.st_size = 0;
}
- init_stat_ex_from_stat(sbuf, &statbuf);
+ init_stat_ex_from_stat(sbuf, &statbuf, fake_dir_create_times);
}
return ret;
}
An lstat() wrapper that will deal with 64 bit filesizes.
********************************************************************/
-int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf)
+int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
+ bool fake_dir_create_times)
{
int ret;
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_LSTAT64)
if (S_ISDIR(statbuf.st_mode)) {
statbuf.st_size = 0;
}
- init_stat_ex_from_stat(sbuf, &statbuf);
+ init_stat_ex_from_stat(sbuf, &statbuf, fake_dir_create_times);
}
return ret;
}
if (!sbuf)
sbuf = &st;
- if (sys_stat(fname,sbuf) != 0)
+ if (sys_stat(fname, sbuf, lp_fake_dir_create_times()) != 0)
return(False);
return((S_ISREG(sbuf->st_ex_mode)) || (S_ISFIFO(sbuf->st_ex_mode)));
bool socket_exist(const char *fname)
{
SMB_STRUCT_STAT st;
- if (sys_stat(fname,&st) != 0)
+ if (sys_stat(fname, &st, lp_fake_dir_create_times()) != 0)
return(False);
return S_ISSOCK(st.st_ex_mode);
if (!st)
st = &st2;
- if (sys_stat(dname,st) != 0)
+ if (sys_stat(dname, st, lp_fake_dir_create_times()) != 0)
return(False);
ret = S_ISDIR(st->st_ex_mode);
{
SMB_STRUCT_STAT buf;
buf.st_ex_size = 0;
- if(sys_stat(file_name,&buf) != 0)
+ if (sys_stat(file_name, &buf, lp_fake_dir_create_times()) != 0)
return (SMB_OFF_T)-1;
return get_file_size_stat(&buf);
}
int ifd = -1;
int ofd = -1;
- if (sys_lstat (source, &source_stats) == -1)
+ if (sys_lstat (source, &source_stats,
+ lp_fake_dir_create_times()) == -1)
return -1;
if (!S_ISREG (source_stats.st_ex_mode))
goto out;
}
- result = sys_stat(smb_fname->base_name, &smb_fname->st);
+ result = sys_stat(smb_fname->base_name, &smb_fname->st,
+ lp_fake_dir_create_times());
out:
END_PROFILE(syscall_stat);
return result;
int result;
START_PROFILE(syscall_fstat);
- result = sys_fstat(fsp->fh->fd, sbuf);
+ result = sys_fstat(fsp->fh->fd,
+ sbuf, lp_fake_dir_create_times());
END_PROFILE(syscall_fstat);
return result;
}
goto out;
}
- result = sys_lstat(smb_fname->base_name, &smb_fname->st);
+ result = sys_lstat(smb_fname->base_name, &smb_fname->st,
+ lp_fake_dir_create_times());
out:
END_PROFILE(syscall_lstat);
return result;
/* get pointer to last '/' */
ptr1 = atalk_get_path_ptr(*orig_path);
- sys_lstat(*orig_path, orig_info);
+ sys_lstat(*orig_path, orig_info, lp_fake_dir_create_times());
if (S_ISDIR(orig_info->st_ex_mode)) {
*adbl_path = talloc_asprintf(ctx, "%s/%s/%s/",
#if 0
DEBUG(3, ("ATALK: DEBUG:\n%s\n%s\n", *orig_path, *adbl_path));
#endif
- sys_lstat(*adbl_path, adbl_info);
+ sys_lstat(*adbl_path, adbl_info, lp_fake_dir_create_times());
return 0;
}
/* Ensure the owner of the usershare file has permission to share
this directory. */
- if (sys_stat(sharepath, &sbuf) == -1) {
+ if (sys_stat(sharepath, &sbuf,
+ lp_fake_dir_create_times()) == -1) {
DEBUG(2,("parse_usershare_file: share %s : stat failed on path %s. %s\n",
servicename, sharepath, strerror(errno) ));
sys_closedir(dp);
/* Minimize the race condition by doing an lstat before we
open and fstat. Ensure this isn't a symlink link. */
- if (sys_lstat(fname, &lsbuf) != 0) {
+ if (sys_lstat(fname, &lsbuf, lp_fake_dir_create_times()) != 0) {
DEBUG(0,("process_usershare_file: stat of %s failed. %s\n",
fname, strerror(errno) ));
SAFE_FREE(fname);
}
/* Now fstat to be *SURE* it's a regular file. */
- if (sys_fstat(fd, &sbuf) != 0) {
+ if (sys_fstat(fd, &sbuf, lp_fake_dir_create_times()) != 0) {
close(fd);
DEBUG(0,("process_usershare_file: fstat of %s failed. %s\n",
fname, strerror(errno) ));
return false;
}
- if (sys_lstat(fname, &lsbuf) != 0) {
+ if (sys_lstat(fname, &lsbuf, lp_fake_dir_create_times()) != 0) {
SAFE_FREE(fname);
return false;
}
return -1;
}
- if (sys_stat(usersharepath, &sbuf) != 0) {
+ if (sys_stat(usersharepath, &sbuf, lp_fake_dir_create_times())
+ != 0) {
DEBUG(0,("load_usershare_service: stat of %s failed. %s\n",
usersharepath, strerror(errno) ));
return -1;
return lp_numservices();
}
- if (sys_stat(usersharepath, &sbuf) != 0) {
+ if (sys_stat(usersharepath, &sbuf, lp_fake_dir_create_times())
+ != 0) {
DEBUG(0,("load_usershare_shares: stat of %s failed. %s\n",
usersharepath, strerror(errno) ));
return ret;
* prevent infinate loops. JRA.
*/
- if (sys_stat(pfile,&sbuf1) != 0) {
+ if (sys_stat(pfile, &sbuf1,
+ lp_fake_dir_create_times()) != 0) {
DEBUG(0, ("startsmbfilepwent_internal: unable to stat file %s. \
Error was %s\n", pfile, strerror(errno)));
pw_file_unlock(fileno(fp), lock_depth);
return NULL;
}
- if (sys_fstat(fileno(fp),&sbuf2) != 0) {
+ if (sys_fstat(fileno(fp), &sbuf2,
+ lp_fake_dir_create_times()) != 0) {
DEBUG(0, ("startsmbfilepwent_internal: unable to fstat file %s. \
Error was %s\n", pfile, strerror(errno)));
pw_file_unlock(fileno(fp), lock_depth);
return False;
if ((close_type == NORMAL_CLOSE || close_type == SHUTDOWN_CLOSE) &&
- (sys_fstat(pjob->fd, &sbuf) == 0)) {
+ (sys_fstat(pjob->fd, &sbuf, lp_fake_dir_create_times())
+ == 0)) {
pjob->size = sbuf.st_ex_size;
close(pjob->fd);
pjob->fd = -1;
/* check for end of file */
- if ( sys_fstat( file->fd, &sbuf ) ) {
+ if (sys_fstat(file->fd, &sbuf, lp_fake_dir_create_times())) {
DEBUG(0,("write_block: stat() failed! (%s)\n", strerror(errno)));
return -1;
}
/* check for end of file */
- if ( sys_fstat( file->fd, &sbuf ) ) {
+ if (sys_fstat(file->fd, &sbuf, lp_fake_dir_create_times())) {
DEBUG(0,("read_block: stat() failed! (%s)\n", strerror(errno)));
return -1;
}
memcpy( hbin->header, "hbin", sizeof(HBIN_HDR_SIZE) );
- if ( sys_fstat( file->fd, &sbuf ) ) {
+ if (sys_fstat(file->fd, &sbuf, lp_fake_dir_create_times())) {
DEBUG(0,("regf_hbin_allocate: stat() failed! (%s)\n", strerror(errno)));
return NULL;
}
goto out;
}
- if (sys_fstat(tmp_fd,&st) == -1) {
+ if (sys_fstat(tmp_fd, &st, lp_fake_dir_create_times()) == -1) {
int err = errno;
close(tmp_fd);
close(outfd);
/* find the block device file */
- if ( sys_stat(path, &S) == -1 )
+ if ( sys_stat(path, &S, lp_fake_dir_create_times()) == -1 )
return(False) ;
devno = S.st_ex_dev ;
found = False ;
while ((mnt = getmntent(fp))) {
- if ( sys_stat(mnt->mnt_dir,&S) == -1 )
+ if ( sys_stat(mnt->mnt_dir, &S, lp_fake_dir_create_times())
+ == -1 )
continue ;
if (S.st_ex_dev == devno) {
int quota_default = 0 ;
bool found = false;
- if (sys_stat(path,&sbuf) == -1) {
+ if (sys_stat(path, &sbuf, lp_fake_dir_create_times()) == -1) {
return false;
}
}
while ((mnt = getmntent(fd)) != NULL) {
- if (sys_stat(mnt->mnt_dir,&sbuf) == -1) {
+ if (sys_stat(mnt->mnt_dir, &sbuf, lp_fake_dir_create_times())
+ == -1) {
continue;
}
if (sbuf.st_ex_dev == devno) {
euser_id = geteuid();
- if (sys_stat(path,&sbuf) == -1) {
+ if (sys_stat(path, &sbuf, lp_fake_dir_create_times()) == -1) {
return false;
}
}
while (getmntent(fd, &mnt) == 0) {
- if (sys_stat(mnt.mnt_mountp, &sbuf) == -1) {
+ if (sys_stat(mnt.mnt_mountp, &sbuf,
+ lp_fake_dir_create_times()) == -1) {
continue;
}
}
while ((mnt = getmntent(fd)) != NULL) {
- if (sys_stat(mnt->mnt_dir,&sbuf) == -1) {
+ if (sys_stat(mnt->mnt_dir, &sbuf,
+ lp_fake_dir_create_times()) == -1) {
continue;
}
DEBUG(5,("disk_quotas: testing \"%s\" devno=%x\n",
/* find the block device file */
- if ( sys_stat(path, &S) == -1 ) {
+ if ( sys_stat(path, &S, lp_fake_dir_create_times()) == -1 ) {
return(False) ;
}
found = False ;
while ((mnt = getmntent(fp))) {
- if ( sys_stat(mnt->mnt_dir,&S) == -1 )
+ if ( sys_stat(mnt->mnt_dir, &S, lp_fake_dir_create_times()) == -1 )
continue ;
if (S.st_ex_dev == devno) {
found = True ;
* to have a significant performance boost when
* lstat calls on /dev access this function.
*/
- if ((sys_stat(path, &S)<0) || (devnm(S_IFBLK, S.st_ex_dev, dev_disk, 256, 1)<0))
+ if ((sys_stat(path, &S, lp_fake_dir_create_times())<0)
+ || (devnm(S_IFBLK, S.st_ex_dev, dev_disk, 256, 1)<0))
#else
- if ((sys_stat(path, &S)<0) || (devnm(S_IFBLK, S.st_ex_dev, dev_disk, 256, 0)<0))
+ if ((sys_stat(path, &S, lp_fake_dir_create_times())<0)
+ || (devnm(S_IFBLK, S.st_ex_dev, dev_disk, 256, 0)<0))
return (False);
#endif /* ifdef HPUX */
SMB_STRUCT_STAT st;
int mntsize, i;
- if (sys_stat(path,&st) < 0)
+ if (sys_stat(path, &st, lp_fake_dir_create_times()) < 0)
return False;
devno = st.st_ex_dev;
return False;
for (i = 0; i < mntsize; i++) {
- if (sys_stat(mnts[i].f_mntonname,&st) < 0)
+ if (sys_stat(mnts[i].f_mntonname, &st, lp_fake_dir_create_times()) < 0)
return False;
if (st.st_ex_dev == devno)
break;
goto done;
}
- if (sys_stat(path, &sbuf) != 0) {
+ if (sys_stat(path, &sbuf, lp_fake_dir_create_times()) != 0) {
d_fprintf(stderr,
_("ERROR: cannot stat path '%s' to ensure "
"this is a directory.\n"
return -1;
}
- if (sys_lstat(path, &sbuf) != 0) {
+ if (sys_lstat(path, &sbuf, lp_fake_dir_create_times())
+ != 0) {
d_fprintf(stderr,
_("get_share_list: can't lstat file %s. Error "
"was %s\n"),
}
/* Paranoia... */
- if (sys_fstat(fd, &sbuf) != 0) {
+ if (sys_fstat(fd, &sbuf, lp_fake_dir_create_times()) != 0) {
d_fprintf(stderr,
_("info_fn: can't fstat file %s. Error was %s\n"),
basepath, strerror(errno) );
return -1;
}
- if (sys_lstat(path, &sbuf) != 0) {
+ if (sys_lstat(path, &sbuf, lp_fake_dir_create_times())
+ != 0) {
d_fprintf(stderr,
_("count_num_usershares: can't lstat file %s. "
"Error was %s\n"),
}
/* Check the directory to be shared exists. */
- if (sys_stat(us_path, &sbuf) != 0) {
+ if (sys_stat(us_path, &sbuf, lp_fake_dir_create_times()) != 0) {
d_fprintf(stderr,
_("net usershare add: cannot stat path %s to ensure "
"this is a directory. Error was %s\n"),
}
/* Ensure we opened the file we thought we did. */
- if (sys_lstat(full_path_tmp, &lsbuf) != 0) {
+ if (sys_lstat(full_path_tmp, &lsbuf, lp_fake_dir_create_times())
+ != 0) {
d_fprintf(stderr,
_("net usershare add: cannot lstat tmp file %s\n"),
full_path_tmp );
}
/* Check this is the same as the file we opened. */
- if (sys_fstat(tmpfd, &sbuf) != 0) {
+ if (sys_fstat(tmpfd, &sbuf, lp_fake_dir_create_times()) != 0) {
d_fprintf(stderr,
_("net usershare add: cannot fstat tmp file %s\n"),
full_path_tmp );
}
}
- if (sys_stat(file, &st) != 0)
- {
+ if (sys_stat(file, &st, lp_fake_dir_create_times()) != 0) {
cgi_setup_error("404 File Not Found","",
"The requested file was not found");
}