www.pudn.com > cryptfs030905.rar > fist_setkey.c
/* * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 2001-2003 Stony Brook University * * For specific licensing information, see the COPYING file distributed with * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. * * This Copyright notice must be kept intact and distributed with all * fistgen sources INCLUDING sources generated by fistgen. */ /* * fist_setkey: set an cipher key for cryptfs. */ #include#include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { int fd, ret; uid_t uid; struct _fist_ioctl_SETKEY val; if (argc != 2) { fprintf(stderr, "Usage: %s file\n", argv[0]); exit(1); } fd = open(argv[1], O_RDONLY); if (fd < 0) { perror(argv[1]); exit(1); } printf("Enter key: "); memset(val.ukey, 0, 16); fgets(val.ukey, 16, stdin); val.uid=getuid(); //printf("uid:%d\n",val.uid); ret = ioctl(fd, FIST_IOCTL_SETKEY, &val); if (ret < 0) { perror("ioctl"); } close(fd); exit(ret); }