ソースを参照

Fix the large-mmap test.

Don Porter 5 年 前
コミット
a5471a80a8

+ 1 - 0
LibOS/shim/include/shim_fs.h

@@ -71,6 +71,7 @@ struct shim_fs_ops {
     int (*move) (const char * trim_old_name, const char * trim_new_name);
     int (*copy) (const char * trim_old_name, const char * trim_new_name);
 
+    /* Returns 0 on success, -errno on error */
     int (*truncate) (struct shim_handle * hdl, uint64_t len);
 
     /* hstat: get status of the file */

+ 6 - 3
LibOS/shim/src/fs/chroot/fs.c

@@ -268,7 +268,7 @@ static int __query_attr (struct shim_dentry * dent,
     } else {
         /* DEP 3/18/17: Right now, we don't support hard links,
          * so just return 1;
-         */ 
+         */
         data->nlink = 1;
     }
 
@@ -929,6 +929,7 @@ out:
 static int chroot_truncate (struct shim_handle * hdl, uint64_t len)
 {
     int ret = 0;
+    uint64_t rv;
 
     if (NEED_RECREATE(hdl) && (ret = chroot_recreate(hdl)) < 0)
         return ret;
@@ -945,8 +946,10 @@ static int chroot_truncate (struct shim_handle * hdl, uint64_t len)
         struct shim_file_data * data = FILE_HANDLE_DATA(hdl);
         atomic_set(&data->size, len);
     }
-
-    if ((ret = DkStreamSetLength(hdl->pal_handle, len)) != len) {
+    rv = DkStreamSetLength(hdl->pal_handle, len);
+    if (rv) {
+        // For an error, cast it back down to an int return code
+        ret = -((int)rv);
         goto out;
     }
 

+ 1 - 1
LibOS/shim/src/sys/shim_msgget.c

@@ -792,7 +792,7 @@ static int __store_msg_persist (struct shim_msg_handle * msgq)
                         sizeof(struct msg_backup) * msgq->nmsgs +
                         msgq->currentsize;
 
-    if (DkStreamSetLength(file, expected_size) != expected_size)
+    if (DkStreamSetLength(file, expected_size))
         goto err_file;
 
     void * mem = (void *) DkStreamMap(file, NULL,

+ 7 - 2
Pal/src/db_streams.c

@@ -647,6 +647,7 @@ int64_t _DkStreamSetLength (PAL_HANDLE handle, uint64_t length)
 PAL_NUM
 DkStreamSetLength (PAL_HANDLE handle, PAL_NUM length)
 {
+    PAL_NUM rv = 0;
     ENTER_PAL_CALL(DkStreamSetLength);
 
     if (!handle) {
@@ -656,12 +657,16 @@ DkStreamSetLength (PAL_HANDLE handle, PAL_NUM length)
 
     int64_t ret = _DkStreamSetLength(handle, length);
 
+    // Convert failure to a positive value
     if (ret < 0) {
         _DkRaiseFailure(-ret);
-        ret = 0;
+        rv = -ret;
     }
 
-    LEAVE_PAL_CALL_RETURN(ret);
+    // At this point, ret should equal length
+    assert(ret == length);
+
+    LEAVE_PAL_CALL_RETURN(rv);
 }
 
 /* _DkStreamFlush for internal use. This function sync up the handle with

+ 3 - 0
Pal/src/pal.h

@@ -325,6 +325,9 @@ DkStreamMap (PAL_HANDLE handle, PAL_PTR address, PAL_FLG prot,
 void
 DkStreamUnmap (PAL_PTR addr, PAL_NUM size);
 
+/* Sets the length of the file referenced by handle to length.  Returns the 0
+ * on success, a _positive_ errno on failure.
+ */
 PAL_NUM
 DkStreamSetLength (PAL_HANDLE handle, PAL_NUM length);