Lines Matching defs:fd

257 calculate_hashed_pin_offset(int fd)
261 if (lseek(fd, KS_HASHED_PIN_SALT_LEN_OFFSET, SEEK_SET)
266 if (readn_nointr(fd, (char *)&salt_length,
286 lock_file(int fd, boolean_t read_lock, boolean_t set_lock)
303 while ((r = fcntl(fd, F_SETLKW, &lock_info)) == -1) {
312 while ((r = fcntl(fd, F_SETLKW, &lock_info)) == -1) {
328 int fd, buf;
366 fd = open_nointr(get_desc_file_path(ks_desc_file),
368 if (fd < 0) {
378 if (lock_file(fd, B_FALSE, B_TRUE) != 0) {
380 (void) close(fd);
388 (void) lock_file(fd, B_FALSE, B_FALSE);
390 (void) close(fd);
398 (void) lock_file(fd, B_FALSE, B_FALSE);
400 (void) close(fd);
410 if ((writen_nointr(fd, (char *)ver_buf, sizeof (ver_buf)))
417 if (writen_nointr(fd, (void *)&buf, KS_VER_SIZE) != KS_VER_SIZE) {
423 if (writen_nointr(fd, (void *)&buf, KS_COUNTER_SIZE)
430 if (writen_nointr(fd, (void *)salt, KS_KEY_SALT_SIZE)
436 if (writen_nointr(fd, (void *)salt, KS_HMAC_SALT_SIZE)
456 if (writen_nointr(fd, (void *)&ulong_buf, KS_HASHED_PIN_SALT_LEN_SIZE)
461 if (writen_nointr(fd, (void *)hashed_pin_salt,
468 if (writen_nointr(fd, (void *)&ulong_buf, KS_HASHED_PINLEN_SIZE)
473 if (writen_nointr(fd, (void *)hashed_pin, hashed_pin_len)
478 (void) lock_file(fd, B_FALSE, B_FALSE);
480 (void) close(fd);
486 (void) lock_file(fd, B_FALSE, B_FALSE);
488 (void) close(fd);
496 * Determines if the file referenced by "fd" has the same
508 is_inode_same(int fd, char *fname, boolean_t *same)
512 if (fstat(fd, &fd_stat) != 0) {
531 acquire_file_lock(int *fd, char *fname, mode_t mode) {
539 if (lock_file(*fd, read_lock, B_TRUE) != 0) {
547 if (is_inode_same(*fd, fname, &same_inode) != 0) {
548 (void) lock_file(*fd, B_TRUE, B_FALSE); /* unlock file */
559 if (lock_file(*fd, B_TRUE, B_FALSE) != 0) {
563 (void) close(*fd);
566 *fd = open_nointr(fname, mode|O_NONBLOCK);
567 if (*fd < 0) {
572 if (lock_file(*fd, read_lock, B_TRUE) != 0) {
576 if (is_inode_same(*fd, fname, &same_inode) != 0) {
577 (void) lock_file(*fd, B_TRUE, B_FALSE); /* unlock */
596 int fd;
601 fd = open_nointr(fname, mode|O_NONBLOCK);
602 if (fd < 0) {
607 fd = open_nointr(fname, mode|O_NONBLOCK);
608 if (fd < 0) {
618 return (fd);
621 if (acquire_file_lock(&fd, fname, mode) != 0) {
622 if (fd > 0) {
623 (void) close(fd);
629 return (fd);
668 /* make sure we have a valid fd */
689 int fd;
701 fd = open_nointr(obj_fname, oflag|O_NONBLOCK);
702 if (fd < 0) {
708 return (fd);
711 if (acquire_file_lock(&fd, obj_fname, oflag) != 0) {
712 if (fd > 0) {
713 (void) close(fd);
719 return (fd);
735 create_updated_keystore_version(int fd, char *tmp_fname)
755 if (readn_nointr(fd, buf, KS_PKCS11_VER_SIZE) != KS_PKCS11_VER_SIZE) {
767 if (readn_nointr(fd, &version, KS_VER_SIZE) != KS_VER_SIZE) {
782 nread = readn_nointr(fd, buf, BUFSIZ);
787 nread = readn_nointr(fd, buf, BUFSIZ);
870 get_hashed_pin(int fd, char **hashed_pin)
875 if (calculate_hashed_pin_offset(fd) != 0) {
881 if (lseek(fd, ks_hashed_pinlen_offset, SEEK_SET)
886 if (readn_nointr(fd, (char *)&hashed_pin_size,
898 if ((readn_nointr(fd, *hashed_pin, hashed_pin_size))
977 int fd;
986 if ((fd = open_and_lock_object_file(ks_handle, oflag, B_FALSE)) < 0) {
990 return (fd);
997 * fd: file descriptor returned from soft_keystore_lock_object
1007 soft_keystore_unlock_object(int fd)
1009 if (lock_file(fd, B_TRUE, B_FALSE) != 0) {
1013 (void) close(fd);
1039 int fd, ret_val = 0;
1042 if ((fd = open_and_lock_keystore_desc(O_RDONLY,
1047 if (lseek(fd, KS_VER_OFFSET, SEEK_SET) != KS_VER_OFFSET) {
1052 if (readn_nointr(fd, (char *)&buf, KS_VER_SIZE) != KS_VER_SIZE) {
1061 if (lock_file(fd, B_TRUE, B_FALSE) < 0) {
1066 (void) close(fd);
1093 int fd, ret_val = 0;
1096 if ((fd = open_and_lock_object_file(ks_handle, O_RDONLY,
1105 if (readn_nointr(fd, (char *)&tmp, OBJ_VER_SIZE) != OBJ_VER_SIZE) {
1114 if (lock_file(fd, B_TRUE, B_FALSE) < 0) {
1120 (void) close(fd);
1150 int fd, ret_val = -1;
1153 if ((fd = open_and_lock_keystore_desc(O_RDONLY, B_FALSE,
1158 rv = get_hashed_pin(fd, hashed_pin);
1165 if (lock_file(fd, B_TRUE, B_FALSE) < 0) {
1170 (void) close(fd);
1439 int fd, tmp_ks_fd, version, ret_val = -1;
1466 if ((fd = open_and_lock_keystore_desc(O_RDWR, B_TRUE,
1481 (void) close(fd);
1486 if (readn_nointr(fd, filebuf, KS_PKCS11_VER_SIZE)
1497 if (readn_nointr(fd, &version, KS_VER_SIZE) != KS_VER_SIZE) {
1512 if (readn_nointr(fd, filebuf, KS_COUNTER_SIZE) != KS_COUNTER_SIZE) {
1526 if (readn_nointr(fd, (char *)crypt_salt, KS_KEY_SALT_SIZE)
1536 if (readn_nointr(fd, (char *)hmac_salt, KS_HMAC_SALT_SIZE)
1601 if (readn_nointr(fd, (char *)&hashed_pin_salt_length,
1618 if ((readn_nointr(fd, hashed_pin_salt, hashed_pin_salt_length)) !=
1769 if (lock_file(fd, B_FALSE, B_FALSE) < 0) {
1779 (void) close(fd);
1811 int fd;
1816 if ((fd = open_and_lock_keystore_desc(O_RDONLY,
1826 if (lseek(fd, KS_KEY_SALT_OFFSET, SEEK_SET) != KS_KEY_SALT_OFFSET) {
1830 if (readn_nointr(fd, (char *)crypt_salt, KS_KEY_SALT_SIZE)
1845 if (lseek(fd, KS_HMAC_SALT_OFFSET, SEEK_SET) != KS_HMAC_SALT_OFFSET) {
1849 if (readn_nointr(fd, (char *)hmac_salt, KS_HMAC_SALT_SIZE)
1863 (void) lock_file(fd, B_TRUE, B_FALSE);
1864 (void) close(fd);
2035 int fd;
2046 if ((fd = open_and_lock_object_file(ks_handle, O_RDONLY,
2063 if (readn_nointr(fd, &(obj->obj_version), OBJ_VER_SIZE)
2070 if (readn_nointr(fd, iv, OBJ_IV_SIZE) != OBJ_IV_SIZE) {
2075 if (readn_nointr(fd, obj_hmac, OBJ_HMAC_SIZE) != OBJ_HMAC_SIZE) {
2080 rv = read_obj_data(fd, (char **)&buf, &nread);
2155 (void) lock_file(fd, B_TRUE, B_FALSE);
2158 (void) close(fd);
2203 int fd, tmp_ks_fd, obj_fd;
2227 if ((fd = open_and_lock_keystore_desc(O_RDWR, B_FALSE,
2242 (void) close(fd);
2247 if (readn_nointr(fd, filebuf, KS_PKCS11_VER_SIZE)
2258 if (readn_nointr(fd, &version, KS_VER_SIZE) != KS_VER_SIZE) {
2272 if (readn_nointr(fd, &counter, KS_COUNTER_SIZE) != KS_COUNTER_SIZE) {
2412 nread = readn_nointr(fd, filebuf, sizeof (filebuf));
2417 nread = readn_nointr(fd, filebuf, sizeof (filebuf));
2425 if (lock_file(fd, B_FALSE, B_FALSE) != 0) {
2426 (void) close(fd);
2430 (void) close(fd);
2444 (void) lock_file(fd, B_FALSE, B_FALSE);
2447 (void) close(fd);
2480 int fd, ks_fd, tmp_fd, version;
2514 if ((fd = open_and_lock_object_file(ks_handle, O_RDWR,
2546 if (readn_nointr(fd, (char *)&version, OBJ_VER_SIZE) != OBJ_VER_SIZE) {
2657 if (lock_file(fd, B_FALSE, B_FALSE) < 0) {
2658 (void) close(fd);
2667 (void) close(fd);
2673 (void) close(fd);
2682 (void) close(fd);
2714 int fd;
2720 if ((fd = open_and_lock_keystore_desc(O_RDWR, B_FALSE,
2727 if (create_updated_keystore_version(fd, tmp_ks_name) != 0) {
2765 if (lock_file(fd, B_FALSE, B_FALSE) != 0) {
2766 (void) close(fd);
2771 (void) close(fd);
2787 int fd, ret_val = -1;
2790 if ((fd = open_and_lock_keystore_desc(O_RDONLY, B_FALSE,
2795 if (lseek(fd, KS_HASHED_PIN_SALT_LEN_OFFSET, SEEK_SET)
2800 if (readn_nointr(fd, (char *)&hashed_pin_salt_size,
2811 if ((readn_nointr(fd, *salt, hashed_pin_salt_size))
2821 if (lock_file(fd, B_TRUE, B_FALSE) < 0) {
2825 (void) close(fd);
2860 int fd;
2864 if ((fd = open_and_lock_keystore_desc(O_RDONLY, B_FALSE,
2869 if (lseek(fd, KS_KEY_SALT_OFFSET, SEEK_SET) != KS_KEY_SALT_OFFSET) {
2874 if (readn_nointr(fd, (char *)crypt_salt, KS_KEY_SALT_SIZE)
2887 ret_val = get_hashed_pin(fd, hashed_pin);
2893 if (lock_file(fd, B_TRUE, B_FALSE) < 0) {
2898 (void) close(fd);