* (of type <link linkend="G-VARIANT-TYPE-ARRAY:CAPS">'ay'</link>) for the name of the backing file and
* <literal>backing-file-device</literal>
* (of type <link linkend="G-VARIANT-TYPE-UINT64:CAPS">'t'</link>) for the #dev_t
- * for of the device holding the backing file and
+ * for of the device holding the backing file (or 0 if unknown) and
* <literal>setup-by-uid</literal>
* (of type <link linkend="G-VARIANT-TYPE-UINT32:CAPS">'u'</link>) that is the #uid_t
* of the user who set up the loop device.
/* Check if device exists... */
if (major (backing_file_device) == 0)
{
- /* major==0 -> not regular block device ... could be e.g. NFS ...
+ /* major==0 -> not regular block device or just not known ... could be e.g. NFS ...
* for now, just assume it's still there and mounted
*/
has_backing_device = TRUE;
* @cleanup: A #UDisksCleanup.
* @device_file: The loop device file.
* @backing_file: The backing file.
- * @backing_file_device: The #dev_t of the backing file.
+ * @backing_file_device: The #dev_t of the backing file or 0 if unknown.
* @uid: The user id of the process requesting the loop device.
*
* Adds a new entry to the <filename>/run/udisks2/loop</filename>
guint64 option_size = 0;
uid_t caller_uid;
struct stat fd_statbuf;
- struct stat path_statbuf;
+ gboolean fd_statbuf_valid = FALSE;
WaitForLoopData wait_data;
/* we need the uid of the caller for the loop file */
g_variant_lookup (options, "offset", "t", &option_offset);
g_variant_lookup (options, "size", "t", &option_size);
- /* Validate that st_ino and st_dev from fstat(fd) are the same as
- * for stat(path)
+ /* it's not a problem if fstat fails... for example, this can happen if the user
+ * passes a fd to a file on the GVfs fuse mount
*/
- if (fstat (fd, &fd_statbuf) != 0)
- {
- g_dbus_method_invocation_return_error (invocation,
- UDISKS_ERROR, UDISKS_ERROR_FAILED,
- "Error statting fd: %m");
- goto out;
- }
- if (stat (path, &path_statbuf) != 0)
- {
- g_dbus_method_invocation_return_error (invocation,
- UDISKS_ERROR, UDISKS_ERROR_FAILED,
- "Error statting path: %m");
- goto out;
- }
- if ((fd_statbuf.st_ino != path_statbuf.st_ino) ||
- (fd_statbuf.st_dev != path_statbuf.st_dev))
- {
- g_dbus_method_invocation_return_error (invocation,
- UDISKS_ERROR, UDISKS_ERROR_FAILED,
- "stat(2) info for path and fd does not agree");
- goto out;
- }
+ if (fstat (fd, &fd_statbuf) == 0)
+ fd_statbuf_valid = TRUE;
loop_control_fd = open ("/dev/loop-control", O_RDWR);
if (loop_control_fd == -1)
udisks_cleanup_add_loop (udisks_daemon_get_cleanup (manager->daemon),
loop_device,
path,
- fd_statbuf.st_dev,
+ fd_statbuf_valid ? fd_statbuf.st_dev : 0,
caller_uid);
udisks_notice ("Set up loop device %s (backed by %s)",