Lines Matching refs:fd

89     int fd, block_size;
93 if ((fd = open(dev, O_RDONLY)) < 0) {
98 if (lseek64(fd, 1024, SEEK_SET) < 0) {
103 if (read(fd, &sb, sizeof(sb)) != sizeof(sb)) {
108 close(fd);
118 static unsigned int get_blkdev_size(int fd)
122 if ( (ioctl(fd, BLKGETSIZE, &nr_sec)) == -1) {
148 int fd;
160 if ( (fd = open(fname, O_RDWR)) < 0) {
165 if ( (nr_sec = get_blkdev_size(fd)) == 0) {
176 if (lseek64(fd, off, SEEK_SET) == -1) {
182 if ( (fd = open(fname, O_RDWR | O_CREAT, 0600)) < 0) {
191 if ((cnt = write(fd, crypt_ftr, sizeof(struct crypt_mnt_ftr))) != sizeof(struct crypt_mnt_ftr)) {
203 if ( (cnt = write(fd, key, crypt_ftr->keysize)) != crypt_ftr->keysize) {
215 if (lseek64(fd, off, SEEK_CUR) == -1) {
220 if ( (cnt = write(fd, salt, SALT_LEN)) != SALT_LEN) {
226 fstat(fd, &statbuf);
229 if (ftruncate(fd, 0x4000)) {
239 close(fd);
247 int fd;
259 if ( (fd = open(fname, O_RDONLY)) < 0) {
264 if ( (nr_sec = get_blkdev_size(fd)) == 0) {
275 if (lseek64(fd, off, SEEK_SET) == -1) {
281 if ( (fd = open(fname, O_RDONLY)) < 0) {
287 fstat(fd, &statbuf);
297 if ( (cnt = read(fd, crypt_ftr, sizeof(struct crypt_mnt_ftr))) != sizeof(struct crypt_mnt_ftr)) {
322 if (lseek(fd, crypt_ftr->ftr_size - sizeof(struct crypt_mnt_ftr), SEEK_CUR) == -1) {
334 if ( (cnt = read(fd, key, crypt_ftr->keysize)) != crypt_ftr->keysize) {
339 if (lseek64(fd, KEY_TO_SALT_PADDING, SEEK_CUR) == -1) {
344 if ( (cnt = read(fd, salt, SALT_LEN)) != SALT_LEN) {
353 close(fd);
389 int fd;
393 if ((fd = open("/dev/device-mapper", O_RDWR)) < 0 ) {
401 if (ioctl(fd, DM_DEV_CREATE, io)) {
408 if (ioctl(fd, DM_DEV_STATUS, io)) {
434 if (! ioctl(fd, DM_TABLE_LOAD, io)) {
450 if (ioctl(fd, DM_DEV_SUSPEND, io)) {
459 close(fd); /* If fd is <0 from a failed open call, it's safe to just ignore the close error */
466 int fd;
471 if ((fd = open("/dev/device-mapper", O_RDWR)) < 0 ) {
479 if (ioctl(fd, DM_DEV_REMOVE, io)) {
488 close(fd); /* If fd is <0 from a failed open call, it's safe to just ignore the close error */
572 int fd;
578 fd = open("/dev/urandom", O_RDONLY);
579 read(fd, key_buf, sizeof(key_buf));
580 read(fd, salt, SALT_LEN);
581 close(fd);
888 int nr_sec, fd;
896 fd = open(real_blkdev, O_RDONLY);
897 nr_sec = get_blkdev_size(fd);
898 close(fd);
1030 static inline int unix_read(int fd, void* buff, int len)
1033 do { ret = read(fd, buff, len); } while (ret < 0 && errno == EINTR);
1037 static inline int unix_write(int fd, const void* buff, int len)
1040 do { ret = write(fd, buff, len); } while (ret < 0 && errno == EINTR);
1141 int rc=-1, fd, i, ret;
1174 fd = open(real_blkdev, O_RDONLY);
1175 if ( (nr_sec = get_blkdev_size(fd)) == 0) {
1179 close(fd);
1216 fd = open(vol_list[i].blk_dev, O_RDONLY);
1217 if ( (vol_list[i].size = get_blkdev_size(fd)) == 0) {
1221 close(fd);
1402 int fd = open("/cache/recovery/command", O_RDWR|O_CREAT|O_TRUNC, 0600);
1403 if (fd >= 0) {
1404 write(fd, "--wipe_data", strlen("--wipe_data") + 1);
1405 close(fd);