Skip to content

Zfs 196 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,3 @@ ModelManifest.xml
.fake/

*.am

5 changes: 2 additions & 3 deletions ZFSin.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2005
# Visual Studio Version 16
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required

VisualStudioVersion = 16.0.30204.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZFSin", "ZFSin\ZFSin.vcxproj", "{9AFC9A86-1D07-49E1-9296-F7A3979B751D}"
EndProject
Expand Down Expand Up @@ -95,7 +95,6 @@ Global
{9AFC9A86-1D07-49E1-9296-F7A3979B751D}.Debug|ARM64.Deploy.0 = Debug|ARM64
{9AFC9A86-1D07-49E1-9296-F7A3979B751D}.Debug|x64.ActiveCfg = Debug|x64
{9AFC9A86-1D07-49E1-9296-F7A3979B751D}.Debug|x64.Build.0 = Debug|x64
{9AFC9A86-1D07-49E1-9296-F7A3979B751D}.Debug|x64.Deploy.0 = Debug|x64
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not req

{9AFC9A86-1D07-49E1-9296-F7A3979B751D}.Debug|x86.ActiveCfg = Debug|Win32
{9AFC9A86-1D07-49E1-9296-F7A3979B751D}.Debug|x86.Build.0 = Debug|Win32
{9AFC9A86-1D07-49E1-9296-F7A3979B751D}.Debug|x86.Deploy.0 = Debug|Win32
Expand Down
4 changes: 3 additions & 1 deletion ZFSin/ZFSin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@
<ClCompile Include="zfs\module\zfs\zfs_byteswap.c" />
<ClCompile Include="zfs\module\zfs\zfs_debug.c" />
<ClCompile Include="zfs\module\zfs\zfs_dir.c" />
<ClCompile Include="zfs\module\zfs\zfs_file.c" />
<ClCompile Include="zfs\module\zfs\zfs_fm.c" />
<ClCompile Include="zfs\module\zfs\zfs_fuid.c" />
<ClCompile Include="zfs\module\zfs\zfs_ioctl.c">
Expand Down Expand Up @@ -643,6 +644,7 @@
<ClInclude Include="zfs\include\sys\zfs_debug.h" />
<ClInclude Include="zfs\include\sys\zfs_delay.h" />
<ClInclude Include="zfs\include\sys\zfs_dir.h" />
<ClInclude Include="zfs\include\sys\zfs_file.h" />
<ClInclude Include="zfs\include\sys\zfs_fuid.h" />
<ClInclude Include="zfs\include\sys\zfs_ioctl.h" />
<ClInclude Include="zfs\include\sys\zfs_mount.h" />
Expand Down Expand Up @@ -699,4 +701,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions ZFSin/zfs/cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,7 @@ static void
dump_cachefile(const char *cachefile)
{
int fd;
struct stat statbuf;
struct _stat64 statbuf;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May not be required

char *buf;
nvlist_t *config;

Expand Down Expand Up @@ -2908,7 +2908,7 @@ dump_label(const char *dev)
int fd;
label_t labels[VDEV_LABELS];
char path[MAXPATHLEN];
struct stat statbuf;
struct _stat64 statbuf;
uint64_t psize, ashift;
int l;
boolean_t label_found = B_FALSE;
Expand Down
2 changes: 2 additions & 0 deletions ZFSin/zfs/cmd/zpool/zpool/runsdvui.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd /d "C:\zfs\ZFSin\zfs\cmd\zpool\zpool" &msbuild "zpool.vcxproj" /t:sdvViewer /p:configuration="Debug" /p:platform="x64" /p:SolutionDir="C:\zfs"
exit %errorlevel%
2 changes: 1 addition & 1 deletion ZFSin/zfs/cmd/zpool/zpool_vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ make_disks(zpool_handle_t *zhp, nvlist_t *nv)

char vdev_path[MAX_PATH];
sprintf(vdev_path, "/dev/physicaldrive%lu", deviceNumber.DeviceNumber);

/*
* Update the path to refer to the partition. The presence of
* the 'whole_disk' field indicates to the CLI that we should
Expand Down
2 changes: 1 addition & 1 deletion ZFSin/zfs/include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ typedef struct zpool_load_policy {
* The location of the pool configuration repository, shared between kernel and
* userland.
*/
#define ZPOOL_CACHE "/etc/zfs/zpool.cache"
#define ZPOOL_CACHE "\\SystemRoot\\System32\\drivers\\zpool.cache"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert it for now


/*
* vdev states are ordered from least to most healthy.
Expand Down
6 changes: 6 additions & 0 deletions ZFSin/zfs/include/sys/spa.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,12 @@ typedef enum {
SPA_AUTOTRIM_ON
} spa_autotrim_t;

typedef enum spa_mode {
SPA_MODE_UNINIT = 0,
SPA_MODE_READ = 1,
SPA_MODE_WRITE = 2,
} spa_mode_t;

/*
* Reason TRIM command was issued, used internally for accounting purposes.
*/
Expand Down
6 changes: 6 additions & 0 deletions ZFSin/zfs/include/sys/vdev_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define _SYS_VDEV_FILE_H

#include <sys/vdev.h>
#include <sys/zfs_file.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -42,6 +43,11 @@ extern "C" {
} vdev_file_t;
#endif

typedef struct vdev_file2 {
HANDLE vf_file;
} vdev_file_t2;


#ifdef __cplusplus
}
#endif
Expand Down
58 changes: 58 additions & 0 deletions ZFSin/zfs/include/sys/zfs_file.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/

#ifndef _SYS_ZFS_FILE_H
#define _SYS_ZFS_FILE_H

typedef HANDLE zfs_file_t;

typedef struct zfs_file_attr {
ULONGLONG zfa_size;
DWORD zfa_type;
} zfs_file_attr_t;

int zfs_file_open(const char *path, int flags, int mode, zfs_file_t *fp);
void zfs_file_close(zfs_file_t *fp);
int zfs_file_write(zfs_file_t *fp, const void *buf, size_t len, ssize_t *resid);
int zfs_file_getattr(zfs_file_t* fp, zfs_file_attr_t* zfattr);
int zfs_file_read(zfs_file_t *fp, void *buf, size_t len, ssize_t *resid);
int zfs_file_geomtery(zfs_file_t* hFile, zfs_file_attr_t* zattr);
int zfs_file_pread(zfs_file_t* hFile, void* buf, DWORD dwBytesToRead, DWORD* resid, DWORD offset);
//int zfs_file_pwrite(zfs_file_t *fp, const void *buf, size_t len, loff_t off,
// ssize_t *resid);
//int zfs_file_read(zfs_file_t *fp, void *buf, size_t len, ssize_t *resid);
//int zfs_file_pread(zfs_file_t *fp, void *buf, size_t len, loff_t off,
// ssize_t *resid);

/*
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for commented sections.

int zfs_file_seek(zfs_file_t *fp, loff_t *offp, int whence);
int zfs_file_getattr(zfs_file_t *fp, zfs_file_attr_t *zfattr);
int zfs_file_fsync(zfs_file_t *fp, int flags);
int zfs_file_fallocate(zfs_file_t *fp, int mode, loff_t offset, loff_t len);
loff_t zfs_file_off(zfs_file_t *fp);
int zfs_file_unlink(const char *);

int zfs_file_get(int fd, zfs_file_t **fp);
void zfs_file_put(int fd);
void *zfs_file_private(zfs_file_t *fp);
*/

#endif /* _SYS_ZFS_FILE_H */
14 changes: 12 additions & 2 deletions ZFSin/zfs/lib/libspl/include/umem.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ umem_free(void *ptr, size_t size)
free(ptr);
}

static inline void
umem_free_align(void* ptr, size_t size)
{
_aligned_free(ptr);
}

static inline void
umem_nofail_callback(umem_nofail_callback_t *cb) {}

Expand Down Expand Up @@ -189,8 +195,12 @@ umem_cache_free(umem_cache_t *cp, void *ptr)
{
if (cp->cache_destructor)
cp->cache_destructor(ptr, cp->cache_private);

umem_free(ptr, cp->cache_bufsize);
if (cp->cache_align != 0)
{
umem_free_align(ptr, cp->cache_bufsize);
}
else
umem_free(ptr, cp->cache_bufsize);
}

static inline void
Expand Down
6 changes: 5 additions & 1 deletion ZFSin/zfs/lib/libspl/include/wosix.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ extern FILE *wosix_fdopen(int fildes, const char *mode);
#define pwrite64 wosix_pwrite
#undef fstat
#define fstat wosix_fstat
#undef _fstat64
#define _fstat64 wosix_fstat
#undef fstat_blk
#define fstat_blk wosix_fstat_blk
#undef stat
#define stat wosix_stat
#undef fdatasync
#define fdatasync wosix_fdatasync
#undef ftruncate
Expand All @@ -109,4 +113,4 @@ extern FILE *wosix_fdopen(int fildes, const char *mode);
#undef pipe
#define pipe wosix_pipe

#endif /* WOSIX_HEADER */
#endif /* WOSIX_HEADER */
10 changes: 10 additions & 0 deletions ZFSin/zfs/lib/libspl/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,16 @@ int wosix_mkdir(const char *path, mode_t mode)
return _mkdir(path);
}

int wosix_stat(char *path, struct _stat64 *st)
{
int fd;

fd = open(path, O_RDONLY);
if (fd == -1)
return -1;
return wosix_fstat(fd, st);
}

// Only fill in what we actually use in ZFS
// Mostly used to test for existance, st_mode, st_size
// also FIFO and BLK (fixme)
Expand Down
2 changes: 1 addition & 1 deletion ZFSin/zfs/lib/libuuid/gen_uuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ void uuid_generate_random(uuid_t out)
*/
static int have_random_source(void)
{
struct stat s;
struct _stat64 s;

return (!stat("/dev/random", &s) || !stat("/dev/urandom", &s));
}
Expand Down
Loading