Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jul 2013 08:56:49 GMT
From:      dpl@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r254611 - soc2013/dpl/head/contrib/xz/src/xz
Message-ID:  <201307110856.r6B8unpO018243@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dpl
Date: Thu Jul 11 08:56:49 2013
New Revision: 254611
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254611

Log:
  Prepare everything to write io_files_open(). Which will open all the files as needed, and limit them.
  The compressing/decompressing functions will accept file_pair as arguments instead (instead of opening files and doing the stuff).
  

Modified:
  soc2013/dpl/head/contrib/xz/src/xz/coder.c
  soc2013/dpl/head/contrib/xz/src/xz/coder.h
  soc2013/dpl/head/contrib/xz/src/xz/file_io.c
  soc2013/dpl/head/contrib/xz/src/xz/file_io.h
  soc2013/dpl/head/contrib/xz/src/xz/list.c
  soc2013/dpl/head/contrib/xz/src/xz/main.c

Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.c
==============================================================================
--- soc2013/dpl/head/contrib/xz/src/xz/coder.c	Thu Jul 11 07:17:03 2013	(r254610)
+++ soc2013/dpl/head/contrib/xz/src/xz/coder.c	Thu Jul 11 08:56:49 2013	(r254611)
@@ -609,9 +609,8 @@
 
 
 extern void
-coder_run(const char *filename[], int files)
+coder_run(const char *filename)
 {
-	file_pair all_files
 	// Set and possibly print the filename for the progress message.
 	message_filename(filename);
 
@@ -641,9 +640,6 @@
 			// Don't open the destination file when --test
 			// is used.
 			if (opt_mode == MODE_TEST || !io_open_dest(pair)) {
-#if defined(CAPSICUM)
-				limitfd(pair);
-#endif
 				// Initialize the progress indicator.
 				const uint64_t in_size
 						= pair->src_st.st_size <= 0

Modified: soc2013/dpl/head/contrib/xz/src/xz/coder.h
==============================================================================
--- soc2013/dpl/head/contrib/xz/src/xz/coder.h	Thu Jul 11 07:17:03 2013	(r254610)
+++ soc2013/dpl/head/contrib/xz/src/xz/coder.h	Thu Jul 11 08:56:49 2013	(r254611)
@@ -58,4 +58,4 @@
 extern void coder_set_compression_settings(void);
 
 /// Compress or decompress the given file
-extern void coder_run(const char *filename[], int files);
+extern void coder_run(const char *filename);

Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.c
==============================================================================
--- soc2013/dpl/head/contrib/xz/src/xz/file_io.c	Thu Jul 11 07:17:03 2013	(r254610)
+++ soc2013/dpl/head/contrib/xz/src/xz/file_io.c	Thu Jul 11 08:56:49 2013	(r254611)
@@ -604,9 +604,6 @@
 			free(pair->dest_name);
 			return true;
 		}
-#if defined(CAPSICUM)
-		limitfd(pair);
-#endif
 	}
 
 	// If this really fails... well, we have a safe fallback.
@@ -959,6 +956,12 @@
 	return io_write_buf(pair, buf->u8, size);
 }
 
+extern file_pair
+io_open_files(char *filenames[], int files)
+{
+	return;
+}
+
 #if defined(CAPSICUM)
 extern void
 limitfd(file_pair *pair)

Modified: soc2013/dpl/head/contrib/xz/src/xz/file_io.h
==============================================================================
--- soc2013/dpl/head/contrib/xz/src/xz/file_io.h	Thu Jul 11 07:17:03 2013	(r254610)
+++ soc2013/dpl/head/contrib/xz/src/xz/file_io.h	Thu Jul 11 08:56:49 2013	(r254611)
@@ -128,6 +128,16 @@
 ///             and error message printed.
 extern bool io_write(file_pair *pair, const io_buf *buf, size_t size);
 
+
+/// \brief      Open all the files as needed.
+///
+/// \param      filenames    Array containing all the filenames to be open.
+/// \param      files     Number of files to open.
+///
+/// \return     Returns an array of file_pairs.
+extern file_pair io_open_files(char *filenames[], int  files);
+
+
 #if defined(CAPSICUM)
 /// \brief      Limits fd using FreeBSD's Capsicum framework.
 ///

Modified: soc2013/dpl/head/contrib/xz/src/xz/list.c
==============================================================================
--- soc2013/dpl/head/contrib/xz/src/xz/list.c	Thu Jul 11 07:17:03 2013	(r254610)
+++ soc2013/dpl/head/contrib/xz/src/xz/list.c	Thu Jul 11 08:56:49 2013	(r254611)
@@ -1059,16 +1059,20 @@
 extern void
 list_file(const char *filename)
 {
+	int i;
+
 	if (opt_format != FORMAT_XZ && opt_format != FORMAT_AUTO)
 		message_fatal(_("--list works only on .xz files "
 				"(--format=xz or --format=auto)"));
 
+	for ( i = 0; i < files; i++) {
+
 	message_filename(filename);
 
 	if (filename == stdin_filename) {
 		message_error(_("--list does not support reading from "
 				"standard input"));
-		return;
+		continue;
 	}
 
 	// Unset opt_stdout so that io_open_src() won't accept special files.
@@ -1077,7 +1081,7 @@
 	opt_force = true;
 	file_pair *pair = io_open_src(filename);
 	if (pair == NULL)
-		return;
+		continue;
 
 	xz_file_info xfi = XZ_FILE_INFO_INIT;
 	if (!parse_indexes(&xfi, pair)) {

Modified: soc2013/dpl/head/contrib/xz/src/xz/main.c
==============================================================================
--- soc2013/dpl/head/contrib/xz/src/xz/main.c	Thu Jul 11 07:17:03 2013	(r254610)
+++ soc2013/dpl/head/contrib/xz/src/xz/main.c	Thu Jul 11 08:56:49 2013	(r254611)
@@ -208,7 +208,8 @@
 		signals_init();
 
 	// coder_run() handles compression, decompression, and testing.
-	// list_file() is for --list.
+	// list_file() is for --list. 
+	// We have to limit both functions with Capsicum.
 	void (*run)(const char *filename) = opt_mode == MODE_LIST
 			 ? &list_file : &coder_run;
 
@@ -244,9 +245,12 @@
 			// handling the special case of stdin.
 			args.arg_names[i] = (char *)stdin_filename;
 			files++;
+
+/*			// Do the actual compression/decompression.*/
+/*			run(args.arg_names[i]);*/
 		}
 	}
-	run(args.arg_names, files);
+
 
 	// If --files or --files0 was used, process the filenames from the
 	// given file or stdin. Note that here we don't consider "-" to



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307110856.r6B8unpO018243>