Extend NTIMES to allow setting create_time
[samba.git] / source3 / modules / vfs_default.c
index 8fa8f6ae0671bc51b9467dd2b078da702a8cf42b..a9aabab76854ca43ee82a5ecbc21a1654bb75b72 100644 (file)
@@ -150,12 +150,17 @@ static int vfswrap_mkdir(vfs_handle_struct *handle,  const char *path, mode_t mo
 {
        int result;
        bool has_dacl = False;
+       char *parent = NULL;
 
        START_PROFILE(syscall_mkdir);
 
-       if (lp_inherit_acls(SNUM(handle->conn)) && (has_dacl = directory_has_default_acl(handle->conn, parent_dirname(path))))
+       if (lp_inherit_acls(SNUM(handle->conn))
+           && parent_dirname(talloc_tos(), path, &parent, NULL)
+           && (has_dacl = directory_has_default_acl(handle->conn, parent)))
                mode = 0777;
 
+       TALLOC_FREE(parent);
+
        result = mkdir(path, mode);
 
        if (result == 0 && !has_dacl) {
@@ -677,25 +682,26 @@ static char *vfswrap_getwd(vfs_handle_struct *handle,  char *path)
  system will support.
 **********************************************************************/
 
-static int vfswrap_ntimes(vfs_handle_struct *handle, const char *path, const struct timespec ts[2])
+static int vfswrap_ntimes(vfs_handle_struct *handle, const char *path,
+                         struct smb_file_time *ft)
 {
        int result;
 
        START_PROFILE(syscall_ntimes);
 #if defined(HAVE_UTIMES)
-       if (ts != NULL) {
+       if (ft != NULL) {
                struct timeval tv[2];
-               tv[0] = convert_timespec_to_timeval(ts[0]);
-               tv[1] = convert_timespec_to_timeval(ts[1]);
+               tv[0] = convert_timespec_to_timeval(ft->atime);
+               tv[1] = convert_timespec_to_timeval(ft->mtime);
                result = utimes(path, tv);
        } else {
                result = utimes(path, NULL);
        }
 #elif defined(HAVE_UTIME)
-       if (ts != NULL) {
+       if (ft != NULL) {
                struct utimbuf times;
-               times.actime = convert_timespec_to_time_t(ts[0]);
-               times.modtime = convert_timespec_to_time_t(ts[1]);
+               times.actime = convert_timespec_to_time_t(ft->atime);
+               times.modtime = convert_timespec_to_time_t(ft->mtime);
                result = utime(path, times);
        } else {
                result = utime(path, NULL);
@@ -740,6 +746,20 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
        if (st.st_size > len)
                return sys_ftruncate(fsp->fh->fd, len);
 
+       /* available disk space is enough or not? */
+       if (lp_strict_allocate(SNUM(fsp->conn))){
+               uint64_t space_avail;
+               uint64_t bsize,dfree,dsize;
+
+               space_avail = get_dfree_info(fsp->conn,fsp->fsp_name,false,&bsize,&dfree,&dsize);
+               /* space_avail is 1k blocks */
+               if (space_avail == (uint64_t)-1 ||
+                               ((uint64_t)space_to_write/1024 > space_avail) ) {
+                       errno = ENOSPC;
+                       return -1;
+               }
+       }
+
        /* Write out the real space on disk. */
        if (SMB_VFS_LSEEK(fsp, st.st_size, SEEK_SET) != st.st_size)
                return -1;