G_TYPE_BOOLEAN, \
G_TYPE_INVALID))
-typedef struct {
- const char *id;
- const char *name;
- gboolean supports_unix_owners;
- gboolean can_mount;
- gboolean can_create;
- guint max_label_len;
- gboolean supports_label_rename;
- gboolean supports_online_label_rename;
- gboolean supports_fsck;
- gboolean supports_online_fsck;
- gboolean supports_resize_enlarge;
- gboolean supports_online_resize_enlarge;
- gboolean supports_resize_shrink;
- gboolean supports_online_resize_shrink;
-} DevkitDisksFilesystem;
-
static const DevkitDisksFilesystem known_file_systems[] = {
{
"vfat", /* id */
static const int num_known_file_systems = sizeof (known_file_systems) / sizeof (DevkitDisksFilesystem);
+const DevkitDisksFilesystem *
+devkit_disks_daemon_local_get_fs_details (DevkitDisksDaemon *daemon,
+ const gchar *filesystem_id)
+{
+ gint n;
+ const DevkitDisksFilesystem *ret;
+
+ ret = NULL;
+
+ for (n = 0; n < num_known_file_systems; n++) {
+ if (strcmp (known_file_systems[n].id, filesystem_id) == 0) {
+ ret = &known_file_systems[n];
+ break;
+ }
+ }
+
+ return ret;
+}
+
static GPtrArray *
get_known_filesystems (DevkitDisksDaemon *daemon)
{
DevkitDisksLogger *devkit_disks_daemon_local_get_logger (DevkitDisksDaemon *daemon);
+typedef struct {
+ const char *id;
+ const char *name;
+ gboolean supports_unix_owners;
+ gboolean can_mount;
+ gboolean can_create;
+ guint max_label_len;
+ gboolean supports_label_rename;
+ gboolean supports_online_label_rename;
+ gboolean supports_fsck;
+ gboolean supports_online_fsck;
+ gboolean supports_resize_enlarge;
+ gboolean supports_online_resize_enlarge;
+ gboolean supports_resize_shrink;
+ gboolean supports_online_resize_shrink;
+} DevkitDisksFilesystem;
+
+const DevkitDisksFilesystem *devkit_disks_daemon_local_get_fs_details (DevkitDisksDaemon *daemon,
+ const gchar *filesystem_id);
+
/* exported methods */
gboolean devkit_disks_daemon_enumerate_devices (DevkitDisksDaemon *daemon,
char *argv[10];
GError *error;
PolKitCaller *pk_caller;
+ const DevkitDisksFilesystem *fs_details;
if ((pk_caller = devkit_disks_damon_local_get_caller_for_context (device->priv->daemon, context)) == NULL)
goto out;
- /* TODO: some file systems can do this while mounted; we need something similar
- * to GduCreatableFilesystem cf. gdu-util.h
- */
-
- if (devkit_disks_device_local_is_busy (device)) {
- throw_error (context, DEVKIT_DISKS_ERROR_BUSY,
- "Device is busy");
- goto out;
- }
-
if (device->priv->info.id_usage == NULL ||
strcmp (device->priv->info.id_usage, "filesystem") != 0) {
throw_error (context, DEVKIT_DISKS_ERROR_NOT_LABELED,
goto out;
}
- /* TODO: check if the fs support labels at all */
+ fs_details = devkit_disks_daemon_local_get_fs_details (device->priv->daemon,
+ device->priv->info.id_type);
+ if (fs_details == NULL) {
+ throw_error (context, DEVKIT_DISKS_ERROR_BUSY, "Unknown filesystem");
+ goto out;
+ }
+
+ if (!fs_details->supports_online_label_rename) {
+ if (devkit_disks_device_local_is_busy (device)) {
+ throw_error (context, DEVKIT_DISKS_ERROR_BUSY, "Device is busy");
+ goto out;
+ }
+ }
if (!devkit_disks_damon_local_check_auth (device->priv->daemon,
pk_caller,