Codebase list gedit / d0befbd
xattrs support in the saver. Patch by James Antill Paolo Borelli 17 years ago
3 changed file(s) with 68 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 2006-08-11 Paolo Borelli <pborelli@katamail.com>
1
2 * gedit/gedit-document-saver.c: preserve xattrs, patch by James
3 Antill. Bug #350805.
4
05 2006-08-09 Paolo Borelli <pborelli@katamail.com>
16
27 * gedit/gedit-message-area.c:
8484
8585 AC_SUBST(PSPELL_LIBS)
8686
87 dnl ================================================================
88 dnl libattr checks
89 dnl ================================================================
90
91 AC_CHECK_LIB(attr, attr_copy_fd)
8792
8893 dnl ================================================================
8994 dnl Start of pkg-config checks
4949 #include "gedit-marshal.h"
5050 #include "gedit-utils.h"
5151
52 #ifdef HAVE_LIBATTR
53 #include <attr/libattr.h>
54 #else
55 #define attr_copy_fd(x1, x2, x3, x4, x5, x6) (errno = ENOSYS, -1)
56 #endif
57
5258 #define GEDIT_DOCUMENT_SAVER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
5359 GEDIT_TYPE_DOCUMENT_SAVER, \
5460 GeditDocumentSaverPrivate))
456462
457463 /* ----------- local files ----------- */
458464
465 #ifdef HAVE_LIBATTR
466 /* Save everything: user/root xattrs, SELinux, ACLs. */
467 static int
468 all_xattrs (const char *xattr G_GNUC_UNUSED,
469 struct error_context *err G_GNUC_UNUSED)
470 {
471 return 1;
472 }
473 #endif
474
459475 static gboolean
460476 save_existing_local_file (GeditDocumentSaver *saver)
461477 {
596612 goto fallback_strategy;
597613 }
598614
615 /* copy the xattrs, like user.mime_type, over. Also ACLs and
616 * SELinux context. */
617 if ((attr_copy_fd (saver->priv->local_path,
618 saver->priv->fd,
619 tmp_filename,
620 tmpfd,
621 all_xattrs,
622 NULL) == -1) &&
623 (errno != EOPNOTSUPP) && (errno != ENOSYS))
624 {
625 gedit_debug_message (DEBUG_SAVER, "could not set xattrs");
626
627 close (tmpfd);
628 unlink (tmp_filename);
629 g_free (tmp_filename);
630
631 goto fallback_strategy;
632 }
633
599634 if (!write_document_contents (tmpfd,
600635 GTK_TEXT_BUFFER (saver->priv->document),
601636 saver->priv->encoding,
748783
749784 goto out;
750785 }
786 }
787
788 /* copy the xattrs, like user.mime_type, over. Also ACLs and
789 * SELinux context. */
790 if ((attr_copy_fd (saver->priv->local_path,
791 saver->priv->fd,
792 backup_filename,
793 bfd,
794 all_xattrs,
795 NULL) == -1) &&
796 (errno != EOPNOTSUPP) && (errno != ENOSYS))
797 {
798 gedit_debug_message (DEBUG_SAVER, "could not set xattrs");
799
800 g_set_error (&saver->priv->error,
801 GEDIT_DOCUMENT_ERROR,
802 GEDIT_DOCUMENT_ERROR_CANT_CREATE_BACKUP,
803 "No backup created");
804
805 unlink (backup_filename);
806 close (bfd);
807
808 goto out;
751809 }
752810
753811 if (!copy_file_data (saver->priv->fd, bfd, NULL))