Skip to content

Commit 8e7042a

Browse files
committed
Change loff_t to Y_LOFF_T in Yaffs Direct
This allows easy porting to 32-bit loff_t. Signed-off-by: Charles Manning <[email protected]>
1 parent 1af6728 commit 8e7042a

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed

direct/handle_common.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ if [ "$1" = "copy" ] ; then
2626
-e "s/strncpy/yaffs_strncpy/g" \
2727
-e "s/strnlen/yaffs_strnlen/g" \
2828
-e "s/strcmp/yaffs_strcmp/g" \
29-
-e "s/strncmp/yaffs_strncmp/g" >$i
29+
-e "s/strncmp/yaffs_strncmp/g"\
30+
-e "s/loff_t/Y_LOFF_T/g" \
31+
>$i
3032
done
3133
elif [ "$1" = "clean" ] ; then
3234
for i in $YAFFS_COMMON_SOURCES ; do

direct/yaffsfs.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct yaffsfs_FileDes {
7474
u8 shareWrite:1;
7575
int inodeId:12; /* Index to corresponding yaffsfs_Inode */
7676
int handleCount:10; /* Number of handles for this fd */
77-
loff_t position; /* current position in file */
77+
Y_LOFF_T position; /* current position in file */
7878
};
7979

8080
struct yaffsfs_Handle {
@@ -1064,17 +1064,17 @@ int yaffs_close(int handle)
10641064
}
10651065

10661066
int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte,
1067-
int isPread, loff_t offset)
1067+
int isPread, Y_LOFF_T offset)
10681068
{
10691069
struct yaffsfs_FileDes *fd = NULL;
10701070
struct yaffs_obj *obj = NULL;
1071-
loff_t pos = 0;
1072-
loff_t startPos = 0;
1073-
loff_t endPos = 0;
1071+
Y_LOFF_T pos = 0;
1072+
Y_LOFF_T startPos = 0;
1073+
Y_LOFF_T endPos = 0;
10741074
int nRead = 0;
10751075
int nToRead = 0;
10761076
int totalRead = 0;
1077-
loff_t maxRead;
1077+
Y_LOFF_T maxRead;
10781078
u8 *buf = (u8 *) vbuf;
10791079

10801080
if (!vbuf) {
@@ -1180,19 +1180,19 @@ int yaffs_read(int handle, void *buf, unsigned int nbyte)
11801180
return yaffsfs_do_read(handle, buf, nbyte, 0, 0);
11811181
}
11821182

1183-
int yaffs_pread(int handle, void *buf, unsigned int nbyte, loff_t offset)
1183+
int yaffs_pread(int handle, void *buf, unsigned int nbyte, Y_LOFF_T offset)
11841184
{
11851185
return yaffsfs_do_read(handle, buf, nbyte, 1, offset);
11861186
}
11871187

11881188
int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte,
1189-
int isPwrite, loff_t offset)
1189+
int isPwrite, Y_LOFF_T offset)
11901190
{
11911191
struct yaffsfs_FileDes *fd = NULL;
11921192
struct yaffs_obj *obj = NULL;
1193-
loff_t pos = 0;
1194-
loff_t startPos = 0;
1195-
loff_t endPos;
1193+
Y_LOFF_T pos = 0;
1194+
Y_LOFF_T startPos = 0;
1195+
Y_LOFF_T endPos;
11961196
int nWritten = 0;
11971197
int totalWritten = 0;
11981198
int write_trhrough = 0;
@@ -1297,12 +1297,12 @@ int yaffs_write(int fd, const void *buf, unsigned int nbyte)
12971297
return yaffsfs_do_write(fd, buf, nbyte, 0, 0);
12981298
}
12991299

1300-
int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, loff_t offset)
1300+
int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, Y_LOFF_T offset)
13011301
{
13021302
return yaffsfs_do_write(fd, buf, nbyte, 1, offset);
13031303
}
13041304

1305-
int yaffs_truncate(const YCHAR *path, loff_t new_size)
1305+
int yaffs_truncate(const YCHAR *path, Y_LOFF_T new_size)
13061306
{
13071307
struct yaffs_obj *obj = NULL;
13081308
struct yaffs_obj *dir = NULL;
@@ -1347,7 +1347,7 @@ int yaffs_truncate(const YCHAR *path, loff_t new_size)
13471347
return (result) ? 0 : -1;
13481348
}
13491349

1350-
int yaffs_ftruncate(int handle, loff_t new_size)
1350+
int yaffs_ftruncate(int handle, Y_LOFF_T new_size)
13511351
{
13521352
struct yaffsfs_FileDes *fd = NULL;
13531353
struct yaffs_obj *obj = NULL;
@@ -1375,12 +1375,12 @@ int yaffs_ftruncate(int handle, loff_t new_size)
13751375

13761376
}
13771377

1378-
loff_t yaffs_lseek(int handle, loff_t offset, int whence)
1378+
Y_LOFF_T yaffs_lseek(int handle, Y_LOFF_T offset, int whence)
13791379
{
13801380
struct yaffsfs_FileDes *fd = NULL;
13811381
struct yaffs_obj *obj = NULL;
1382-
loff_t pos = -1;
1383-
loff_t fSize = -1;
1382+
Y_LOFF_T pos = -1;
1383+
Y_LOFF_T fSize = -1;
13841384

13851385
yaffsfs_Lock();
13861386
fd = yaffsfs_HandleToFileDes(handle);
@@ -2648,9 +2648,9 @@ int yaffs_unmount(const YCHAR *path)
26482648
return yaffs_unmount2(path, 0);
26492649
}
26502650

2651-
loff_t yaffs_freespace(const YCHAR *path)
2651+
Y_LOFF_T yaffs_freespace(const YCHAR *path)
26522652
{
2653-
loff_t retVal = -1;
2653+
Y_LOFF_T retVal = -1;
26542654
struct yaffs_dev *dev = NULL;
26552655
YCHAR *dummy;
26562656

@@ -2677,9 +2677,9 @@ loff_t yaffs_freespace(const YCHAR *path)
26772677
return retVal;
26782678
}
26792679

2680-
loff_t yaffs_totalspace(const YCHAR *path)
2680+
Y_LOFF_T yaffs_totalspace(const YCHAR *path)
26812681
{
2682-
loff_t retVal = -1;
2682+
Y_LOFF_T retVal = -1;
26832683
struct yaffs_dev *dev = NULL;
26842684
YCHAR *dummy;
26852685

@@ -2710,7 +2710,7 @@ loff_t yaffs_totalspace(const YCHAR *path)
27102710

27112711
int yaffs_inodecount(const YCHAR *path)
27122712
{
2713-
loff_t retVal = -1;
2713+
Y_LOFF_T retVal = -1;
27142714
struct yaffs_dev *dev = NULL;
27152715
YCHAR *dummy;
27162716

direct/yaffsfs.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#endif
3232

3333
#define YAFFS_MAX_FILE_SIZE \
34-
( (sizeof(loff_t) < 8) ? YAFFS_MAX_FILE_SIZE_32 : (0x800000000LL - 1) )
34+
( (sizeof(Y_LOFF_T) < 8) ? YAFFS_MAX_FILE_SIZE_32 : (0x800000000LL - 1) )
3535

3636

3737
struct yaffs_dirent {
@@ -55,7 +55,7 @@ struct yaffs_stat {
5555
int st_uid; /* user ID of owner */
5656
int st_gid; /* group ID of owner */
5757
unsigned st_rdev; /* device type (if inode device) */
58-
loff_t st_size; /* total size, in bytes */
58+
Y_LOFF_T st_size; /* total size, in bytes */
5959
unsigned long st_blksize; /* blocksize for filesystem I/O */
6060
unsigned long st_blocks; /* number of blocks allocated */
6161
#ifdef CONFIG_YAFFS_WINCE
@@ -91,13 +91,13 @@ int yaffs_dup(int fd);
9191
int yaffs_read(int fd, void *buf, unsigned int nbyte) ;
9292
int yaffs_write(int fd, const void *buf, unsigned int nbyte) ;
9393

94-
int yaffs_pread(int fd, void *buf, unsigned int nbyte, loff_t offset);
95-
int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, loff_t offset);
94+
int yaffs_pread(int fd, void *buf, unsigned int nbyte, Y_LOFF_T offset);
95+
int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, Y_LOFF_T offset);
9696

97-
loff_t yaffs_lseek(int fd, loff_t offset, int whence) ;
97+
Y_LOFF_T yaffs_lseek(int fd, Y_LOFF_T offset, int whence) ;
9898

99-
int yaffs_truncate(const YCHAR *path, loff_t new_size);
100-
int yaffs_ftruncate(int fd, loff_t new_size);
99+
int yaffs_truncate(const YCHAR *path, Y_LOFF_T new_size);
100+
int yaffs_ftruncate(int fd, Y_LOFF_T new_size);
101101

102102
int yaffs_unlink(const YCHAR *path) ;
103103
int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath) ;
@@ -174,8 +174,8 @@ int yaffs_readlink(const YCHAR *path, YCHAR *buf, int bufsiz);
174174
int yaffs_link(const YCHAR *oldpath, const YCHAR *newpath);
175175
int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev);
176176

177-
loff_t yaffs_freespace(const YCHAR *path);
178-
loff_t yaffs_totalspace(const YCHAR *path);
177+
Y_LOFF_T yaffs_freespace(const YCHAR *path);
178+
Y_LOFF_T yaffs_totalspace(const YCHAR *path);
179179

180180
int yaffs_inodecount(const YCHAR *path);
181181

direct/ydirectenv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ void yaffs_bug_fn(const char *file_name, int line_no);
3535
#define YUCHAR unsigned char
3636
#define _Y(x) x
3737

38+
#ifndef Y_LOFF_T
39+
#define Y_LOFF_T loff_t
40+
#endif
41+
3842
#define yaffs_strcat(a, b) strcat(a, b)
3943
#define yaffs_strcpy(a, b) strcpy(a, b)
4044
#define yaffs_strncpy(a, b, c) strncpy(a, b, c)

0 commit comments

Comments
 (0)