-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/cschoenebeck/tags/pull-9p-20220…
…307' into staging 9pfs: introduce macOS host support and cleanup * Add support for Darwin (a.k.a. macOS) hosts. * Code cleanup (move qemu_dirent_dup() from osdep -> 9p-util). * API doc cleanup (convert Doxygen -> kerneldoc format). # gpg: Signature made Mon 07 Mar 2022 11:14:45 GMT # gpg: using RSA key 96D8D110CF7AF8084F88590134C2B58765A47395 # gpg: issuer "qemu_oss@crudebyte.com" # gpg: Good signature from "Christian Schoenebeck <qemu_oss@crudebyte.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: ECAB 1A45 4014 1413 BA38 4926 30DB 47C3 A012 D5F4 # Subkey fingerprint: 96D8 D110 CF7A F808 4F88 5901 34C2 B587 65A4 7395 * remotes/cschoenebeck/tags/pull-9p-20220307: fsdev/p9array.h: convert Doxygen -> kerneldoc format 9pfs/coth.h: drop Doxygen format on v9fs_co_run_in_worker() 9pfs/9p-util.h: convert Doxygen -> kerneldoc format 9pfs/9p.c: convert Doxygen -> kerneldoc format 9pfs/codir.c: convert Doxygen -> kerneldoc format 9pfs/9p.h: convert Doxygen -> kerneldoc format 9pfs: drop Doxygen format from qemu_dirent_dup() API comment 9pfs: move qemu_dirent_dup() from osdep -> 9p-util 9p: darwin: meson: Allow VirtFS on Darwin 9p: darwin: Adjust assumption on virtio-9p-test 9p: darwin: Implement compatibility for mknodat 9p: darwin: Compatibility for f/l*xattr 9p: darwin: *xattr_nofollow implementations 9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX 9p: darwin: Ignore O_{NOATIME, DIRECT} 9p: darwin: Handle struct dirent differences 9p: darwin: Handle struct stat(fs) differences 9p: Rename 9p-util -> 9p-util-linux 9p: linux: Fix a couple Linux assumptions Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
- Loading branch information
Showing
19 changed files
with
403 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* 9p utilities (Darwin Implementation) | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
* See the COPYING file in the top-level directory. | ||
*/ | ||
|
||
#include "qemu/osdep.h" | ||
#include "qemu/xattr.h" | ||
#include "qapi/error.h" | ||
#include "qemu/error-report.h" | ||
#include "9p-util.h" | ||
|
||
ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, | ||
void *value, size_t size) | ||
{ | ||
int ret; | ||
int fd = openat_file(dirfd, filename, | ||
O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); | ||
if (fd == -1) { | ||
return -1; | ||
} | ||
ret = fgetxattr(fd, name, value, size, 0, 0); | ||
close_preserve_errno(fd); | ||
return ret; | ||
} | ||
|
||
ssize_t flistxattrat_nofollow(int dirfd, const char *filename, | ||
char *list, size_t size) | ||
{ | ||
int ret; | ||
int fd = openat_file(dirfd, filename, | ||
O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); | ||
if (fd == -1) { | ||
return -1; | ||
} | ||
ret = flistxattr(fd, list, size, 0); | ||
close_preserve_errno(fd); | ||
return ret; | ||
} | ||
|
||
ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, | ||
const char *name) | ||
{ | ||
int ret; | ||
int fd = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); | ||
if (fd == -1) { | ||
return -1; | ||
} | ||
ret = fremovexattr(fd, name, 0); | ||
close_preserve_errno(fd); | ||
return ret; | ||
} | ||
|
||
int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, | ||
void *value, size_t size, int flags) | ||
{ | ||
int ret; | ||
int fd = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); | ||
if (fd == -1) { | ||
return -1; | ||
} | ||
ret = fsetxattr(fd, name, value, size, 0, flags); | ||
close_preserve_errno(fd); | ||
return ret; | ||
} | ||
|
||
/* | ||
* As long as mknodat is not available on macOS, this workaround | ||
* using pthread_fchdir_np is needed. | ||
* | ||
* Radar filed with Apple for implementing mknodat: | ||
* rdar://FB9862426 (https://openradar.appspot.com/FB9862426) | ||
*/ | ||
#if defined CONFIG_PTHREAD_FCHDIR_NP | ||
|
||
int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) | ||
{ | ||
int preserved_errno, err; | ||
if (!pthread_fchdir_np) { | ||
error_report_once("pthread_fchdir_np() not available on this version of macOS"); | ||
return -ENOTSUP; | ||
} | ||
if (pthread_fchdir_np(dirfd) < 0) { | ||
return -1; | ||
} | ||
err = mknod(filename, mode, dev); | ||
preserved_errno = errno; | ||
/* Stop using the thread-local cwd */ | ||
pthread_fchdir_np(-1); | ||
if (err < 0) { | ||
errno = preserved_errno; | ||
} | ||
return err; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.