Top |
gchar *
udisks_decode_udev_string (const gchar *str
);
Unescapes sequences like \x20 to " " and ensures the returned string is valid UTF-8.
If the string is not valid UTF-8, try as hard as possible to convert to UTF-8.
If NULL
is passed, then NULL
is returned.
See udev_util_encode_string()
in libudev/libudev-util.c in the udev
tree for what kinds of strings can be used.
void udisks_safe_append_to_object_path (GString *str
,const gchar *s
);
Appends s
to str
in a way such that only characters that can be
used in a D-Bus object path will be used. E.g. a character not in
A-Z[0-9]_
will be escaped as _HEX where
HEX is a two-digit hexadecimal number.
Note that his mapping is not bijective - e.g. you cannot go back to the original string.
guint64 udisks_daemon_util_block_get_size (GUdevDevice *device
,gboolean *out_media_available
,gboolean *out_media_change_detected
);
Gets the size of the device
top-level block device, checking for media in the process
device |
A GUdevDevice for a top-level block device. |
|
out_media_available |
Return location for whether media is available or |
[out] |
out_media_change_detected |
Return location for whether media change is detected or |
[out] |
gchar * udisks_daemon_util_resolve_link (const gchar *path
,const gchar *name
);
Resolves the symlink path
/name
.
gchar ** udisks_daemon_util_resolve_links (const gchar *path
,const gchar *dir_name
);
Resolves all symlinks in path
/dir_name
. This can be used to
easily walk e.g. holders or slaves of block devices.
gboolean udisks_daemon_util_check_authorization_sync (UDisksDaemon *daemon
,UDisksObject *object
,const gchar *action_id
,GVariant *options
,const gchar *message
,GDBusMethodInvocation *invocation
);
Checks if the caller represented by invocation
is authorized for
the action identified by action_id
, optionally displaying message
if authentication is needed. Additionally, if the caller is not
authorized, the appropriate error is already returned to the caller
via invocation
.
The calling thread is blocked for the duration of the authorization
check which could be a very long time since it may involve
presenting an authentication dialog and having a human user use
it. If “auth.no_user_interaction” in options
is TRUE
no authentication dialog will be presented and the check is not
expected to take a long time.
See Table 1, “Known polkit variables” for the variables that
can be used in message
but note that not all variables can be used
in all checks. For example, any check involving a UDisksDrive or a
UDisksBlock object can safely include the fragment
the drive, e.g. “INTEL SSDSA2MH080G1GC (/dev/sda1)” or the block device file e.g. “/dev/vg_lucifer/lv_root” or “/dev/sda1”. However this won't work for operations that isn't on a drive or block device, for example calls on the
Managerobject.
daemon |
A UDisksDaemon. |
|
object |
The GDBusObject that the call is on or |
[allow-none] |
action_id |
The action id to check for. |
|
options |
A GVariant to check for the “auth.no_user_interaction” option or |
[allow-none] |
message |
The message to convey (use N_). |
|
invocation |
The invocation to check for. |
gboolean udisks_daemon_util_get_caller_uid_sync (UDisksDaemon *daemon
,GDBusMethodInvocation *invocation
,GCancellable *cancellable
,uid_t *out_uid
,gid_t *out_gid
,gchar **out_user_name
,GError **error
);
Gets the UNIX user id (and possibly group id and user name) of the
peer represented by invocation
.
daemon |
A UDisksDaemon. |
|
invocation |
||
cancellable |
A GCancellable or |
[allow-none] |
out_uid |
Return location for resolved uid or |
[out] |
out_gid |
Return location for resolved gid or |
[out][allow-none] |
out_user_name |
Return location for resolved user name or |
[out][allow-none] |
error |
Return location for error. |
gboolean udisks_daemon_util_get_caller_pid_sync (UDisksDaemon *daemon
,GDBusMethodInvocation *invocation
,GCancellable *cancellable
,pid_t *out_pid
,GError **error
);
Gets the UNIX process id of the peer represented by invocation
.
daemon |
A UDisksDaemon. |
|
invocation |
||
cancellable |
A GCancellable or |
[allow-none] |
out_pid |
Return location for resolved pid or |
[out] |
error |
Return location for error. |
gboolean udisks_daemon_util_setup_by_user (UDisksDaemon *daemon
,UDisksObject *object
,uid_t user
);
Checks whether the device represented by object
(if any) has been
setup by user
.
daemon |
A UDisksDaemon. |
|
object |
The GDBusObject that the call is on or |
|
user |
The user in question. |
gpointer udisks_daemon_util_dup_object (gpointer interface_
,GError **error
);
Gets the enclosing UDisksObject for interface
, if any.
interface_ |
A GDBusInterface-derived instance. |
[type GDBusInterface] |
error |
|
Either NULL
or a
UDisksObject-derived instance that must be released with
g_object_unref()
.
[transfer full][type UDisksObject]
gchar *
udisks_daemon_util_escape (const gchar *str
);
Escapes double-quotes (") and back-slashes()
in a string
using back-slash()
.
gchar *
udisks_daemon_util_escape_and_quote (const gchar *str
);
Like udisks_daemon_util_escape()
but also wraps the result in
double-quotes.
UDisksInhibitCookie *
udisks_daemon_util_inhibit_system_sync
(const gchar *reason
);
Tries to inhibit the system.
Right now only
systemdinhibitors are supported but other inhibitors can be added in the future.
void
udisks_daemon_util_uninhibit_system_sync
(UDisksInhibitCookie *cookie
);
Does nothing if cookie
is NULL
, otherwise uninhibits.
gchar * udisks_daemon_util_hexdump (gconstpointer data
,gsize len
);
Utility function to generate a hexadecimal representation of len
bytes of data
.
void udisks_daemon_util_hexdump_debug (gconstpointer data
,gsize len
);
Utility function to dumps the hexadecimal representation of len
bytes of data
generated with udisks_daemon_util_hexdump()
using
udisks_debug()
.
gboolean udisks_daemon_util_file_set_contents (const gchar *filename
,const gchar *contents
,gssize contents_len
,gint mode_for_new_file
,GError **error
);
Like g_file_set_contents()
but preserves the mode of the file if it
already exists and sets it to mode_for_new_file
otherwise.
filename |
Name of a file to write |
[type filename] |
contents |
String to write to the file. |
[array length=length][element-type guint8] |
contents_len |
Length of |
|
mode_for_new_file |
Mode for new file. |
|
error |
gboolean udisks_daemon_util_on_user_seat (UDisksDaemon *daemon
,UDisksObject *object
,uid_t user
);
Checks whether the device represented by object
(if any) is plugged into
a seat where the caller represented by user
is logged in and active.
This works if object
is a drive or a block object.
daemon |
A UDisksDaemon. |
|
object |
The GDBusObject that the call is on or |
|
user |
The user to check for. |
gchar *
udisks_daemon_util_get_free_mdraid_device
(void
);
Gets a free MD RAID device.
guint16 udisks_ata_identify_get_word (const guchar *identify_data
,guint word_number
);
Gets a “word” from position word_number
from
identify_data
.
identify_data |
A 512-byte array containing ATA IDENTIFY or ATA IDENTIFY PACKET DEVICE data or |
[allow-none] |
word_number |
The word number to get - must be less than 256. |
typedef struct UDisksInhibitCookie UDisksInhibitCookie;
Opaque data structure used in udisks_daemon_util_inhibit_system_sync()
and
udisks_daemon_util_uninhibit_system_sync()
.