def METHOD_NAME(filepath, content, drive, diskformat):
    injected = False
    gfs = guestfs.GuestFS()
    try:
        gfs.add_drive_opts(drive, format=diskformat)
    except RuntimeError as e:
        sys.stderr.write('fileinject: [error in inject_file]: %s\n' % e)
    else:
        gfs.launch()
        for root in gfs.inspect_os():
            if gfs.inspect_get_type(root) == "windows":
                filepath = os.path.join(
                    gfs.case_sensitive_path(os.path.dirname(filepath)),
                    os.path.basename(filepath))
            gfs.mount_options("", root, "/")
            try:
                gfs.write(filepath, content)
            except RuntimeError as e:
                sys.stderr.write('fileinject: [upload failed]: %s\n' % e)
            else:
                injected = True
            finally:
                gfs.umount(root)
    return injected