char *volname_conf;
char buf[1024], uuid[UUID_PRINTABLE_STRING_LENGTH], *p;
FILE *fp;
+ struct stat tmpstat;
+ int fd;
if ((fp = fopen(obj->options.uuidconf, "r")) != NULL) { /* read open? */
/* scan in the conf file */
fclose(fp);
/* not found or no file, reopen in append mode */
- if ((fp = fopen(obj->options.uuidconf, "a+")) == NULL) {
+
+ if (stat(obj->options.uuidconf, &tmpstat)) { /* no file */
+ if (( fd = creat(obj->options.uuidconf, 0644 )) < 0 ) {
+ LOG(log_error, logtype_atalkd, "ERROR: Cannot create %s (%s).",
+ obj->options.uuidconf, strerror(errno));
+ return NULL;
+ }
+ if (( fp = fdopen( fd, "w" )) == NULL ) {
+ LOG(log_error, logtype_atalkd, "ERROR: Cannot fdopen %s (%s).",
+ obj->options.uuidconf, strerror(errno));
+ close(fd);
+ return NULL;
+ }
+ } else if ((fp = fopen(obj->options.uuidconf, "a+")) == NULL) { /* not found */
LOG(log_error, logtype_afpd, "Cannot create or append to %s (%s).",
obj->options.uuidconf, strerror(errno));
return NULL;