diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2023-05-09 00:31:03 +0300 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-05-10 02:16:00 +0200 |
commit | 4ba239ddbe936322bd7f9a8b17715ebaeb1cb800 (patch) | |
tree | 54d13689e60310babf35b5d9117278eade2ed758 /libdiskfs | |
parent | edc6fe07c5a7f9ade000b3bfc17c030fe2086e21 (diff) | |
download | hurd-4ba239ddbe936322bd7f9a8b17715ebaeb1cb800.tar.gz hurd-4ba239ddbe936322bd7f9a8b17715ebaeb1cb800.tar.bz2 hurd-4ba239ddbe936322bd7f9a8b17715ebaeb1cb800.zip |
libdiskfs: Port to x86_64
Message-Id: <20230508213136.608575-9-bugaevc@gmail.com>
Diffstat (limited to 'libdiskfs')
-rw-r--r-- | libdiskfs/dir-lookup.c | 2 | ||||
-rw-r--r-- | libdiskfs/dir-readdir.c | 14 | ||||
-rw-r--r-- | libdiskfs/diskfs.h | 5 | ||||
-rw-r--r-- | libdiskfs/file-exec.c | 31 | ||||
-rw-r--r-- | libdiskfs/file-get-fs-opts.c | 4 | ||||
-rw-r--r-- | libdiskfs/file-get-trans.c | 10 | ||||
-rw-r--r-- | libdiskfs/file-getfh.c | 3 | ||||
-rw-r--r-- | libdiskfs/file-set-trans.c | 12 | ||||
-rw-r--r-- | libdiskfs/fsys-forward.c | 5 | ||||
-rw-r--r-- | libdiskfs/fsys-getroot.c | 28 | ||||
-rw-r--r-- | libdiskfs/io-restrict-auth.c | 12 | ||||
-rw-r--r-- | libdiskfs/io-write.c | 19 | ||||
-rw-r--r-- | libdiskfs/node-rdwr.c | 12 | ||||
-rw-r--r-- | libdiskfs/priv.h | 3 | ||||
-rw-r--r-- | libdiskfs/rdwr-internal.c | 17 | ||||
-rw-r--r-- | libdiskfs/sync-interval.c | 4 |
16 files changed, 99 insertions, 82 deletions
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c index eb939c09..8df81cfa 100644 --- a/libdiskfs/dir-lookup.c +++ b/libdiskfs/dir-lookup.c @@ -52,7 +52,7 @@ diskfs_S_dir_lookup (struct protid *dircred, int newnode = 0; struct dirstat *ds = 0; int mustbedir = 0; - size_t amt; + mach_msg_type_name_t amt; int type; struct protid *newpi = 0; struct peropen *newpo = 0; diff --git a/libdiskfs/dir-readdir.c b/libdiskfs/dir-readdir.c index 2a62b367..82a9720f 100644 --- a/libdiskfs/dir-readdir.c +++ b/libdiskfs/dir-readdir.c @@ -26,7 +26,7 @@ kern_return_t diskfs_S_dir_readdir (struct protid *cred, data_t *data, - size_t *datacnt, + mach_msg_type_number_t *datacnt, boolean_t *data_dealloc, int entry, int nentries, @@ -35,6 +35,7 @@ diskfs_S_dir_readdir (struct protid *cred, { error_t err; struct node *np; + size_t data_len = *datacnt; if (!cred) return EOPNOTSUPP; @@ -54,8 +55,15 @@ diskfs_S_dir_readdir (struct protid *cred, return ENOTDIR; } - err = diskfs_get_directs (np, entry, nentries, data, datacnt, bufsiz, amt); + err = diskfs_get_directs (np, entry, nentries, + data, &data_len, + bufsiz, amt); *data_dealloc = 1; /* XXX */ pthread_mutex_unlock (&np->lock); - return err; + + if (err) + return err; + + *datacnt = data_len; + return 0; } diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h index 91b868bb..c8c1ab51 100644 --- a/libdiskfs/diskfs.h +++ b/libdiskfs/diskfs.h @@ -694,8 +694,9 @@ void diskfs_nrele_light (struct node *np); read. */ error_t diskfs_node_rdwr (struct node *np, char *data, loff_t off, - size_t amt, int dir, struct protid *cred, - size_t *amtread); + mach_msg_type_number_t amt, int dir, + struct protid *cred, + mach_msg_type_number_t *amtread); /* Send notifications to users who have requested them with diff --git a/libdiskfs/file-exec.c b/libdiskfs/file-exec.c index ec9bc424..254e52ad 100644 --- a/libdiskfs/file-exec.c +++ b/libdiskfs/file-exec.c @@ -34,19 +34,19 @@ diskfs_S_file_exec (struct protid *cred, task_t task, int flags, const_data_t argv, - size_t argvlen, + mach_msg_type_number_t argvlen, const_data_t envp, - size_t envplen, + mach_msg_type_number_t envplen, const mach_port_t *fds, - size_t fdslen, + mach_msg_type_number_t fdslen, const mach_port_t *portarray, - size_t portarraylen, + mach_msg_type_number_t portarraylen, const int *intarray, - size_t intarraylen, + mach_msg_type_number_t intarraylen, const mach_port_t *deallocnames, - size_t deallocnameslen, + mach_msg_type_number_t deallocnameslen, const mach_port_t *destroynames, - size_t destroynameslen) + mach_msg_type_number_t destroynameslen) { return diskfs_S_file_exec_paths (cred, task, @@ -69,19 +69,19 @@ diskfs_S_file_exec_paths (struct protid *cred, const_string_t path, const_string_t abspath, const_data_t argv, - size_t argvlen, + mach_msg_type_number_t argvlen, const_data_t envp, - size_t envplen, + mach_msg_type_number_t envplen, const mach_port_t *fds, - size_t fdslen, + mach_msg_type_number_t fdslen, const mach_port_t *portarray, - size_t portarraylen, + mach_msg_type_number_t portarraylen, const int *intarray, - size_t intarraylen, + mach_msg_type_number_t intarraylen, const mach_port_t *deallocnames, - size_t deallocnameslen, + mach_msg_type_number_t deallocnameslen, const mach_port_t *destroynames, - size_t destroynameslen) + mach_msg_type_number_t destroynameslen) { struct node *np; uid_t uid; @@ -155,7 +155,8 @@ diskfs_S_file_exec_paths (struct protid *cred, err = fshelp_exec_reauth (suid, uid, sgid, gid, diskfs_auth_server_port, get_file_ids, - portarray, portarraylen, fds, fdslen, &secure); + (mach_port_t *) portarray, portarraylen, + (mach_port_t *) fds, fdslen, &secure); if (secure) flags |= EXEC_SECURE | EXEC_NEWTASK; } diff --git a/libdiskfs/file-get-fs-opts.c b/libdiskfs/file-get-fs-opts.c index 71d388f4..4aa5c166 100644 --- a/libdiskfs/file-get-fs-opts.c +++ b/libdiskfs/file-get-fs-opts.c @@ -26,8 +26,8 @@ #include "fs_S.h" error_t -diskfs_S_file_get_fs_options (struct protid *cred, - data_t *data, size_t *data_len) +diskfs_S_file_get_fs_options (struct protid *cred, data_t *data, + mach_msg_type_number_t *data_len) { error_t err; char *argz = 0; diff --git a/libdiskfs/file-get-trans.c b/libdiskfs/file-get-trans.c index c5e495fc..9cec73ae 100644 --- a/libdiskfs/file-get-trans.c +++ b/libdiskfs/file-get-trans.c @@ -24,8 +24,8 @@ /* Implement file_get_translator as described in <hurd/fs.defs>. */ kern_return_t diskfs_S_file_get_translator (struct protid *cred, - data_t *trans, - size_t *translen) + data_t *trans, + mach_msg_type_number_t *translen) { struct node *np; error_t err = 0; @@ -41,7 +41,7 @@ diskfs_S_file_get_translator (struct protid *cred, if (S_ISLNK (np->dn_stat.st_mode)) { unsigned int len = sizeof _HURD_SYMLINK + np->dn_stat.st_size + 1; - size_t amt; + mach_msg_type_number_t amt; assert_backtrace (diskfs_shortcut_symlink); if (len > *translen) *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); @@ -79,8 +79,8 @@ diskfs_S_file_get_translator (struct protid *cred, (S_ISCHR (np->dn_stat.st_mode) ? _HURD_CHRDEV : _HURD_BLKDEV), - '\0', (np->dn_stat.st_rdev >> 8) & 0377, - '\0', (np->dn_stat.st_rdev) & 0377); + '\0', (int) ((np->dn_stat.st_rdev >> 8) & 0377), + '\0', (int) ((np->dn_stat.st_rdev) & 0377)); buflen++; /* terminating nul */ if (buflen > *translen) diff --git a/libdiskfs/file-getfh.c b/libdiskfs/file-getfh.c index 291a70c3..db120813 100644 --- a/libdiskfs/file-getfh.c +++ b/libdiskfs/file-getfh.c @@ -26,7 +26,8 @@ /* Return an NFS file handle for CRED in FH & FN_LEN. */ error_t -diskfs_S_file_getfh (struct protid *cred, data_t *fh, size_t *fh_len) +diskfs_S_file_getfh (struct protid *cred, data_t *fh, + mach_msg_type_number_t *fh_len) { struct node *node; union diskfs_fhandle *f; diff --git a/libdiskfs/file-set-trans.c b/libdiskfs/file-set-trans.c index 7359b906..12f48035 100644 --- a/libdiskfs/file-set-trans.c +++ b/libdiskfs/file-set-trans.c @@ -25,12 +25,12 @@ /* Implement file_set_translator as described in <hurd/fs.defs>. */ kern_return_t diskfs_S_file_set_translator (struct protid *cred, - int passive_flags, - int active_flags, - int killtrans_flags, - const_data_t passive, - size_t passivelen, - fsys_t active) + int passive_flags, + int active_flags, + int killtrans_flags, + const_data_t passive, + mach_msg_type_number_t passivelen, + fsys_t active) { struct node *np; error_t err; diff --git a/libdiskfs/fsys-forward.c b/libdiskfs/fsys-forward.c index 8d5c2fda..f5095941 100644 --- a/libdiskfs/fsys-forward.c +++ b/libdiskfs/fsys-forward.c @@ -30,8 +30,9 @@ filesystem up. */ error_t diskfs_S_fsys_forward (mach_port_t server, - mach_port_t reply, mach_msg_type_name_t reply_type, - mach_port_t requestor, const_data_t argz, size_t argz_len) + mach_port_t reply, mach_msg_type_name_t reply_type, + mach_port_t requestor, const_data_t argz, + mach_msg_type_number_t argz_len) { return EOPNOTSUPP; } diff --git a/libdiskfs/fsys-getroot.c b/libdiskfs/fsys-getroot.c index 1bc6c4a3..4debdf8b 100644 --- a/libdiskfs/fsys-getroot.c +++ b/libdiskfs/fsys-getroot.c @@ -28,18 +28,18 @@ /* Implement fsys_getroot as described in <hurd/fsys.defs>. */ kern_return_t diskfs_S_fsys_getroot (struct diskfs_control *pt, - mach_port_t reply, - mach_msg_type_name_t replytype, - mach_port_t dotdot, - const uid_t *uids, - size_t nuids, - const id_t *gids, - size_t ngids, - int flags, - retry_type *retry, - string_t retryname, - file_t *returned_port, - mach_msg_type_name_t *returned_port_poly) + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t dotdot, + const uid_t *uids, + mach_msg_type_number_t nuids, + const id_t *gids, + mach_msg_type_number_t ngids, + int flags, + retry_type *retry, + string_t retryname, + file_t *returned_port, + mach_msg_type_name_t *returned_port_poly) { error_t err = 0; mode_t type; @@ -110,7 +110,7 @@ diskfs_S_fsys_getroot (struct diskfs_control *pt, err = (*diskfs_read_symlink_hook) (diskfs_root_node, pathbuf); if (!diskfs_read_symlink_hook || err == EINVAL) { - size_t amt = 0; + mach_msg_type_number_t amt = 0; err = diskfs_node_rdwr (diskfs_root_node, pathbuf, 0, diskfs_root_node->dn_stat.st_size, 0, 0, &amt); @@ -184,7 +184,7 @@ diskfs_S_fsys_getroot (struct diskfs_control *pt, flags &= ~OPENONLY_STATE_MODES; err = diskfs_make_peropen (diskfs_root_node, flags, - &peropen_context, &newpo); + &peropen_context, &newpo); if (! err) { err = diskfs_create_protid (newpo, &user, &newpi); diff --git a/libdiskfs/io-restrict-auth.c b/libdiskfs/io-restrict-auth.c index 4b27a919..bb21b15a 100644 --- a/libdiskfs/io-restrict-auth.c +++ b/libdiskfs/io-restrict-auth.c @@ -22,12 +22,12 @@ /* Implement io_restrict_auth as described in <hurd/io.defs>. */ kern_return_t diskfs_S_io_restrict_auth (struct protid *cred, - mach_port_t *newport, - mach_msg_type_name_t *newportpoly, - const uid_t *uids, - size_t nuids, - const gid_t *gids, - size_t ngids) + mach_port_t *newport, + mach_msg_type_name_t *newportpoly, + const uid_t *uids, + mach_msg_type_name_t nuids, + const gid_t *gids, + mach_msg_type_name_t ngids) { error_t err; struct iouser *user; diff --git a/libdiskfs/io-write.c b/libdiskfs/io-write.c index 9efed88f..2e47c81c 100644 --- a/libdiskfs/io-write.c +++ b/libdiskfs/io-write.c @@ -22,14 +22,15 @@ /* Implement io_write as described in <hurd/io.defs>. */ kern_return_t diskfs_S_io_write (struct protid *cred, - const_data_t data, - mach_msg_type_number_t datalen, - off_t offset, - vm_size_t *amt) + const_data_t data, + mach_msg_type_number_t datalen, + off_t offset, + vm_size_t *amt) { struct node *np; error_t err; off_t off = offset; + mach_msg_type_number_t nwritten; if (!cred) return EOPNOTSUPP; @@ -75,18 +76,20 @@ diskfs_S_io_write (struct protid *cred, diskfs_node_update (np, 1); } - *amt = datalen; - err = _diskfs_rdwr_internal (np, (char*) data, off, amt, 1, 0); + nwritten = datalen; + err = _diskfs_rdwr_internal (np, (char *) data, off, &nwritten, 1, 0); + if (!err) + *amt = nwritten; if (!err && offset == -1) - cred->po->filepointer += *amt; + cred->po->filepointer += nwritten; if (!err && ((cred->po->openstat & O_FSYNC) || diskfs_synchronous)) diskfs_file_update (np, 1); if (!err && np->filemod_reqs) - diskfs_notice_filechange (np, FILE_CHANGED_WRITE, off, off + *amt); + diskfs_notice_filechange (np, FILE_CHANGED_WRITE, off, off + nwritten); out: pthread_mutex_unlock (&np->lock); return err; diff --git a/libdiskfs/node-rdwr.c b/libdiskfs/node-rdwr.c index ed94df44..744a38c1 100644 --- a/libdiskfs/node-rdwr.c +++ b/libdiskfs/node-rdwr.c @@ -28,12 +28,12 @@ read. */ error_t diskfs_node_rdwr (struct node *np, - char *data, - off_t off, - size_t amt, - int dir, - struct protid *cred, - size_t *amtread) + char *data, + off_t off, + mach_msg_type_number_t amt, + int dir, + struct protid *cred, + mach_msg_type_number_t *amtread) { error_t err; diff --git a/libdiskfs/priv.h b/libdiskfs/priv.h index 420323dd..ca3c23ca 100644 --- a/libdiskfs/priv.h +++ b/libdiskfs/priv.h @@ -86,7 +86,8 @@ typedef struct bootinfo *bootinfo_t; be locked. If NOTIME is set, then don't update the access or modify times on the file. */ error_t _diskfs_rdwr_internal (struct node *np, char *data, off_t offset, - size_t *amt, int dir, int notime); + mach_msg_type_number_t *amt, + int dir, int notime); /* Called when we have a real user environment (complete with proc and auth ports). */ diff --git a/libdiskfs/rdwr-internal.c b/libdiskfs/rdwr-internal.c index 8b2e1319..011558c5 100644 --- a/libdiskfs/rdwr-internal.c +++ b/libdiskfs/rdwr-internal.c @@ -27,12 +27,8 @@ DIR is set for writing and clear for reading. The inode must be locked. If NOTIME is set, then don't update the mtime or atime. */ error_t -_diskfs_rdwr_internal (struct node *np, - char *data, - off_t offset, - size_t *amt, - int dir, - int notime) +_diskfs_rdwr_internal (struct node *np, char *data, off_t offset, + mach_msg_type_number_t *amt, int dir, int notime) { memory_object_t memobj; vm_prot_t prot = dir ? (VM_PROT_READ | VM_PROT_WRITE) : VM_PROT_READ; @@ -63,8 +59,13 @@ _diskfs_rdwr_internal (struct node *np, offset + *amt > ((off_t) 1) << (sizeof(vm_offset_t) * 8)) err = EFBIG; else - err = pager_memcpy (diskfs_get_filemap_pager_struct (np), memobj, - offset, data, amt, prot); + { + size_t amount = *amt; + err = pager_memcpy (diskfs_get_filemap_pager_struct (np), memobj, + offset, data, &amount, prot); + if (!err) + *amt = amount; + } if (!diskfs_check_readonly () && !notime) { diff --git a/libdiskfs/sync-interval.c b/libdiskfs/sync-interval.c index 14405f29..3a09e868 100644 --- a/libdiskfs/sync-interval.c +++ b/libdiskfs/sync-interval.c @@ -91,9 +91,9 @@ diskfs_set_sync_interval (int interval) INTERVAL seconds, as long as it's in the thread pointed to by the global variable PERIODIC_SYNC_THREAD. */ static void * -periodic_sync (void * arg) +periodic_sync (void *arg) { - int interval = (int) arg; + int interval = (int)(uintptr_t) arg; for (;;) { error_t err; |