view toys/other/fsfreeze.c @ 1775:57f2a26fa92c draft toast

To ensure that toybox can be installed alongside busybox without confusing update-alternatives, the paths of the links installed by toybox should match those installed by busybox. This is accomplished by changing the flags of a few tools within toybox.
author Paul Barker <paul@paulbarker.me.uk>
date Sat, 04 Apr 2015 11:58:06 -0500
parents 0ce03bb85ebd
children
line wrap: on
line source

/* fsfreeze.c - freeze or thaw filesystem
 *
 * No standard.

USE_FSFREEZE(NEWTOY(fsfreeze, "<1>1f|u|[!fu]", TOYFLAG_USR|TOYFLAG_SBIN))

config FSFREEZE
  bool "fsfreeze"
  default y
  depends on TOYBOX_FIFREEZE
  help
    usage: fsfreeze {-f | -u} MOUNTPOINT

    Freeze or unfreeze a filesystem.

    -f	freeze
    -u	unfreeze
*/

#define FOR_fsfreeze
#include "toys.h"
#include <linux/fs.h>

void fsfreeze_main(void)
{
  int fd = xopen(*toys.optargs, O_RDONLY); 
  long p = 1;

  xioctl(fd, (toys.optflags & FLAG_f) ? FIFREEZE : FITHAW, &p);
  xclose(fd);
}