summaryrefslogtreecommitdiffstats
path: root/daemon/file.c
Commit message (Collapse)AuthorAgeFilesLines
* daemon: Don't need to prefix error messages with the command name.Richard Jones2010-02-121-12/+12
| | | | | | | | | | | | | | | | | | | | The RPC stubs already prefix the command name to error messages. The daemon doesn't have to do this. As a (small) benefit this also makes the daemon slightly smaller. Code in the daemon such as: if (argv[0] == NULL) { reply_with_error ("passed an empty list"); return NULL; } now results in error messages like this: ><fs> command "" libguestfs: error: command: passed an empty list (whereas previously you would have seen ..command: command:..)
* Add 'filesize' call.Richard Jones2010-01-251-0/+18
| | | | | Returns the size of a file. You can already do this with 'stat', but this call is good for scripting.
* daemon: Use gnulib futimens module.Richard Jones2009-11-251-4/+0
| | | | | | | | | Instead of checking for futimens support and falling back (incorrectly in one case) to using futimes, use gnulib's module. However the gnulib module does not yet support Win32, so this change is only really useful on platforms like RHEL 5.
* use STREQ, not strcmp: part 1Jim Meyering2009-11-091-2/+2
| | | | | git grep -l 'strcmp *([^=]*== *0'|xargs \ perl -pi -e 's/\bstrcmp( *\(.*?\)) *== *0/STREQ$1/g'
* change strncmp() == 0 to STREQLEN()Jim Meyering2009-11-091-1/+1
| | | | | git grep -l 'strncmp *([^=]*== *0'|xargs \ perl -pi -e 's/\bstrncmp( *\(.*?\)) *== *0\b/STREQLEN$1/g'
* New API call: preadRichard Jones2009-11-021-0/+52
| | | | | guestfs_pread lets you do partial file reads from arbitrary places within a file. It works like the pread(2) system call.
* New API calls: truncate, truncate_size, mkdir_mode, utimens, lchown.Richard Jones2009-11-021-0/+17
| | | | | | | | | | | | | | | truncate, truncate_size: Used to truncate files to a particular size, or to zero bytes. mkdir_mode: Like mkdir but allows you to also specify the initial permissions for the new directory. utimens: Set timestamp on a file with nanosecond accuracy. lchown: Corresponding to lchown(2) syscall (we already have chown). The implementation is complicated by the fact that we had to add an Int64 parameter type to the generator.
* generator.ml: finish adding Dev_or_Path supportJim Meyering2009-08-131-2/+0
| | | | | | | | | | * src/generator.ml: Update all rules to handle Dev_or_Path. (the above changes to generator.ml are mostly mechanical) Emit a use of REQUIRE_ROOT_OR_RESOLVE_DEVICE. * daemon/upload.c (do_download): Remove use of REQUIRE_ROOT_OR_RESOLVE_DEVICE, now that it's automatically done in calling code. * daemon/file.c (do_file): Likewise.
* generator.ml: use new "Pathname" designationJim Meyering2009-08-131-45/+12
| | | | | | | | | | Nearly every file-related function in daemons/*.c is affected: Remove this pair of statements from each affected do_* function: - NEED_ROOT (return -1); - ABS_PATH (dir, return -1); and change the type of the corresponding parameter to "const char *". * src/generator.ml: Emit NEED_ROOT just once, even when there are two or more Pathname args.
* update all NEED_ROOT usesJim Meyering2009-08-131-11/+11
| | | | | | run this command: git grep -l -w NEED_ROOT|xargs perl -pi -e \ 's/(NEED_ROOT) \((.*?)\)/$1 (return $2)/'
* s/NEED_ROOT_OR_IS_DEVICE/REQUIRE_ROOT_OR_RESOLVE_DEVICE/Jim Meyering2009-08-131-1/+1
|
* manually adjust ABS_PATH uses for new semanticsJim Meyering2009-08-131-1/+1
| | | | * daemon/file.c (do_cat): fix an ABS_PATH use
* update all uses of ABS_PATHJim Meyering2009-08-131-10/+10
| | | | | | run this command: git grep -l -w ABS_PATH|xargs perl -pi -e \ 's/(?:ABS_PATH)( \(.*?,) (.*?)\)/ABS_PATH$1 return $2)/'
* change almost all uses: s/IS_DEVICE/RESOLVE_DEVICE/Jim Meyering2009-08-131-1/+1
| | | | | | Use this command: git grep -l -w IS_DEVICE|xargs perl -pi -e \ 's/\b(?:IS_DEVICE)\b( \(.*?,) (.*?)\)/RESOLVE_DEVICE$1 return $2)/'
* daemon/file.c: remove duplicate absolute-path checkJim Meyering2009-08-101-1/+0
| | | | | | * daemon/file.c (do_file): Remove redundant use of ABS_PATH. It's redundant because the preceding line invokes NEED_ROOT_OR_IS_DEVICE, which also invokes ABS_PATH.
* Convert all TABs-as-indentation to spaces.Jim Meyering2009-08-031-9/+9
| | | | | | | | | | | Do it by running this command: [exempted files are matched via .x-sc_TAB_in_indentation] git ls-files \ | pcregrep -vf .x-sc_TAB_in_indentation \ | xargs pcregrep -l '^ *\t' \ | xargs perl -MText::Tabs -ni -le \ '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
* Pass '-z' parameter to 'file' command so it looks inside compressed files.Richard Jones2009-07-281-1/+1
| | | | Also we deprecate the old 'zfile' command.
* Replace shell_quote function with %Q and %R printf specifiers.Richard Jones2009-07-281-14/+10
| | | | | | | %Q => simple shell quoted string %R => path will be prefixed by /sysroot eg. snprintf (cmd, sizeof cmd, "cat %R", path); system (cmd);
* Fix typo in error message.Richard Jones2009-07-221-1/+1
|
* Generator: Implement RBufferOut and "read-file" call.Richard W.M. Jones2009-07-211-0/+59
| | | | | | | | | This commit implements the RBufferOut type for returning arbitrary 8 bit data from calls. We also implement the guestfs_read_file call to read a whole file that can contain any 8 bit content, but up to a limit of ~ 2 MB.
* Make /sysroot path configurable.Richard Jones2009-07-181-6/+6
| | | | | | | | | Currently /sysroot is hard-coded throughout the daemon code. This patch turns the path into a variable so that we can change it in future, for example to allow standalone mode to be implemented. This patch was tested by running all the C API tests successfully.
* Implement new 'zfile' command, to show file type inside compressed files.Richard Jones2009-07-131-0/+60
|
* remove trailing blanksJim Meyering2009-07-031-1/+1
|
* Check return value from close() call.Richard Jones2009-06-221-1/+5
|
* In the daemon, change all const char * parameters to char *.Richard Jones2009-06-101-10/+10
|
* Fix missing futimens bug.Richard Jones2009-05-061-1/+7
|
* Use AC_GNU_SOURCE in daemon. Don't need _GNU_SOURCE in C files any more.Richard W.M. Jones2009-04-231-2/+0
|
* Implement NEED_ROOT_OR_IS_DEVICE macro.Richard Jones2009-04-191-1/+1
|
* 'guestfish edit' commands and several bugfixes.Richard Jones2009-04-151-2/+2
|
* Fix 'file(1)' command to work on /dev devices.Richard Jones2009-04-141-10/+15
|
* Added file(1) command.Richard Jones2009-04-131-0/+49
|
* Added test suite.Richard Jones2009-04-111-0/+74
|
* New commands: rm rmdir rm-rf mkdir mkdir-p chmod chownRichard Jones2009-04-101-0/+60
|
* Definition and implementation of new guestfs_read_lines API call.Richard Jones2009-04-081-1/+53
|
* Implementations of 'cat', 'ls', and some cleanups.Richard Jones2009-04-061-9/+69
|
* Implement RString and RStringList return types.Richard Jones2009-04-041-0/+7
| | | | | - implement 'll' command. - outlines for 'ls' and 'cat' commands.
* Implemented 'mount' and 'touch' commands.Richard Jones2009-04-031-0/+63