Check-in [3a68a54e44]
Overview
Comment:Limit the stat structure when on Win32
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3a68a54e4404f5973dbf9780c6a31a7a54e9d833da770b7e631d1b4aee6dc9d1
User & Date: rkeene on 2019-09-17 16:39:53
Other Links: manifest | tags
Context
2019-09-17
16:40
Updated ignores check-in: 2b232db6ee user: rkeene tags: trunk
16:39
Limit the stat structure when on Win32 check-in: 3a68a54e44 user: rkeene tags: trunk
14:39
A bit of cleanup check-in: a4f7828c1d user: rkeene tags: trunk
Changes

Modified xvfs.c.rvt from [19ca754e24] to [74cd5716ea].

1
2
3
4
5
6
7
8
9











10
11
12
13
14
15
16
#include <xvfs-core.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <tcl.h>

#define XVFS_NAME_LOOKUP_ERROR (-1)
#define XVFS_FILE_BLOCKSIZE 1024












#define MIN(a, b) (((a) < (b)) ? (a) : (b))

typedef enum {
	XVFS_FILE_TYPE_REG,
	XVFS_FILE_TYPE_DIR
} xvfs_file_type_t;










>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <xvfs-core.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <tcl.h>

#define XVFS_NAME_LOOKUP_ERROR (-1)
#define XVFS_FILE_BLOCKSIZE 1024

/*
 * XXX:TODO: Determine this automatically rather than
 *           by heuristics
 */
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
#define HAVE_STRUCT_STAT_ST_BLOCKS  1
#ifdef WIN32
#  undef HAVE_STRUCT_STAT_ST_BLKSIZE
#  undef HAVE_STRUCT_STAT_ST_BLOCKS
#endif

#define MIN(a, b) (((a) < (b)) ? (a) : (b))

typedef enum {
	XVFS_FILE_TYPE_REG,
	XVFS_FILE_TYPE_DIR
} xvfs_file_type_t;

187
188
189
190
191
192
193

194

195
196
197
198
199

200

201
202
203
204

205

206
207
208
209
210
211
212
	statBuf->st_rdev  = 0;
	statBuf->st_ino   = inode;
	statBuf->st_uid   = -1;
	statBuf->st_gid   = -1;
	statBuf->st_atime = 0;
	statBuf->st_ctime = 0;
	statBuf->st_mtime = 0;

	statBuf->st_blksize = XVFS_FILE_BLOCKSIZE;

	
	if (fileInfo->type == XVFS_FILE_TYPE_REG) {
		statBuf->st_mode   = 0100444;
		statBuf->st_nlink  = 1;
		statBuf->st_size   = fileInfo->size;

		statBuf->st_blocks = (fileInfo->size + statBuf->st_blksize - 1) / statBuf->st_blksize;

	} else if (fileInfo->type == XVFS_FILE_TYPE_DIR) {
		statBuf->st_mode   = 040555;
		statBuf->st_nlink  = fileInfo->size;
		statBuf->st_size   = fileInfo->size;

		statBuf->st_blocks = 1;

	}
	
	return(0);
}

static struct Xvfs_FSInfo xvfs_<?= $::xvfs::fsName ?>_fsInfo = {
	.protocolVersion = XVFS_PROTOCOL_VERSION,







>

>





>

>




>

>







198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
	statBuf->st_rdev  = 0;
	statBuf->st_ino   = inode;
	statBuf->st_uid   = -1;
	statBuf->st_gid   = -1;
	statBuf->st_atime = 0;
	statBuf->st_ctime = 0;
	statBuf->st_mtime = 0;
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
	statBuf->st_blksize = XVFS_FILE_BLOCKSIZE;
#endif
	
	if (fileInfo->type == XVFS_FILE_TYPE_REG) {
		statBuf->st_mode   = 0100444;
		statBuf->st_nlink  = 1;
		statBuf->st_size   = fileInfo->size;
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
		statBuf->st_blocks = (fileInfo->size + statBuf->st_blksize - 1) / statBuf->st_blksize;
#endif
	} else if (fileInfo->type == XVFS_FILE_TYPE_DIR) {
		statBuf->st_mode   = 040555;
		statBuf->st_nlink  = fileInfo->size;
		statBuf->st_size   = fileInfo->size;
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
		statBuf->st_blocks = 1;
#endif
	}
	
	return(0);
}

static struct Xvfs_FSInfo xvfs_<?= $::xvfs::fsName ?>_fsInfo = {
	.protocolVersion = XVFS_PROTOCOL_VERSION,