summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdike <jdike>2001-06-18 03:16:10 +0000
committerjdike <jdike>2001-06-18 03:16:10 +0000
commitff987783b9d7b4051105d4a6978bb19d7ca1f2bb (patch)
treeb39a588a029987b58c0bb34c9aab26b159f96948
parent19542c91d3acba72ac9bae1f48bf31645ea06cb0 (diff)
downloaduml-history-ff987783b9d7b4051105d4a6978bb19d7ca1f2bb.tar.gz
Added Lennert's 64-bit file support patch.
-rw-r--r--arch/um/Makefile6
-rw-r--r--arch/um/drivers/ubd_user.c10
-rw-r--r--arch/um/fs/hostfs/hostfs.h12
-rw-r--r--arch/um/fs/hostfs/hostfs_kern.c31
-rw-r--r--arch/um/fs/hostfs/hostfs_user.c35
-rw-r--r--arch/um/kernel/user_util.c15
6 files changed, 63 insertions, 46 deletions
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 11413ea..ca77e34 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -1,6 +1,6 @@
include arch/$(ARCH)/Makefile-$(SUBARCH)
-EXTRAVERSION := $(EXTRAVERSION)-6um
+EXTRAVERSION := $(EXTRAVERSION)-7um
include/linux/version.h: arch/$(ARCH)/Makefile
ARCH_DIR = $(TOPDIR)/arch/um
@@ -36,9 +36,7 @@ endif
NESTING = 0
CFLAGS += $(DEBUG) $(PROFILE) $(ARCH_CFLAGS) -D__arch_um__ \
- -DSUBARCH=\"$(SUBARCH)\" -DNESTING=$(NESTING)
-
-#-D_FILE_OFFSET_BITS=64
+ -DSUBARCH=\"$(SUBARCH)\" -DNESTING=$(NESTING) -D_LARGEFILE64_SOURCE
LINKFLAGS += -r
diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c
index 34c5fcc..32bcdb7 100644
--- a/arch/um/drivers/ubd_user.c
+++ b/arch/um/drivers/ubd_user.c
@@ -20,11 +20,11 @@ int open_ubd_fs(char *file, int *openflags)
{
int fd;
- if((fd = open(file, *openflags, 0)) < 0){
+ if((fd = open64(file, *openflags, 0)) < 0){
if((*openflags != O_RDWR) ||
((errno != EROFS) && (errno != EACCES))) return(-errno);
*openflags = O_RDONLY;
- if((fd = open(file, *openflags, 0)) < 0) return(-errno);
+ if((fd = open64(file, *openflags, 0)) < 0) return(-errno);
}
return(fd);
}
@@ -41,9 +41,9 @@ int write_ubd_fs(int fd, char *buffer, int len)
int ubd_is_dir(char *file)
{
- struct stat buf;
+ struct stat64 buf;
- if(stat(file, &buf) < 0) return(0);
+ if(stat64(file, &buf) < 0) return(0);
return(S_ISDIR(buf.st_mode));
}
@@ -51,7 +51,7 @@ int do_io(struct io_thread_req *req)
{
int n;
- if(lseek(req->fd, req->offset, SEEK_SET) < 0){
+ if(lseek64(req->fd, req->offset, SEEK_SET) < 0){
printk("do_io - lseek failed : errno = %d\n",
errno);
return(-1);
diff --git a/arch/um/fs/hostfs/hostfs.h b/arch/um/fs/hostfs/hostfs.h
index abf8a70..e2a6024 100644
--- a/arch/um/fs/hostfs/hostfs.h
+++ b/arch/um/fs/hostfs/hostfs.h
@@ -37,12 +37,12 @@ struct hostfs_iattr {
unsigned int ia_attr_flags;
};
-extern int stat_file(const char *path, int *dev_out, unsigned long *inode_out,
+extern int stat_file(const char *path, int *dev_out, unsigned long long *inode_out,
int *mode_out, int *nlink_out, int *uid_out,
- int *gid_out, unsigned long *size_out,
+ int *gid_out, unsigned long long *size_out,
unsigned long *atime_out, unsigned long *mtime_out,
unsigned long *ctime_out, int *blksize_out,
- int *blocks_out);
+ unsigned long long *blocks_out);
extern int access_file(char *path, int r, int w, int x);
extern int open_file(char *path, int r, int w);
extern int file_type(const char *path, int *rdev);
@@ -65,9 +65,9 @@ extern int do_mknod(const char *file, int mode, int dev);
extern int link_file(const char *from, const char *to);
extern int do_readlink(char *file, char *buf, int size);
extern int rename_file(char *from, char *to);
-extern int do_statfs(char *root, long *bsize_out, long *blocks_out,
- long *bfree_out, long *bavail_out, long *files_out,
- long *ffree_out, void *fsid_out, int fsid_size,
+extern int do_statfs(char *root, long *bsize_out, long long *blocks_out,
+ long long *bfree_out, long long *bavail_out, long long *files_out,
+ long long *ffree_out, void *fsid_out, int fsid_size,
long *namelen_out, long *spare_out);
#endif
diff --git a/arch/um/fs/hostfs/hostfs_kern.c b/arch/um/fs/hostfs/hostfs_kern.c
index c98974b..4df4ac3 100644
--- a/arch/um/fs/hostfs/hostfs_kern.c
+++ b/arch/um/fs/hostfs/hostfs_kern.c
@@ -78,12 +78,15 @@ static int read_name(struct inode *ino, char *name)
* in and having them treated as int * breaks on big-endian machines
*/
int err;
- int i_dev, i_mode, i_nlink, i_blksize, i_blocks;
- unsigned long i_size;
- err = stat_file(name, &i_dev, &ino->i_ino, &i_mode, &i_nlink,
+ int i_dev, i_mode, i_nlink, i_blksize;
+ unsigned long long i_size;
+ unsigned long long i_ino;
+ unsigned long long i_blocks;
+ err = stat_file(name, &i_dev, &i_ino, &i_mode, &i_nlink,
&ino->i_uid, &ino->i_gid, &i_size, &ino->i_atime,
&ino->i_mtime, &ino->i_ctime, &i_blksize, &i_blocks);
if(err) return(err);
+ ino->i_ino = i_ino;
ino->i_dev = i_dev;
ino->i_mode = i_mode;
ino->i_nlink = i_nlink;
@@ -116,13 +119,27 @@ void hostfs_delete_inode(struct inode *ino)
int hostfs_statfs(struct super_block *sb, struct statfs *sf)
{
+ /* do_statfs uses struct statfs64 internally, but the linux kernel
+ * struct statfs still has 32-bit versions for most of these fields,
+ * so we convert them here
+ */
int err;
+ long long f_blocks;
+ long long f_bfree;
+ long long f_bavail;
+ long long f_files;
+ long long f_ffree;
err = do_statfs(sb->s_root->d_inode->u.generic_ip, &sf->f_bsize,
- &sf->f_blocks, &sf->f_bfree, &sf->f_bavail,
- &sf->f_files, &sf->f_ffree, &sf->f_fsid,
- sizeof(sf->f_fsid), &sf->f_namelen, sf->f_spare);
+ &f_blocks, &f_bfree, &f_bavail, &f_files, &f_ffree,
+ &sf->f_fsid, sizeof(sf->f_fsid), &sf->f_namelen,
+ sf->f_spare);
if(err) return(err);
+ sf->f_blocks = f_blocks;
+ sf->f_bfree = f_bfree;
+ sf->f_bavail = f_bavail;
+ sf->f_files = f_files;
+ sf->f_ffree = f_ffree;
sf->f_type = HOSTFS_SUPER_MAGIC;
return(0);
}
@@ -276,7 +293,7 @@ int hostfs_readpage(struct file *file, struct page *page)
long long start;
int err = 0;
- start = page->index << PAGE_CACHE_SHIFT;
+ start = (long long) page->index << PAGE_CACHE_SHIFT;
buffer = kmap(page);
err = read_file((int) file->private_data, &start, buffer,
PAGE_CACHE_SIZE);
diff --git a/arch/um/fs/hostfs/hostfs_user.c b/arch/um/fs/hostfs/hostfs_user.c
index b194e02..6ac383b 100644
--- a/arch/um/fs/hostfs/hostfs_user.c
+++ b/arch/um/fs/hostfs/hostfs_user.c
@@ -16,15 +16,15 @@
#include "kern_util.h"
#include "user.h"
-int stat_file(const char *path, int *dev_out, unsigned long *inode_out,
+int stat_file(const char *path, int *dev_out, unsigned long long *inode_out,
int *mode_out, int *nlink_out, int *uid_out, int *gid_out,
- unsigned long *size_out, unsigned long *atime_out,
+ unsigned long long *size_out, unsigned long *atime_out,
unsigned long *mtime_out, unsigned long *ctime_out,
- int *blksize_out, int *blocks_out)
+ int *blksize_out, unsigned long long *blocks_out)
{
- struct stat buf;
+ struct stat64 buf;
- if(lstat(path, &buf) < 0)
+ if(lstat64(path, &buf) < 0)
return(-errno);
if(dev_out != NULL) *dev_out = buf.st_dev;
if(inode_out != NULL) *inode_out = buf.st_ino;
@@ -43,9 +43,9 @@ int stat_file(const char *path, int *dev_out, unsigned long *inode_out,
int file_type(const char *path, int *rdev)
{
- struct stat buf;
+ struct stat64 buf;
- if(lstat(path, &buf) < 0) return(-errno);
+ if(lstat64(path, &buf) < 0) return(-errno);
*rdev = buf.st_rdev;
if(S_ISDIR(buf.st_mode)) return(HOSTFS_DIR);
else if(S_ISLNK(buf.st_mode)) return(HOSTFS_SYMLINK);
@@ -76,7 +76,7 @@ int open_file(char *path, int r, int w)
else if(!r && w) mode = O_WRONLY;
else if(r && w) mode = O_RDWR;
else panic("Impossible mode in open_file");
- fd = open(path, mode);
+ fd = open64(path, mode);
if(fd < 0) return(-errno);
else return(fd);
}
@@ -108,7 +108,7 @@ int read_file(int fd, unsigned long long *offset, char *buf, int len)
{
int n;
- if(lseek(fd, *offset, SEEK_SET) != *offset)
+ if(lseek64(fd, *offset, SEEK_SET) != *offset)
return(-errno);
n = read(fd, buf, len);
if(n < 0) return(-errno);
@@ -119,7 +119,8 @@ int read_file(int fd, unsigned long long *offset, char *buf, int len)
int write_file(int fd, unsigned long long *offset, const char *buf, int len,
int append)
{
- int n, where, off;
+ unsigned long long off;
+ int n, where;
off = *offset;
where = SEEK_SET;
@@ -127,7 +128,7 @@ int write_file(int fd, unsigned long long *offset, const char *buf, int len,
where = SEEK_END;
off = 0;
}
- if((off = lseek(fd, off, where)) == (off_t) -1)
+ if((off = lseek64(fd, off, where)) == (off_t) -1)
return(-errno);
n = write(fd, buf, len);
if(n < 0) return(-errno);
@@ -139,7 +140,7 @@ int lseek_file(int fd, long long offset, int whence)
{
int ret;
- ret = lseek(fd, (int) offset, whence);
+ ret = lseek64(fd, offset, whence);
if(ret < 0) return(-errno);
return(0);
}
@@ -169,7 +170,7 @@ int file_create(char *name, int ur, int uw, int ux, int gr,
mode |= or ? S_IROTH : 0;
mode |= ow ? S_IWOTH : 0;
mode |= ox ? S_IXOTH : 0;
- fd = open(name, O_CREAT, mode);
+ fd = open64(name, O_CREAT, mode);
if(fd < 0) return(-errno);
close(fd);
return(0);
@@ -299,15 +300,15 @@ int rename_file(char *from, char *to)
return(0);
}
-int do_statfs(char *root, long *bsize_out, long *blocks_out, long *bfree_out,
- long *bavail_out, long *files_out, long *ffree_out,
+int do_statfs(char *root, long *bsize_out, long long *blocks_out, long long *bfree_out,
+ long long *bavail_out, long long *files_out, long long *ffree_out,
void *fsid_out, int fsid_size, long *namelen_out,
long *spare_out)
{
- struct statfs buf;
+ struct statfs64 buf;
int err;
- err = statfs(root, &buf);
+ err = statfs64(root, &buf);
if(err < 0) return(-errno);
*bsize_out = buf.f_bsize;
*blocks_out = buf.f_blocks;
diff --git a/arch/um/kernel/user_util.c b/arch/um/kernel/user_util.c
index 3b6f6de..b5a7ab8 100644
--- a/arch/um/kernel/user_util.c
+++ b/arch/um/kernel/user_util.c
@@ -155,25 +155,26 @@ void remap_data(void *segment_start, void *segment_end)
__u64 file_size(char *file)
{
- struct stat buf;
+ struct stat64 buf;
- if(stat(file, &buf) == -1){
+ if(stat64(file, &buf) == -1){
printk("Couldn't stat \"%s\" : errno = %d\n", file, errno);
- return(-1);
+ return(-errno);
}
if(S_ISBLK(buf.st_mode)){
- int size, fd;
+ long long size;
+ int fd;
- if((fd = open(file, O_RDONLY)) < 0){
+ if((fd = open64(file, O_RDONLY)) < 0){
printk("Couldn't open \"%s\", errno = %d\n", file,
errno);
- return(-1);
+ return(-errno);
}
if(ioctl(fd, BLKGETSIZE, &size) < 0){
printk("Couldn't get the block size of \"%s\", "
"errno = %d\n", file, errno);
close(fd);
- return(-1);
+ return(-errno);
}
size *= 512;
close(fd);