Lines Matching defs:fd

391     int fd, block_size;
395 if ((fd = open(dev, O_RDONLY)) < 0) {
400 if (lseek64(fd, 1024, SEEK_SET) < 0) {
405 if (read(fd, &sb, sizeof(sb)) != sizeof(sb)) {
410 close(fd);
429 int fd;
439 if ( (fd = open(real_blkdev, O_RDWR)) < 0) {
444 if ((nr_sec = get_blkdev_size(fd))) {
455 close(fd);
481 int fd;
499 if ( (fd = open(fname, O_RDWR | O_CREAT, 0600)) < 0) {
505 if (lseek64(fd, starting_off, SEEK_SET) == -1) {
510 if ((cnt = write(fd, crypt_ftr, sizeof(struct crypt_mnt_ftr))) != sizeof(struct crypt_mnt_ftr)) {
515 fstat(fd, &statbuf);
518 if (ftruncate(fd, 0x4000)) {
528 close(fd);
533 static inline int unix_read(int fd, void* buff, int len)
535 return TEMP_FAILURE_RETRY(read(fd, buff, len));
538 static inline int unix_write(int fd, const void* buff, int len)
540 return TEMP_FAILURE_RETRY(write(fd, buff, len));
551 * fd is open read/write on the device that holds the crypto footer and persistent
553 * absolute offset to the start of the crypt_mnt_ftr on the passed in fd.
555 static void upgrade_crypt_ftr(int fd, struct crypt_mnt_ftr *crypt_ftr, off64_t offset)
574 if (lseek64(fd, pdata_offset, SEEK_SET) == -1) {
579 unix_write(fd, pdata, CRYPT_PERSIST_DATA_SIZE);
583 unix_write(fd, pdata, CRYPT_PERSIST_DATA_SIZE);
609 if (lseek64(fd, offset, SEEK_SET) == -1) {
613 unix_write(fd, crypt_ftr, sizeof(struct crypt_mnt_ftr));
620 int fd;
635 if ( (fd = open(fname, O_RDWR)) < 0) {
641 fstat(fd, &statbuf);
648 if (lseek64(fd, starting_off, SEEK_SET) == -1) {
653 if ( (cnt = read(fd, crypt_ftr, sizeof(struct crypt_mnt_ftr))) != sizeof(struct crypt_mnt_ftr)) {
678 upgrade_crypt_ftr(fd, crypt_ftr, starting_off);
685 close(fd);
719 int fd;
760 fd = open(fname, O_RDONLY);
761 if (fd < 0) {
775 if (lseek64(fd, crypt_ftr.persist_data_offset[i], SEEK_SET) < 0) {
779 if (unix_read(fd, pdata, crypt_ftr.persist_data_size) < 0){
796 close(fd);
803 close(fd);
815 int fd;
842 fd = open(fname, O_RDWR);
843 if (fd < 0) {
854 if (lseek64(fd, crypt_ftr.persist_data_offset[0], SEEK_SET) < 0) {
859 if (unix_read(fd, pdata, crypt_ftr.persist_data_size) < 0) {
877 if (lseek(fd, write_offset, SEEK_SET) < 0) {
881 if (unix_write(fd, persist_data, crypt_ftr.persist_data_size) ==
883 if (lseek(fd, erase_offset, SEEK_SET) < 0) {
887 fsync(fd);
889 if (unix_write(fd, pdata, crypt_ftr.persist_data_size) !=
894 fsync(fd);
902 close(fd);
908 close(fd);
979 char *real_blk_name, const char *name, int fd,
1019 if (! ioctl(fd, DM_TABLE_LOAD, io)) {
1034 static int get_dm_crypt_version(int fd, const char *name, int *version)
1045 if (ioctl(fd, DM_LIST_VERSIONS, io)) {
1080 int fd=0;
1087 if ((fd = open("/dev/device-mapper", O_RDWR)) < 0 ) {
1095 if (ioctl(fd, DM_DEV_CREATE, io)) {
1102 if (ioctl(fd, DM_DEV_STATUS, io)) {
1110 if (! get_dm_crypt_version(fd, name, version)) {
1120 fd, extra_params);
1131 if (ioctl(fd, DM_DEV_SUSPEND, io)) {
1140 close(fd); /* If fd is <0 from a failed open call, it's safe to just ignore the close error */
1147 int fd;
1152 if ((fd = open("/dev/device-mapper", O_RDWR)) < 0 ) {
1160 if (ioctl(fd, DM_DEV_REMOVE, io)) {
1169 close(fd); /* If fd is <0 from a failed open call, it's safe to just ignore the close error */
1434 int fd;
1440 fd = open("/dev/urandom", O_RDONLY);
1441 read(fd, key_buf, sizeof(key_buf));
1442 read(fd, salt, SALT_LEN);
1443 close(fd);
1905 int nr_sec, fd;
1912 fd = open(real_blkdev, O_RDONLY);
1913 nr_sec = get_blkdev_size(fd);
1914 close(fd);
2833 int fd = open(filename, O_RDONLY);
2834 if (fd == -1) {
2841 if (unix_read(fd, block, sizeof(block)) < 0) {
2843 close(fd);
2847 close(fd);
2928 int rc=-1, fd, i, ret;
2977 fd = open(real_blkdev, O_RDONLY);
2978 if ( (nr_sec = get_blkdev_size(fd)) == 0) {
2982 close(fd);
3244 int fd = open("/cache/recovery/command", O_RDWR|O_CREAT|O_TRUNC, 0600);
3245 if (fd >= 0) {
3246 write(fd, "--wipe_data\n", strlen("--wipe_data\n") + 1);
3247 write(fd, "--reason=cryptfs_enable_internal\n", strlen("--reason=cryptfs_enable_internal\n") + 1);
3248 close(fd);