r3194: fixed an uninitialised variable
[gd/samba-autobuild/.git] / source4 / ntvfs / posix / pvfs_fsinfo.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    POSIX NTVFS backend - fsinfo
5
6    Copyright (C) Andrew Tridgell 2004
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "include/includes.h"
24 #include "vfs_posix.h"
25
26
27 /*
28   return filesystem space info
29 */
30 NTSTATUS pvfs_fsinfo(struct ntvfs_module_context *ntvfs,
31                      struct smbsrv_request *req, union smb_fsinfo *fs)
32 {
33         struct pvfs_state *pvfs = ntvfs->private_data;
34         struct stat st;
35
36         if (fs->generic.level != RAW_QFS_GENERIC) {
37                 return ntvfs_map_fsinfo(req, fs, ntvfs);
38         }
39
40         if (sys_fsusage(pvfs->base_directory, 
41                         &fs->generic.out.blocks_free, 
42                         &fs->generic.out.blocks_total) == -1) {
43                 return pvfs_map_errno(pvfs, errno);
44         }
45
46         fs->generic.out.block_size = 512;
47
48         if (stat(pvfs->base_directory, &st) != 0) {
49                 return NT_STATUS_DISK_CORRUPT_ERROR;
50         }
51         
52         fs->generic.out.fs_id = st.st_ino;
53         unix_to_nt_time(&fs->generic.out.create_time, st.st_ctime);
54         fs->generic.out.serial_number = st.st_ino;
55         fs->generic.out.fs_attr = 0;
56         fs->generic.out.max_file_component_length = 255;
57         fs->generic.out.device_type = 0;
58         fs->generic.out.device_characteristics = 0;
59         fs->generic.out.quota_soft = 0;
60         fs->generic.out.quota_hard = 0;
61         fs->generic.out.quota_flags = 0;
62         fs->generic.out.volume_name = talloc_strdup(req, pvfs->share_name);
63         fs->generic.out.fs_type = req->tcon->fs_type;
64         ZERO_STRUCT(fs->generic.out.guid);
65
66         return NT_STATUS_OK;
67 }