VirtualBox

Changeset 92402 in vbox


Ignore:
Timestamp:
Nov 12, 2021 3:18:39 PM (3 years ago)
Author:
vboxsync
Message:

Additions: Linux: VBoxDRMClient: refactoring, bugref:10134.

No functional change. Only reshape drmSendHints().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/display-drm.cpp

    r92399 r92402  
    344344}
    345345
    346 static void drmSendHints(RTFILE hDevice, struct DRMVMWRECT *paRects, unsigned cHeads)
    347 {
    348     int rc;
    349     struct DRMVMWUPDATELAYOUT ioctlLayout;
    350     uid_t curuid = getuid();
    351     if (setreuid(0, 0) != 0)
     346/**
     347 * This function sends screen layout data to DRM stack.
     348 *
     349 * @return  VINF_SUCCESS on success, IPRT error code otherwise.
     350 * @param   hDevice             Handle to opened DRM device.
     351 * @param   paRects             Array of screen configuration data.
     352 * @param   cRects              Number of elements in screen configuration array.
     353 */
     354static int drmSendHints(RTFILE hDevice, struct DRMVMWRECT *paRects, uint32_t cRects)
     355{
     356    int rc = 0;
     357    uid_t curuid;
     358
     359    /* Store real user id. */
     360    curuid = getuid();
     361
     362    /* Chenge effective user id. */
     363    if (setreuid(0, 0) == 0)
     364    {
     365        struct DRMVMWUPDATELAYOUT ioctlLayout;
     366
     367        RT_ZERO(ioctlLayout);
     368        ioctlLayout.cOutputs = cRects;
     369        ioctlLayout.ptrRects = (uint64_t)paRects;
     370
     371        rc = RTFileIoCtl(hDevice, DRM_IOCTL_VMW_UPDATE_LAYOUT,
     372                         &ioctlLayout, sizeof(ioctlLayout), NULL);
     373
     374        if (setreuid(curuid, 0) != 0)
     375        {
     376            VBClLogError("VBoxDRMClient: reset of setreuid failed after drm ioctl");
     377            rc = VERR_ACCESS_DENIED;
     378        }
     379    }
     380    else
    352381    {
    353382        VBClLogError("VBoxDRMClient: setreuid failed during drm ioctl\n");
    354         return;
    355     }
    356 
    357     ioctlLayout.cOutputs = cHeads;
    358     ioctlLayout.ptrRects = (uint64_t)paRects;
    359 
    360     rc = RTFileIoCtl(hDevice, DRM_IOCTL_VMW_UPDATE_LAYOUT,
    361                      &ioctlLayout, sizeof(ioctlLayout), NULL);
    362 
    363     VBClLogInfo("VBoxDRMClient: push layout data to DRM stack %s, %Rrc\n",
    364                 RT_SUCCESS(rc) ? "successful" : "failed", rc);
    365 
    366     if (setreuid(curuid, 0) != 0)
    367     {
    368         VBClLogError("VBoxDRMClient: reset of setreuid failed after drm ioctl");
    369     }
     383        rc = VERR_ACCESS_DENIED;
     384    }
     385
     386    return rc;
    370387}
    371388
     
    405422            if (RT_SUCCESS(rc))
    406423            {
    407                 VBClLogInfo("VBoxDRMClient: push to DRM stack info about %u display(s)\n", cDisplaysOut);
    408                 drmSendHints(hDevice, aDisplaysOut, cDisplaysOut);
     424                rc = drmSendHints(hDevice, aDisplaysOut, cDisplaysOut);
     425                VBClLogInfo("VBoxDRMClient: push screen layout data of %u display(s) to DRM stack has %s (%Rrc)\n",
     426                            cDisplaysOut, RT_SUCCESS(rc) ? "succeeded" : "failed", rc);
    409427            }
    410428            else
     
    436454        VBClLogFatalError("VBoxDRMClient: VbglR3InitUser failed: %Rrc", rc);
    437455
    438 
    439 
    440456    rc = VBClLogCreate("");
    441457    if (RT_FAILURE(rc))
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette