History

Removed nasty tabs.

gkostka committed 13 years ago

Commit ead60f11 parent 14dd31728 files · +600 −605Browse files

Showing the changes to blockdev (2 of 28 files). Show all

Unified · Split

2 files
  1. blockdev/filedev/ext4_filedev.c +36 −36
  2. blockdev/filedev/ext4_filedev.h +5 −5
blockdev/filedev/ext4_filedev.c+36−36
@@ -33,14 +33,14 @@ · 32 unmodified lines
33#include <string.h>33#include <string.h>
34#include <fcntl.h>34#include <fcntl.h>
35 35
36/**@brief Default filename.*/36/**@brief Default filename.*/
37static const char *fname = "ext2";37static const char *fname = "ext2";
38 38
39/**@brief Image block size.*/39/**@brief Image block size.*/
40#define EXT4_FILEDEV_BSIZE 51240#define EXT4_FILEDEV_BSIZE 512
41 41
42/**@brief Image file descriptor.*/42/**@brief Image file descriptor.*/
43static FILE *dev_file;43static FILE *dev_file;
44 44
45#define DROP_LINUXCACHE_BUFFERS 145#define DROP_LINUXCACHE_BUFFERS 1
46 46
@@ -48,21 +48,21 @@ static FILE *dev_file; · 1 unmodified line
48/**********************BLOCKDEV INTERFACE**************************************/48/**********************BLOCKDEV INTERFACE**************************************/
49static int filedev_open(struct ext4_blockdev *bdev);49static int filedev_open(struct ext4_blockdev *bdev);
50static int filedev_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,50static int filedev_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,
51 uint32_t blk_cnt);51 uint32_t blk_cnt);
52static int filedev_bwrite(struct ext4_blockdev *bdev, const void *buf,52static int filedev_bwrite(struct ext4_blockdev *bdev, const void *buf,
53 uint64_t blk_id, uint32_t blk_cnt);53 uint64_t blk_id, uint32_t blk_cnt);
54static int filedev_close(struct ext4_blockdev *bdev);54static int filedev_close(struct ext4_blockdev *bdev);
55 55
56 56
57/******************************************************************************/57/******************************************************************************/
58EXT4_BLOCKDEV_STATIC_INSTANCE(58EXT4_BLOCKDEV_STATIC_INSTANCE(
59 _filedev,59 _filedev,
60 EXT4_FILEDEV_BSIZE,60 EXT4_FILEDEV_BSIZE,
61 0,61 0,
62 filedev_open,62 filedev_open,
63 filedev_bread,63 filedev_bread,
64 filedev_bwrite,64 filedev_bwrite,
65 filedev_close65 filedev_close
66);66);
67 67
68/******************************************************************************/68/******************************************************************************/
@@ -71,34 +71,34 @@ EXT4_BCACHE_STATIC_INSTANCE(__cache, CONFIG_BLOCK_DEV_CACHE_SIZE, 1024); · 2 unmodified lines
71/******************************************************************************/71/******************************************************************************/
72static int filedev_open(struct ext4_blockdev *bdev)72static int filedev_open(struct ext4_blockdev *bdev)
73{73{
74 dev_file = fopen(fname, "r+b");74 dev_file = fopen(fname, "r+b");
75 75
76 if(!dev_file)76 if(!dev_file)
77 return EIO;77 return EIO;
78 78
79 /*No buffering at file.*/79 /*No buffering at file.*/
80 setbuf(dev_file, 0);80 setbuf(dev_file, 0);
81 81
82 if(fseek(dev_file, 0, SEEK_END))82 if(fseek(dev_file, 0, SEEK_END))
83 return EFAULT;83 return EFAULT;
84 84
85 _filedev.ph_bcnt = ftell(dev_file) / _filedev.ph_bsize;85 _filedev.ph_bcnt = ftell(dev_file) / _filedev.ph_bsize;
86 86
87 return EOK;87 return EOK;
88}88}
89 89
90/******************************************************************************/90/******************************************************************************/
91 91
92static int filedev_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,92static int filedev_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id,
93 uint32_t blk_cnt)93 uint32_t blk_cnt)
94{94{
95 if(fseek(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))95 if(fseek(dev_file, blk_id * bdev->ph_bsize, SEEK_SET))
96 return EIO;96 return EIO;
97 97
98 if(!fread(buf, bdev->ph_bsize * blk_cnt, 1, dev_file))98 if(!fread(buf, bdev->ph_bsize * blk_cnt, 1, dev_file))
99 return EIO;99 return EIO;
100 100
101 return EOK;101 return EOK;
102}102}
103 103
104static void drop_cache(void)104static void drop_cache(void)
@@ -130,26 +130,26 @@ static int filedev_bwrite(struct ext4_blockdev *bdev, const void *buf, · 25 unmodified lines
130/******************************************************************************/130/******************************************************************************/
131static int filedev_close(struct ext4_blockdev *bdev)131static int filedev_close(struct ext4_blockdev *bdev)
132{132{
133 fclose(dev_file);133 fclose(dev_file);
134 return EOK;134 return EOK;
135}135}
136 136
137 137
138/******************************************************************************/138/******************************************************************************/
139 139
140struct ext4_bcache* ext4_filecache_get(void)140struct ext4_bcache* ext4_filecache_get(void)
141{141{
142 return &__cache;142 return &__cache;
143}143}
144/******************************************************************************/144/******************************************************************************/
145struct ext4_blockdev* ext4_filedev_get(void)145struct ext4_blockdev* ext4_filedev_get(void)
146{146{
147 return &_filedev;147 return &_filedev;
148}148}
149/******************************************************************************/149/******************************************************************************/
150void ext4_filedev_filename(const char *n)150void ext4_filedev_filename(const char *n)
151{151{
152 fname = n;152 fname = n;
153}153}
154 154
155/******************************************************************************/155/******************************************************************************/
blockdev/filedev/ext4_filedev.h+5−5
@@ -34,12 +34,12 @@ · 33 unmodified lines
34#include <stdint.h>34#include <stdint.h>
35#include <stdbool.h>35#include <stdbool.h>
36 36
37/**@brief Filecache get.*/37/**@brief Filecache get.*/
38struct ext4_bcache* ext4_filecache_get(void);38struct ext4_bcache* ext4_filecache_get(void);
39 39
40/**@brief File blockdev get.*/40/**@brief File blockdev get.*/
41struct ext4_blockdev* ext4_filedev_get(void);41struct ext4_blockdev* ext4_filedev_get(void);
42 42
43void ext4_filedev_filename(const char *n);43void ext4_filedev_filename(const char *n);
44 44
45#endif /* EXT4_FILEDEV_H_ */45#endif /* EXT4_FILEDEV_H_ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t