Re: adding new info to GnomeVFSFileInfo
- From: Christophe Fergeau <teuf users sourceforge net>
- To: Ian McKellar <yakk yakk net>
- Cc: gnome-vfs-list gnome org
- Subject: Re: adding new info to GnomeVFSFileInfo
- Date: 18 Sep 2002 09:44:31 +0200
> > + GNOME_VFS_PERM_ACCESS_READABLE = 1 << 16,
> > + GNOME_VFS_PERM_ACCESS_WRITEABLE = 1 << 17,
> > + GNOME_VFS_PERM_ACCESS_EXECUTABLE = 1 << 18
>
> I think its a good idea to put these flags above the space used by POSIX
> in case we want to support flags like SUID in the future. I was a little
> concerned that the GnomeVFSFilePermissions might change size, but it
> doesn't look like it will on Linux/x86 or Solaris/sparc. Does anyone
> know of a platform we support that this will break on?
What is "above the space used by POSIX" ? Is it enough to put them at
bits 16 17 and 18, or would you like them to be "higher" ? (I put them
there because I didn't know exactly which bits were used).
>
> Can you check for error returns from access (-1).
access returns -1 when an error occurred, or when the file being tested
doesn't have the correct permissions. Would you like this code to check
if access returned -1, and then immediatly return if a "real" error
occurred ?
>
> Oh, and the standard style nitpick that you need to put a space between
> function names and parens - foo (bar) vs foo(bar).
>
Ok, I'll change that (even if that's ugly :p )
> > +static void get_access_info (GnomeVFSURI *uri, GnomeVFSFileInfo *file_info)
> > +{
> > + gint i;
> > + gchar *name;
> > + struct param {
> > + char c;
> > + GnomeVFSFilePermissions perm;
> > + };
> > + struct param params[3] = {{'r', GNOME_VFS_PERM_ACCESS_READABLE},
> > + {'w', GNOME_VFS_PERM_ACCESS_WRITEABLE},
> > + {'x', GNOME_VFS_PERM_ACCESS_EXECUTABLE}};
> > +
> > + /* FIXME: escape for shell */
> > + name = gnome_vfs_unescape_string (uri->text, G_DIR_SEPARATOR_S);
> > +
> > + if ( *name == '\0' ) {
> > + g_free(name);
> > + name = g_strdup ("'/'");
> > + }
> > +
> > + for (i = 0; i<3; i++) {
> > + gchar c;
> > + gchar *cmd;
> > + SshHandle *handle;
> > + GnomeVFSFileSize bytes_read;
> > + GnomeVFSResult result;
> > +
> > + cmd = g_strdup_printf("access -%c %s && echo $?",
> > + params[i].c, name);
> > + result = ssh_connect (&handle, uri, cmd);
> > + g_free (cmd);
> > +
> > + if (result != GNOME_VFS_OK) {
> > + return;
> > + }
> > +
> > + result = ssh_read (handle, &c, 1, &bytes_read);
> > + if ((bytes_read > 0) && (c == '0')) {
> > + g_print("%c\n", params[i].c);
> > + file_info->permissions |= params[i].perm;
> > + }
> > + ssh_destroy (handle);
> > + }
> > + file_info->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_ACCESS;
> > +}
> > +
>
> Perhaps this should go into a version of gnome_vfs_parse_ls_lga that
> accepts a username in libgnomevfs/gnome-vfs-parse-ls.[ch] so that we can
> share this code with the ftp method and extfs methods...
>
I don't follow you there... I don't see anything in that function which
can be useful to the ftp method for example. It runs access in a remote
shell (using ssh specific functions) and parses its output. What could
go in gnome_vfs_parse_ls_lga is something which would guess the access
rights for a file by looking at the owner of a file, but I haven't
written such a function yet.
Thanks,
Christophe
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]